Ignore:
Timestamp:
2002-02-27T11:50:16+13:00 (22 years ago)
Author:
jrm21
Message:

Replaced old code to get file descriptors from ofstreams for locking with
c-style open() functions instead. Now works with gcc3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/receptionist.cpp

    r2957 r3007  
    3737#include <assert.h>
    3838#include <time.h>
    39 #include <stdio.h>
     39#include <stdio.h> // for open()
     40#include <fcntl.h> // for open() flags
    4041// following 2 are for printing Last-Modified http header.
    4142#include <sys/stat.h>
     
    695696  char *lfile = filename.getcstr();
    696697
    697   ofstream log (lfile, ios::app);
    698  
    699   if (!log) {
     698  int fd = open(lfile,O_APPEND);
     699 
     700  if (fd == -1) {
    700701    logout << "Error: Couldn't open file " << lfile << "\n";
    701702    delete lfile;
     
    703704  }
    704705
    705   int fd = GSDL_GET_FILEDESC(log);
     706  //int fd = GSDL_GET_FILEDESC(log);
    706707
    707708  // lock_val is set to 0 if file is locked successfully
     
    709710  GSDL_LOCK_FILE (fd);
    710711  if (lock_val == 0) {
    711     log << text_t2utf8 << logstr;
     712    text_t2utf8 << logstr;
     713    char *buffer=new char[logstr.size()];
     714    size_t num_chars;
     715    convertclass::status_t status;
     716    text_t2utf8.convert(buffer, logstr.size(), num_chars, status);
     717    // ignore status - assume it is "finished" as buffer is big enough
     718    write(fd, buffer, num_chars);
    712719    GSDL_UNLOCK_FILE (fd);
     720    delete buffer;
    713721  } else {
    714722    logout << "Error: Couldn't lock file " << lfile << "\n";
    715     log.close();
     723    close(fd);
    716724    delete lfile;
    717725    return false;
    718726  }
    719727
    720   log.close();
     728  close(fd);
    721729       
    722730  delete lfile;
     
    797805    contentout << "Last-Modified: " << asctime(utc_latest);
    798806      }
    799     }
     807    } // end of collection != ""
    800808
    801809    /*
Note: See TracChangeset for help on using the changeset viewer.