filters
gfile.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef GFILE_H
00012 #define GFILE_H
00013
00014 #include <aconf.h>
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <stddef.h>
00018 #if defined(WIN32)
00019 # include <sys/stat.h>
00020 # ifdef FPTEX
00021 # include <win32lib.h>
00022 # else
00023 # include <windows.h>
00024 # endif
00025 #elif defined(ACORN)
00026 #elif defined(MACOS)
00027 # include <ctime.h>
00028 #else
00029 # include <unistd.h>
00030 # include <sys/types.h>
00031 # ifdef VMS
00032 # include "vms_dirent.h"
00033 # elif HAVE_DIRENT_H
00034 # include <dirent.h>
00035 # define NAMLEN(d) strlen((d)->d_name)
00036 # else
00037 # define dirent direct
00038 # define NAMLEN(d) (d)->d_namlen
00039 # if HAVE_SYS_NDIR_H
00040 # include <sys/ndir.h>
00041 # endif
00042 # if HAVE_SYS_DIR_H
00043 # include <sys/dir.h>
00044 # endif
00045 # if HAVE_NDIR_H
00046 # include <ndir.h>
00047 # endif
00048 # endif
00049 #endif
00050 #include "gtypes.h"
00051
00052 class GString;
00053
00054
00055
00056
00057 extern GString *getHomeDir();
00058
00059
00060 extern GString *getCurrentDir();
00061
00062
00063
00064 extern GString *appendToPath(GString *path, const char *fileName);
00065
00066
00067
00068 extern GString *grabPath(const char *fileName);
00069
00070
00071 extern GBool isAbsolutePath(const char *path);
00072
00073
00074
00075 extern GString *makePathAbsolute(GString *path);
00076
00077
00078
00079 extern time_t getModTime(const char *fileName);
00080
00081
00082
00083
00084
00085
00086
00087 extern GBool openTempFile(GString **name, FILE **f, const char *mode);
00088
00089
00090 extern GBool executeCommand(const char *cmd);
00091
00092
00093
00094 extern char *getLine(char *buf, int size, FILE *f);
00095
00096
00097
00098
00099
00100 class GDirEntry {
00101 public:
00102
00103 GDirEntry(const char *dirPath, const char *nameA, GBool doStat);
00104 ~GDirEntry();
00105 GString *getName() { return name; }
00106 GBool isDir() { return dir; }
00107
00108 private:
00109
00110 GString *name;
00111 GBool dir;
00112 };
00113
00114 class GDir {
00115 public:
00116
00117 GDir(const char *name, GBool doStatA = gTrue);
00118 ~GDir();
00119 GDirEntry *getNextEntry();
00120 void rewind();
00121
00122 private:
00123
00124 GString *path;
00125 GBool doStat;
00126 #if defined(WIN32)
00127 WIN32_FIND_DATA ffd;
00128 HANDLE hnd;
00129 #elif defined(ACORN)
00130 #elif defined(MACOS)
00131 #else
00132 DIR *dir;
00133 #ifdef VMS
00134 GBool needParent;
00135 #endif
00136 #endif
00137 };
00138
00139 #endif
|