HPGCC3 Documentation 3.0 R003
|
00001 //& *** (c) 2006-2011 The HPGCC3 Team *** 00002 //& Claudio Lapilli 00003 //& Ingo Blank 00004 //& 00005 //& This file is licensed under the terms and conditions of the 00006 //& HPGCC3 license that is included with the source distribution. 00007 //& *** (c) 2006-2011 The HPGCC3 Team *** 00008 00009 // $Header: fsystem.h,r42 2006-02-18 04:23:47 ingo $ 00010 00011 00012 #ifndef _FSYSTEM_H 00013 00014 #define _FSYSTEM_H 00015 00016 #ifndef _HPTIME_H 00017 #include <time.h> 00018 #endif 00019 // FILE SYSTEM PUBLIC HEADER FILE 00040 // CONSTANTS 00041 00042 // FILE ATTRIBUTES 00046 #define FSATTR_RDONLY 1 00047 00050 #define FSATTR_HIDDEN 2 00051 00054 #define FSATTR_SYSTEM 4 00055 00058 #define FSATTR_VOLUME 8 00059 00062 #define FSATTR_DIR 16 00063 00066 #define FSATTR_ARCHIVE 32 00067 00070 #define FSATTR_LONGNAME 0xf 00071 00074 #define FSATTR_LONGMASK 0x3f 00075 00076 00077 // OPEN MODES 00083 #define FSMODE_READ 0 // READ PERMISSION (DEFAULT) 00084 00089 #define FSMODE_WRITE 2 // WRITE PERMISSION 00090 00095 #define FSMODE_APPEND 4 // ONLY ALLOW WRITING AFTER EOF 00096 00102 #define FSMODE_MODIFY 8 // WRITE TO ANY POSITION WITHIN FILE 00103 00109 #define FSMODE_NOGROW 16 // DON'T ALLOW FILE TO GROW 00110 00116 #define FSMODE_NOCREATE 32 // DON'T CREATE IF FILE DOESN'T EXIST 00117 00118 00119 00120 // ERRORS RETURNED BY USER-LEVEL FUNCTIONS 00124 #define FS_OK 1 00125 00128 #define FS_ERROR 0 // UNKNOWN ERROR (OR FUNCTION DOESN'T CARE) 00129 00132 #define FS_EOF -1 // END OF FILE 00133 00136 #define FS_BADNAME -2 // INVALID FILE NAME 00137 00140 #define FS_BADVOLUME -3 // INVALID DRIVE 00141 00144 #define FS_NOTFOUND -4 // FILE NOT FOUND 00145 00148 #define FS_CANTWRITE -5 // WRITE FAILED 00149 00152 #define FS_NOCARD -6 // NO CARD INSERTED 00153 00156 #define FS_CHANGED -7 // CARD HAS CHANGED 00157 00160 #define FS_MAXFILES -8 // MAXIMUM NUMBER OF FILES OPEN WAS EXCEEDED 00161 00164 #define FS_OPENDIR -9 // NAME IS AN ALREADY OPEN DIRECTORY 00165 00168 #define FS_OPENFILE -9 // NAME IS AN ALREADY OPEN FILE 00169 00172 #define FS_USED -9 // FILE/DIRECTORY IS BEING USED 00173 00176 #define FS_DISKFULL -10 // DISK IS FULL 00177 00180 #define FS_EXIST -11 // FILE ALREADY EXISTS 00181 00184 #define FS_INVHANDLE -12 // HANDLE IS NOT VALID 00185 00186 00187 00188 00189 // CASE SENSITIVITY MODES 00203 #define FSCASE_SENS 0 // CASE SENSITIVE (RAW NAMES) 00204 00235 #define FSCASE_SENSHP 1 // CASE SENSITIVE (W/SEMICOLON STRIPPING) 00236 00244 #define FSCASE_INSENS 2 // CASE INSENSITIVE 00245 00256 #define FSCASE_SENSHPTRUE 3 // CASE SENSITIVE W/SEMICOLONS BUT RETURNS TRUE NAMES 00257 00258 // FILENAME ANALYSIS RESULT FLAGS (FSGetNameType()) 00264 #define FSNAME_HASVOL 1 // 1 == Name include drive 00265 00271 #define FSNAME_HASPATH 2 // 2 == Name include path 00272 00278 #define FSNAME_ABSPATH 4 // 4 == Path is absolute 00279 00285 #define FSNAME_ENDSLASH 8 // 8 == name ends in slash 00286 00292 #define FSNAME_VOLHP 16 // 16== Drive is HP style (:x:) 00293 00299 #define FSNAME_EMPTY 32 // 32== Name is empty 00300 00306 #define FSNAME_INVALID -1 00307 00308 // BITS 16-31 = DEPTH OF PATH (0=CURRENT DIR OR ROOT) 00309 // NEGATIVE RESULT ==> INVALID FILENAME 00310 00311 00312 // CASE INSENSITIVITY MACRO 00313 #define __ICASE(a) ( ((a>96)&&(a<123))? (a&0xdf):a) 00314 #define __UPPER(a) ( ((a>96)&&(a<123))? (a&0xdf):a) 00315 #define __LOWER(a) ( ((a>64)&&(a<91))? (a|0x20):a) 00316 00317 00318 // TYPE DEFINITIONS 00319 00320 struct __frag; 00321 typedef struct __frag FS_FRAGMENT; 00322 struct __buffer; 00323 typedef struct __buffer FS_BUFFER; 00324 struct __file; 00325 typedef struct __file FS_FILE; 00326 00327 00328 struct __frag { 00329 int StartAddr,EndAddr; 00330 FS_FRAGMENT *NextFragment; 00331 }; 00332 00333 struct __buffer { 00334 char *Data; 00335 int Offset,Used; 00336 }; 00337 00338 00339 // MAIN FILE STRUCTURE 00348 struct __file { 00352 char *Name; 00356 unsigned Volume:8, 00360 Mode:8, 00364 Attr:8; 00368 unsigned NTRes:8, 00372 CrtTmTenth:8, 00376 LastAccDate:16; 00380 unsigned int CreatTimeDate; 00384 unsigned int WriteTimeDate; 00388 int FirstCluster; 00392 unsigned int FileSize; 00396 unsigned int CurrentOffset; 00400 int DirEntryOffset, 00404 DirEntryNum; 00408 FS_FILE *Dir; 00412 FS_FRAGMENT Chain; 00416 FS_BUFFER RdBuffer,WrBuffer; 00417 }; 00418 00419 00420 00421 // INITIALIZATION FUNCTIONS 00422 00434 extern int FSShutdown(); 00435 00447 extern int FSRestart(); 00448 00457 extern void FSSleep(); 00458 00466 extern void FSWakeUp(); 00467 00468 // VOLUME FUNCTIONS 00469 00481 extern int FSVolumeMounted(int VolNumber); 00482 00483 00498 extern int FSVolumeInserted(int VolNumber); 00499 00512 extern int FSSetCurrentVolume(int VolNumber); 00513 00524 extern int FSGetCurrentVolume(); 00525 00535 extern int FSGetVolumeSize(int Volnumber); 00545 extern int FSGetVolumeFree(int Volnumber); 00546 00547 // DIRECTORY ACCESS FUNCTIONS 00548 00559 extern int FSMkdir(char *name); 00560 00572 extern int FSRmdir(char *name); 00573 00585 extern int FSChdir(char *name); 00586 00599 extern char *FSGetcwd(int Volume); 00600 00601 00615 extern int FSOpenDir(char *name,FS_FILE **fileptr); 00616 00638 extern int FSGetNextEntry(FS_FILE *entry,FS_FILE *dir); 00639 00640 00652 extern void FSReleaseEntry(FS_FILE *file); 00653 00654 // FILE ACCESS FUNCTIONS 00672 extern int FSCreate(char *name,int attr,FS_FILE **fileptr); 00696 extern int FSOpen(char *name, int mode, FS_FILE **fileptr); 00713 extern int FSClose(FS_FILE *file); 00714 00726 extern int FSCloseAndDelete(FS_FILE *file); 00727 00744 extern int FSSeek(FS_FILE *file,int Offset,int position); 00745 00758 extern int FSTell(FS_FILE *file); 00759 00760 00761 00779 extern int FSRead(char *buffer,int nbytes,FS_FILE *file); 00798 extern int FSWrite(char *buffer,int nbytes,FS_FILE *file); 00811 extern int FSEof(FS_FILE *file); 00823 extern int FSDelete(char *name); 00836 extern int FSRename(char *oldname,char *newname); 00837 00838 00839 // NAME PROCESSING FUNCTIONS 00857 extern int FSNameCompare(char *name1,char *name2,int caseflags); 00858 00876 extern char *FSGetFileName(FS_FILE *file,int pathflags); 00877 00912 extern int FSGetNameType(char *name); 00913 00924 extern void FSStripSemi(char *name); 00925 00937 extern char *FSGetErrorMsg(int errornum); 00938 00950 extern int FSChMode(FS_FILE *file,int newmode); 00951 00967 extern int FSChAttr(FS_FILE *file,int newattr); 00968 00980 extern int FSAttr(FS_FILE *file); 00981 00993 extern int FSFileLength(FS_FILE *file); 00994 01004 extern void FSSetCaseMode(int casemode); 01005 01018 extern void FSGetCreatTime(FS_FILE *file,struct tm *timedate); 01019 01033 extern void FSGetWriteTime(FS_FILE *file,struct tm *timedate); 01034 01035 01051 extern void FSGetAccessDate(FS_FILE *file,struct tm *timedate); 01052 01061 extern int FSGetHandle(FS_FILE *file); 01062 01073 extern int FSGetFileFromHandle(int handle,FS_FILE **fileptr); 01074 01075 01076 #endif