summaryrefslogtreecommitdiff
path: root/src/files.h
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2010-10-01 16:33:37 +0400
committerAndrey Nazarov <skuller@skuller.net>2010-10-01 17:21:52 +0400
commit57ff04fceb133d7c06c67bf991b5941766bb28da (patch)
tree4f7ca34f1a58cd35059c76f72dbdaadcc81684c7 /src/files.h
parentffd86f8fccf7a523e89553fefaa621457460aa38 (diff)
Clean up and fix file listing functions.
- Merge Sys_ListFiles and Sys_ListFilteredFiles into the single Sys_ListFiles_r implementatation (per platform). - Fix an off-by-one bug in Sys_ListFiles (per platform). - Fix an off-by-one bug in FS_ListFiles. - Made Sys_ListFiles ignore hidden and non-regular (irregular?) files on Unix. - Limit maximum recursion depth to 8 (opposed to 32 on Unix and unlimited depth on Win32). - Reduce listed files limit to 2048 from 4096. - Implement FS_SEARCH_STRIPEXT flag instead of ugly hack in FS_File_g. - Kill unused FS_SEARCH_NOSORT flag. - Replace FS_SEARCHDIRS_* cruft with single FS_SEARCH_DIRSONLY flag. - Use unsigned integer type for flags. - Don't list more than 128 files to avoid console spam.
Diffstat (limited to 'src/files.h')
-rw-r--r--src/files.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/files.h b/src/files.h
index 135757e..f3c7ff7 100644
--- a/src/files.h
+++ b/src/files.h
@@ -18,7 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#define MAX_LISTED_FILES 4096
+#define MAX_LISTED_FILES 2048
+#define MAX_LISTED_DEPTH 8
typedef struct file_info_s {
size_t size;
@@ -34,13 +35,6 @@ typedef struct file_info_s {
#define FS_MODE_RDWR 0x00000003
#define FS_MODE_MASK 0x00000003
-/* bits 0 - 1, enum */
-#define FS_SEARCHDIRS_NO 0x00000000
-#define FS_SEARCHDIRS_YES 0x00000001
-#define FS_SEARCHDIRS_ONLY 0x00000002
-#define FS_SEARCHDIRS_RESERVED 0x00000003
-#define FS_SEARCHDIRS_MASK 0x00000003
-
/* bit 2, enum */
#define FS_FLUSH_NONE 0x00000000
#define FS_FLUSH_SYNC 0x00000004
@@ -59,11 +53,12 @@ typedef struct file_info_s {
#define FS_PATH_GAME 0x00000040
#define FS_PATH_MASK 0x00000060
-/* bits 7 - 10, flag */
+/* bits 7 - 11, flag */
#define FS_SEARCH_BYFILTER 0x00000080
#define FS_SEARCH_SAVEPATH 0x00000100
#define FS_SEARCH_EXTRAINFO 0x00000200
-#define FS_SEARCH_NOSORT 0x00000400
+#define FS_SEARCH_STRIPEXT 0x00000400
+#define FS_SEARCH_DIRSONLY 0x00000800
/* bits 7 - 8, flag */
#define FS_FLAG_GZIP 0x00000080
@@ -127,7 +122,7 @@ ssize_t FS_GetFileLength( qhandle_t f );
qboolean FS_WildCmp( const char *filter, const char *string );
qboolean FS_ExtCmp( const char *extension, const char *string );
-void **FS_ListFiles( const char *path, const char *extension, int flags, int *numFiles );
+void **FS_ListFiles( const char *path, const char *filter, unsigned flags, int *count_p );
void **FS_CopyList( void **list, int count );
file_info_t *FS_CopyInfo( const char *name, size_t size, time_t ctime, time_t mtime );
void FS_FreeList( void **list );
@@ -137,7 +132,7 @@ char *FS_ReplaceSeparators( char *s, int separator );
int FS_pathcmp( const char *s1, const char *s2 );
int FS_pathcmpn( const char *s1, const char *s2, size_t n );
-void FS_File_g( const char *path, const char *ext, int flags, genctx_t *ctx );
+void FS_File_g( const char *path, const char *ext, unsigned flags, genctx_t *ctx );
extern cvar_t *fs_game;