=========== FS_SV_FOpenFileRead search for a file somewhere below the home path, base path or cd path we search in that order, matching FS_SV_FOpenFileRead order =========== */
| 816 | =========== |
| 817 | */ |
| 818 | int FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ) { |
| 819 | char *ospath; |
| 820 | fileHandle_t f = 0; |
| 821 | |
| 822 | FS_AssertInitialised(); |
| 823 | |
| 824 | f = FS_HandleForFile(); |
| 825 | fsh[f].zipFile = qfalse; |
| 826 | |
| 827 | Q_strncpyz( fsh[f].name, filename, sizeof( fsh[f].name ) ); |
| 828 | |
| 829 | // don't let sound stutter |
| 830 | S_ClearSoundBuffer(); |
| 831 | |
| 832 | // search homepath |
| 833 | ospath = FS_BuildOSPath( fs_homepath->string, filename, "" ); |
| 834 | // remove trailing slash |
| 835 | ospath[strlen(ospath)-1] = '\0'; |
| 836 | |
| 837 | if ( fs_debug->integer ) { |
| 838 | Com_Printf( "FS_SV_FOpenFileRead (fs_homepath): %s\n", ospath ); |
| 839 | } |
| 840 | |
| 841 | fsh[f].handleFiles.file.o = fopen( ospath, "rb" ); |
| 842 | fsh[f].handleSync = qfalse; |
| 843 | if (!fsh[f].handleFiles.file.o) |
| 844 | { |
| 845 | // NOTE TTimo on non *nix systems, fs_homepath == fs_basepath, might want to avoid |
| 846 | if (Q_stricmp(fs_homepath->string,fs_basepath->string)) |
| 847 | { |
| 848 | // search basepath |
| 849 | ospath = FS_BuildOSPath( fs_basepath->string, filename, "" ); |
| 850 | ospath[strlen(ospath)-1] = '\0'; |
| 851 | |
| 852 | if ( fs_debug->integer ) |
| 853 | { |
| 854 | Com_Printf( "FS_SV_FOpenFileRead (fs_basepath): %s\n", ospath ); |
| 855 | } |
| 856 | |
| 857 | fsh[f].handleFiles.file.o = fopen( ospath, "rb" ); |
| 858 | fsh[f].handleSync = qfalse; |
| 859 | } |
| 860 | |
| 861 | if ( !fsh[f].handleFiles.file.o ) |
| 862 | { |
| 863 | f = 0; |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | if (!fsh[f].handleFiles.file.o) |
| 868 | { |
| 869 | // search cd path |
| 870 | ospath = FS_BuildOSPath( fs_cdpath->string, filename, "" ); |
| 871 | ospath[strlen(ospath)-1] = '\0'; |
| 872 | |
| 873 | if (fs_debug->integer) |
| 874 | { |
| 875 | Com_Printf( "FS_SV_FOpenFileRead (fs_cdpath) : %s\n", ospath ); |
no test coverage detected