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 #ifdef BEOS
00027 #include <fcntl.h>
00028 #endif
00029
00030 #include <defs.h>
00031
00032 class SWDLLEXPORT FileMgr;
00033
00034 class SWDLLEXPORT FileDesc
00035 {
00036
00037 friend class FileMgr;
00038
00039 char *path;
00040 int mode;
00041 int perms;
00042 long offset;
00043 int fd;
00044 FileMgr *parent;
00045 FileDesc *next;
00046
00047 public:
00048 FileDesc (FileMgr * parent, char *path, int mode, int perms);
00049 virtual ~FileDesc ();
00050 int getFd ();
00051 };
00052
00053
00054 class FileMgr
00055 {
00056
00057 friend class FileDesc;
00058
00059 FileDesc *files;
00060 int sysOpen (FileDesc * file);
00061 public:
00062
00063 FileMgr (int maxFiles = 35);
00064 ~FileMgr ();
00065 FileDesc *open (char *path, int mode, int perms = S_IREAD | S_IWRITE);
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