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