00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020
00021
00022 #ifndef FILEMGR_H
00023 #define FILEMGR_H
00024
00025 #include <sys/stat.h>
00026
00027 #include <defs.h>
00028
00029 class SWDLLEXPORT FileMgr;
00030
00031 class SWDLLEXPORT FileDesc
00032 {
00033
00034 friend class FileMgr;
00035
00036 char *path;
00037 int mode;
00038 int perms;
00039 long offset;
00040 int fd;
00041 FileMgr *parent;
00042 FileDesc *next;
00043
00044 public:
00045 FileDesc (FileMgr * parent, char *path, int mode, int perms);
00046 virtual ~FileDesc ();
00047 int getFd ();
00048 };
00049
00050
00051 class FileMgr
00052 {
00053
00054 friend class FileDesc;
00055
00056 FileDesc *files;
00057 int sysOpen (FileDesc * file);
00058 public:
00059
00060 FileMgr (int maxFiles = 35);
00061 ~FileMgr ();
00062 FileDesc *open (char *path, int mode, int perms = S_IREAD | S_IWRITE);
00063 void close (FileDesc *);
00064
00065 static char existsFile (const char *ipath, const char *ifileName = 0);
00066 static char existsDir (const char *ipath, const char *idirName = 0);
00067
00068
00069
00070 char trunc (FileDesc *);
00071
00072 int maxFiles;
00073 static FileMgr systemFileMgr;
00074 };
00075
00076
00077
00078
00079 #endif