00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef OM_HGUARD_UTILS_H
00024 #define OM_HGUARD_UTILS_H
00025
00026 #include <xapian/visibility.h>
00027
00028 #include <string>
00029 using std::string;
00030
00031 #include <cstdlib>
00032 #include <sys/types.h>
00033 #include "safesysstat.h"
00034 #include "safeunistd.h"
00035
00038 XAPIAN_VISIBILITY_DEFAULT
00039 bool file_exists(const string &fname);
00040
00043 XAPIAN_VISIBILITY_DEFAULT
00044 bool dir_exists(const string &dirname);
00045
00047 inline int unlink(const string &filename) { return unlink(filename.c_str()); }
00048
00050 inline int system(const string &command) { return system(command.c_str()); }
00051
00053 inline int mkdir(const string &filename, mode_t mode) {
00054 return mkdir(filename.c_str(), mode);
00055 }
00056
00058 inline int stat(const string &filename, struct stat *buf) {
00059 return stat(filename.c_str(), buf);
00060 }
00061
00069 void removedir(const string &dirname);
00070
00071 namespace Xapian {
00072 namespace Internal {
00073 bool within_DBL_EPSILON(double a, double b);
00074 }
00075 }
00076
00080 class fdcloser {
00081 public:
00082 fdcloser(int fd_) : fd(fd_) {}
00083 ~fdcloser() {
00084 if (fd >= 0) {
00085 (void)close(fd);
00086 }
00087 }
00088 private:
00089 int fd;
00090 };
00091
00092 #endif