fsystem.h

Go to the documentation of this file.
00001 //@<head>
00002 //& <prolog>
00003 //& ****************************************************************************
00004 //&
00005 //& Written by Claudio Lapilli, February 2006
00006 //&
00007 //& Copyright (C) 2006 HP-GCC Development Team
00008 //&
00009 //& ****************************************************************************
00010 //&
00011 //&
00012 //& This file is part of HP-GCC.
00013 //&
00014 //& HP-GCC is free software; you can redistribute it and/or modify
00015 //& it under the terms of the GNU General Public License as published by
00016 //& the Free Software Foundation; either version 2, or (at your option)
00017 //& any later version.
00018 //& 
00019 //& HP-GCC is distributed in the hope that it will be useful,
00020 //& but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 //& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022 //& GNU General Public License for more details.
00023 //& 
00024 //& You should have received a copy of the GNU General Public License
00025 //& along with HP-GCC; see the file COPYING. 
00026 //&
00027 //& As a special exception, you may use this file as part of a free software
00028 //& library without restriction.  Specifically, if other files instantiate
00029 //& templates or use macros or inline functions from this file, or you compile
00030 //& this file and link it with other files to produce an executable, this
00031 //& file does not by itself cause the resulting executable to be covered by
00032 //& the GNU General Public License.  This exception does not however
00033 //& invalidate any other reasons why the executable file might be covered by
00034 //& the GNU General Public License.
00035 //&
00036 //& ****************************************************************************
00037 
00038 //& </prolog>
00039 
00040 // $Header: fsystem.h,r42 2006-02-18 04:23:47 ingo $
00041 
00042 // FILE SYSTEM PUBLIC HEADER FILE
00050 // CONSTANTS
00051 
00052 // FILE ATTRIBUTES
00056 #define FSATTR_RDONLY 1
00057 
00060 #define FSATTR_HIDDEN 2
00061 
00064 #define FSATTR_SYSTEM 4
00065 
00068 #define FSATTR_VOLUME 8
00069 
00072 #define FSATTR_DIR    16
00073 
00076 #define FSATTR_ARCHIVE 32
00077 
00080 #define FSATTR_LONGNAME 0xf
00081 
00084 #define FSATTR_LONGMASK 0x3f
00085 
00086 
00087 // OPEN MODES
00093 #define FSMODE_READ      0    // READ PERMISSION (DEFAULT)
00094 
00099 #define FSMODE_WRITE     2    // WRITE PERMISSION
00100 
00105 #define FSMODE_APPEND    4    // ONLY ALLOW WRITING AFTER EOF
00106 
00112 #define FSMODE_MODIFY    8    // WRITE TO ANY POSITION WITHIN FILE
00113 
00119 #define FSMODE_NOGROW   16    // DON'T ALLOW FILE TO GROW
00120 
00126 #define FSMODE_NOCREATE 32    // DON'T CREATE IF FILE DOESN'T EXIST
00127 
00128 
00129 
00130 // ERRORS RETURNED BY USER-LEVEL FUNCTIONS
00134 #define FS_OK             1
00135 
00138 #define FS_ERROR      0             // UNKNOWN ERROR (OR FUNCTION DOESN'T CARE)
00139 
00142 #define FS_EOF       -1                 // END OF FILE
00143 
00146 #define FS_BADNAME   -2                 // INVALID FILE NAME
00147 
00150 #define FS_BADVOLUME -3                 // INVALID DRIVE
00151 
00154 #define FS_NOTFOUND  -4                 // FILE NOT FOUND
00155 
00158 #define FS_CANTWRITE -5                 // WRITE FAILED
00159 
00162 #define FS_NOCARD    -6                 // NO CARD INSERTED
00163 
00166 #define FS_CHANGED   -7                 // CARD HAS CHANGED
00167 
00170 #define FS_MAXFILES  -8                 // MAXIMUM NUMBER OF FILES OPEN WAS EXCEEDED
00171 
00174 #define FS_OPENDIR   -9                 // NAME IS AN ALREADY OPEN DIRECTORY
00175 
00178 #define FS_OPENFILE  -9                 // NAME IS AN ALREADY OPEN FILE
00179 
00182 #define FS_USED      -9                 // FILE/DIRECTORY IS BEING USED
00183 
00186 #define FS_DISKFULL  -10                // DISK IS FULL
00187 
00190 #define FS_EXIST     -11                // FILE ALREADY EXISTS
00191 
00192 
00193 // CASE SENSITIVITY MODES
00207 #define FSCASE_SENS   0                 // CASE SENSITIVE (RAW NAMES)
00208 
00239 #define FSCASE_SENSHP 1                 // CASE SENSITIVE (W/SEMICOLON STRIPPING)
00240 
00248 #define FSCASE_INSENS 2                 // CASE INSENSITIVE
00249 
00260 #define FSCASE_SENSHPTRUE 3             // CASE SENSITIVE W/SEMICOLONS BUT RETURNS TRUE NAMES
00261 
00262 // FILENAME ANALYSIS RESULT FLAGS (FSGetNameType())
00268 #define FSNAME_HASVOL    1              // 1 == Name include drive
00269 
00275 #define FSNAME_HASPATH   2              // 2 == Name include path
00276 
00282 #define FSNAME_ABSPATH   4              // 4 == Path is absolute
00283 
00289 #define FSNAME_ENDSLASH  8              // 8 == name ends in slash
00290 
00296 #define FSNAME_VOLHP    16              // 16== Drive is HP style (:x:)
00297 
00303 #define FSNAME_EMPTY    32              // 32== Name is empty
00304 
00310 #define FSNAME_INVALID  -1
00311 
00312 // BITS 16-31 = DEPTH OF PATH (0=CURRENT DIR OR ROOT)
00313 // NEGATIVE RESULT ==> INVALID FILENAME 
00314 
00315 
00316 // CASE INSENSITIVITY MACRO
00317 #define __ICASE(a) ( ((a>96)&&(a<123))? (a&0xdf):a)
00318 #define __UPPER(a) ( ((a>96)&&(a<123))? (a&0xdf):a)
00319 #define __LOWER(a) ( ((a>64)&&(a<91))? (a|0x20):a)
00320 
00321 
00322 // TYPE DEFINITIONS
00323 
00324 struct __frag;
00325 typedef struct __frag FS_FRAGMENT;
00326 struct __buffer;
00327 typedef struct __buffer FS_BUFFER;
00328 struct __file;
00329 typedef struct __file FS_FILE;
00330 
00331 
00332 struct __frag {
00333 int StartAddr,EndAddr;
00334 FS_FRAGMENT *NextFragment;
00335 };
00336 
00337 struct __buffer {
00338 char *Data;
00339 int Offset,Used;
00340 };
00341 
00342 
00343 // MAIN FILE STRUCTURE
00352 struct __file {
00356 char *Name;
00360 unsigned Volume:8,
00364           Mode:8,
00368           Attr:8;
00372 unsigned NTRes:8,
00376           CrtTmTenth:8,
00380                   LastAccDate:16;
00384 unsigned int CreatTimeDate;
00388 unsigned int WriteTimeDate;
00392 int FirstCluster;
00396 unsigned int FileSize;
00400 unsigned int CurrentOffset;
00404 int DirEntryOffset,
00408     DirEntryNum;
00412 FS_FILE *Dir;
00416 FS_FRAGMENT Chain;
00420 FS_BUFFER RdBuffer,WrBuffer;
00421 };
00422 
00423 
00424 
00425 // INITIALIZATION FUNCTIONS
00426 
00438 extern int FSShutdown();
00439 
00451 extern int FSRestart();
00452 
00461 extern void FSSleep();
00462 
00470 extern void FSWakeUp();
00471 
00472 // VOLUME FUNCTIONS
00473 
00485 extern int FSVolumeMounted(int VolNumber);
00486 
00487 
00502 extern int FSVolumeInserted(int VolNumber);
00503 
00516 extern int FSSetCurrentVolume(int VolNumber);
00517 
00528 extern int FSGetCurrentVolume();
00529 
00539 extern int FSGetVolumeSize(int Volnumber);
00549 extern int FSGetVolumeFree(int Volnumber);
00550 
00551 // DIRECTORY ACCESS FUNCTIONS
00552 
00563 extern int FSMkdir(char *name);
00564 
00576 extern int FSRmdir(char *name);
00577 
00589 extern int FSChdir(char *name);
00590 
00603 extern char *FSGetcwd(int Volume);
00604 
00605 
00619 extern int FSOpenDir(char *name,FS_FILE **fileptr);
00620 
00642 extern int FSGetNextEntry(FS_FILE *entry,FS_FILE *dir);
00643 
00644 
00656 extern void FSReleaseEntry(FS_FILE *file);
00657 
00658 // FILE ACCESS FUNCTIONS
00676 extern int FSCreate(char *name,int attr,FS_FILE **fileptr);
00700 extern int FSOpen(char *name, int mode, FS_FILE **fileptr);
00717 extern int FSClose(FS_FILE *file);
00718 
00730 extern int FSCloseAndDelete(FS_FILE *file);
00731 
00748 extern int FSSeek(FS_FILE *file,int Offset,int position);
00749 
00762 extern int FSTell(FS_FILE *file);
00763 
00764 
00765 
00783 extern int FSRead(char *buffer,int nbytes,FS_FILE *file);
00802 extern int FSWrite(char *buffer,int nbytes,FS_FILE *file);
00815 extern int FSEof(FS_FILE *file);
00827 extern int FSDelete(char *name);
00840 extern int FSRename(char *oldname,char *newname);
00841 
00842 
00843 // NAME PROCESSING FUNCTIONS
00861 extern int FSNameCompare(char *name1,char *name2,int caseflags);
00862 
00880 extern char *FSGetFileName(FS_FILE *file,int pathflags);
00881 
00916 extern int FSGetNameType(char *name);
00917 
00928 extern void FSStripSemi(char *name);
00929 
00941 extern char *FSGetErrorMsg(int errornum);
00942 
00954 extern int FSChMode(FS_FILE *file,int newmode);
00955 
00971 extern int FSChAttr(FS_FILE *file,int newattr);
00972 
00984 extern int FSAttr(FS_FILE *file);
00985 
00997 extern int FSFileLength(FS_FILE *file);
00998 
01008 extern void FSSetCaseMode(int casemode);
01009 
01022 extern void FSGetCreatTime(FS_FILE *file,struct tm *timedate);
01023 
01037 extern void FSGetWriteTime(FS_FILE *file,struct tm *timedate);
01038 
01039 
01055 extern void FSGetAccessDate(FS_FILE *file,struct tm *timedate);
01056 

Generated on Fri Feb 16 16:43:17 2007 for FILESYSTEM by  doxygen 1.5.0