searchengine/util/cpixtools/inc/public/cpixfstools.h
changeset 8 6547bf8ca13a
parent 0 671dee74050a
equal deleted inserted replaced
7:a5fbfefd615f 8:6547bf8ca13a
    26 
    26 
    27 // A lot of POSIX system calls (open, close, read, write) can fail
    27 // A lot of POSIX system calls (open, close, read, write) can fail
    28 // with EINTR which means that they just have to be retried. Now, even
    28 // with EINTR which means that they just have to be retried. Now, even
    29 // if OpenC does not support this, the code here is supposed to be
    29 // if OpenC does not support this, the code here is supposed to be
    30 // platform independent and must work on a true *NIX (like linux).
    30 // platform independent and must work on a true *NIX (like linux).
    31 //_SP is for single parameter
    31 #define Cpt_EINTR_RETRY(res,op)  while (((res=op) == -1) && (errno == EINTR)) { res ++; /* To avoid compiler warning: FIXME */ }
    32 #define Cpt_EINTR_RETRY_SP(op)  while ((op == -1) && (errno == EINTR)) { ; /* NOP */ }
       
    33 
       
    34 // A lot of POSIX system calls (open, close, read, write) can fail
       
    35 // with EINTR which means that they just have to be retried. Now, even
       
    36 // if OpenC does not support this, the code here is supposed to be
       
    37 // platform independent and must work on a true *NIX (like linux).
       
    38 #define Cpt_EINTR_RETRY(res,op)  while (((res=op) == -1) && (errno == EINTR)) { ; /* NOP */ }
       
    39 
    32 
    40 
    33 
    41 // Same as Cpt_EINTR_RETRY, but for cases when the return value is not
    34 // Same as Cpt_EINTR_RETRY, but for cases when the return value is not
    42 // integer, but some pointer, and where failure is signalled through
    35 // integer, but some pointer, and where failure is signalled through
    43 // NULL
    36 // NULL
   165      * @returns the size of the file. -1 is returned on error.
   158      * @returns the size of the file. -1 is returned on error.
   166      */
   159      */
   167     off_t filesize(int fileDesc);
   160     off_t filesize(int fileDesc);
   168 
   161 
   169 
   162 
       
   163     /**
       
   164      * Obtain the size of a directory
       
   165      * 
       
   166      * @param the path of the directory
       
   167      */
       
   168     off_t dirsize(const char * path); 
   170     
   169     
   171     /**
   170     /**
   172      * Returns when the file was last modified or 0 if some error occurred.
   171      * Returns when the file was last modified or 0 if some error occurred.
   173      */
   172      */
   174     time_t filemodified(const char * path);
   173     time_t filemodified(const char * path);
       
   174     
       
   175     /**
       
   176      * Adds delimiter if needed
       
   177      */
       
   178     std::string appendpath(const char* path, const char* item);
   175 
   179 
   176     /**
   180     /**
   177      * Reads line to buffer 
   181      * Reads line to buffer 
   178      */
   182      */
   179     bool fgetline(FILE* file, std::string& line); 
   183     bool fgetline(FILE* file, std::string& line);