filesystem.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. Copyright (C) 2004-2005 Michael Liebscher <johnnycanuck@users.sourceforge.net>
  3. Copyright (C) 1997-2001 Id Software, Inc.
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. /*
  17. * filesystem.h: Interface to filesystem layer.
  18. *
  19. * Author: Michael Liebscher <johnnycanuck@users.sourceforge.net>
  20. *
  21. * Acknowledgement:
  22. * This code was derived from Quake II, and was originally
  23. * written by Id Software, Inc.
  24. *
  25. */
  26. /*
  27. Notes:
  28. This module is implemented by files.c.
  29. */
  30. #ifndef __FILESYSTEM_H__
  31. #define __FILESYSTEM_H__
  32. #define MAX_GAMEPATH 256 // max length of a game pathname
  33. #define MAX_OSPATH 256 // max length of a filesystem pathname
  34. extern void FS_InitFilesystem(void);
  35. extern char *FS_Gamedir(void);
  36. /////////////////////////////////////////////////////////////////////
  37. //
  38. // PORTABLE FILE SYSTEM SERVICES
  39. //
  40. /////////////////////////////////////////////////////////////////////
  41. typedef struct
  42. {
  43. FILE *hFile;
  44. /* Following is used when the file is loaded into memory */
  45. _boolean bLoaded; /* Was file loaded into memory? */
  46. W32 filesize; /* Size of file data in bytes */
  47. W8 *ptrStart; /* pointer to start of file data block */
  48. W8 *ptrCurrent; /* pointer to current position in file data block */
  49. W8 *ptrEnd; /* pointer to end of file data block */
  50. void *filedata; /* file data loaded into memory */
  51. } filehandle_t;
  52. /* Desired Access Flags */
  53. #define DA_GENERIC_READ 0x01
  54. #define DA_GENERIC_WRITE 0x02
  55. /* Flags and Attributes */
  56. #define FA_FILE_FLAG_LOAD 0x01
  57. #define FA_FILE_FLAG_CACHE 0x02
  58. #define FA_FILE_IPHONE_DOC_DIR 0x04
  59. extern filehandle_t *FS_OpenFile( const char *filename, W32 FlagsAndAttributes );
  60. extern void FS_CloseFile( filehandle_t *fhandle );
  61. // note: this can't be called from another DLL, due to MS libc issues
  62. extern SW32 FS_ReadFile( void *buffer, W32 size, W32 count, filehandle_t *fhandle );
  63. extern SW32 FS_FileTell( filehandle_t *fhandle );
  64. extern W32 FS_FileSeek( filehandle_t *fhandle, SW32 offset, W32 origin );
  65. extern SW32 FS_GetFileSize( filehandle_t *fhandle );
  66. extern void *FS_GetLoadedFilePointer( filehandle_t *fhandle, W32 origin );
  67. extern void FS_CreatePath( char *path );
  68. extern void FS_FilePath( char *in, char *out );
  69. extern char *FS_SkipPath( char *pathname );
  70. /////////////////////////////////////////////////////////////////////
  71. //
  72. // NON-PORTABLE FILE SYSTEM SERVICES
  73. //
  74. /////////////////////////////////////////////////////////////////////
  75. extern W8 FS_CreateDirectory( const char *dirname );
  76. extern W8 FS_ChangeCurrentDirectory( const char *path );
  77. extern _boolean FS_DeleteFile( const char *filename );
  78. extern _boolean FS_RemoveDirectory( const char *pathname );
  79. // directory/file attributes
  80. #define FA_ARCH 0x01
  81. #define FA_HIDDEN 0x02
  82. #define FA_RDONLY 0x04
  83. #define FA_DIR 0x08
  84. #define FA_SYSTEM 0x10
  85. // pass in an attribute mask of things you wish to REJECT
  86. extern char *FS_FindFirst( const char *path, W32 musthave, W32 canthave );
  87. extern char *FS_FindNext( W32 musthave, W32 canthave );
  88. extern void FS_FindClose( void );
  89. #endif /* __FILESYSTEM_H__ */