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 #include <fcntl.h>
00027
00028 #include <defs.h>
00029
00030 class SWDLLEXPORT FileMgr;
00031
00032 class SWDLLEXPORT FileDesc
00033 {
00034
00035 friend class FileMgr;
00036
00037 long offset;
00038 int fd;
00039 FileMgr *parent;
00040 FileDesc *next;
00041
00042 public:
00043 FileDesc (FileMgr * parent, char *path, int mode, int perms, bool tryDowngrade);
00044 virtual ~FileDesc ();
00045 int getFd ();
00046 char *path;
00047 int mode;
00048 int perms;
00049 bool tryDowngrade;
00050 };
00051
00052
00053 class FileMgr
00054 {
00055
00056 friend class FileDesc;
00057
00058 FileDesc *files;
00059 int sysOpen (FileDesc * file);
00060 public:
00061
00062 FileMgr (int maxFiles = 35);
00063 ~FileMgr ();
00064 FileDesc *open (char *path, int mode, bool tryDowngrade);
00065 FileDesc *open (char *path, int mode, int perms = S_IREAD | S_IWRITE, bool tryDowngrade = false);
00066 void close (FileDesc *);
00067
00068 static signed char existsFile (const char *ipath, const char *ifileName = 0);
00069 static signed char existsDir (const char *ipath, const char *idirName = 0);
00070
00071
00072
00073 signed char trunc (FileDesc *);
00074
00075 int maxFiles;
00076 static FileMgr systemFileMgr;
00077 };
00078
00079
00080
00081
00082 #endif