summaryrefslogtreecommitdiff
path: root/src/files.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2010-10-01 17:52:54 +0400
committerAndrey Nazarov <skuller@skuller.net>2010-10-01 17:52:54 +0400
commitf56136418650c1f26dc5f3161f7af29bcd8d6123 (patch)
tree68cb8732b94102ca1274c2083be0f8b6522e55c6 /src/files.c
parente3a2946e3793906c3f3018969872e392b07ba10f (diff)
Renamed Com_HashPath into FS_HashPath.
Diffstat (limited to 'src/files.c')
-rw-r--r--src/files.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/files.c b/src/files.c
index 097874a..37f494a 100644
--- a/src/files.c
+++ b/src/files.c
@@ -260,11 +260,6 @@ int FS_pathcmpn( const char *s1, const char *s2, size_t n ) {
}
#ifdef _WIN32
-/*
-================
-FS_ReplaceSeparators
-================
-*/
char *FS_ReplaceSeparators( char *s, int separator ) {
char *p;
@@ -280,6 +275,21 @@ char *FS_ReplaceSeparators( char *s, int separator ) {
}
#endif
+unsigned FS_HashPath( const char *s, unsigned size ) {
+ unsigned hash, c;
+
+ hash = 0;
+ while( *s ) {
+ c = *s++;
+ c = c == '\\' ? '/' : Q_tolower( c );
+ hash = 127 * hash + c;
+ }
+
+ hash = ( hash >> 20 ) ^ ( hash >> 10 ) ^ hash;
+ return hash & ( size - 1 );
+}
+
+
// =============================================================================
static file_t *alloc_handle( qhandle_t *f ) {
@@ -992,7 +1002,7 @@ static ssize_t open_file_read( file_t *file, const char *name, qboolean unique )
//
// search through the path, one element at a time
//
- hash = Com_HashPath( name, 0 );
+ hash = FS_HashPath( name, 0 );
for( search = fs_searchpaths; search; search = search->next ) {
if( file->mode & FS_PATH_MASK ) {
@@ -1588,7 +1598,7 @@ static pack_t *pack_alloc( FILE *fp, filetype_t type, const char *name,
}
static void pack_hash_file( pack_t *pack, packfile_t *file ) {
- unsigned hash = Com_HashPath( file->name, pack->hash_size );
+ unsigned hash = FS_HashPath( file->name, pack->hash_size );
file->hash_next = pack->file_hash[hash];
pack->file_hash[hash] = file;
@@ -2552,7 +2562,7 @@ static void FS_WhereIs_f( void ) {
Com_Printf( "%s is linked to %s\n", filename, path );
}
- hash = Com_HashPath( path, 0 );
+ hash = FS_HashPath( path, 0 );
total = 0;
valid = -1;