file.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Copyright (C) 2004 Michael Liebscher
  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. * file.h: Access methods to file system services.
  18. *
  19. * Author: Michael Liebscher <johnnycanuck@users.sourceforge.net>
  20. * Date: 2004
  21. *
  22. * Acknowledgement:
  23. * This code was derived from Quake II, and was originally
  24. * written by Id Software, Inc.
  25. *
  26. */
  27. /*
  28. Notes:
  29. This module is implemented by file.c
  30. Non-portable methods are implemented in:
  31. win32/win_file.c for Windows
  32. unix/unix_file.c for unix
  33. */
  34. #ifndef __FILE_H__
  35. #define __FILE_H__
  36. #include <stdio.h>
  37. #include <time.h>
  38. #include "../../../common/arch.h"
  39. // filename/path manipulation
  40. extern char *FS_SkipPath( char *pathname );
  41. extern void FS_StripExtension( char *in, char *out );
  42. extern char *FS_FileExtension( char *in );
  43. extern void FS_FileBase( char *in, char *out );
  44. extern void FS_FilePath( char *in, char *out );
  45. extern W32 UnixTimeToDosTime( time_t *t );
  46. /////////////////////////////////////////////////////////////////////
  47. //
  48. // PORTABLE FILE SYSTEM SERVICES
  49. //
  50. /////////////////////////////////////////////////////////////////////
  51. extern SW32 FS_FileLength( FILE *filestream );
  52. extern void FS_Read( void *buffer, int len, FILE *f );
  53. extern SW32 FS_FOpenFile( const char *filename, FILE **file );
  54. extern SW32 FS_LoadFile( const char *path, void **buffer );
  55. extern void FS_FreeFile( void *buffer );
  56. /////////////////////////////////////////////////////////////////////
  57. //
  58. // NON-PORTABLE FILE SYSTEM SERVICES
  59. //
  60. /////////////////////////////////////////////////////////////////////
  61. extern W8 FS_Mkdir( const char *dirname );
  62. extern W8 FS_ChangeCurrentDirectory( const char *path );
  63. extern _boolean FS_DeleteFile( const char *filename );
  64. extern _boolean FS_RemoveDirectory( const char *pathname );
  65. // directory/file attributes
  66. #define FA_ARCH 0x01
  67. #define FA_HIDDEN 0x02
  68. #define FA_RDONLY 0x04
  69. #define FA_DIR 0x08
  70. #define FA_SYSTEM 0x10
  71. // pass in an attribute mask of things you wish to REJECT
  72. extern char *FS_FindFirst( const char *path, W32 musthave, W32 canthave );
  73. extern char *FS_FindNext( W32 musthave, W32 canthave );
  74. extern void FS_FindClose( void );
  75. struct filestats
  76. {
  77. W32 attributes; /* The following attributes are defined as FA_ARCH to FA_SYSTEM*/
  78. W32 creationtime; /* Time when file data last modified */
  79. W32 lastaccesstime; /* Time when file data last accessed */
  80. W32 lastwritetime; /* Time when file data last modified */
  81. };
  82. extern _boolean FS_GetFileAttributes( const char *filename, struct filestats *fs );
  83. #endif /* __FILE_H__ */