View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003036 | FSSCP | Platform-Engine interaction | public | 2014-04-30 04:30 | 2015-01-22 19:29 |
Reporter | niffiwan | Assigned To | chief1983 | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
OS | Linux | ||||
Product Version | 3.7.1 | ||||
Target Version | 3.7.2 | Fixed in Version | 3.7.2 RC5 | ||
Summary | 0003036: cf_exists does not search all dirs correctly on Linux (and probably OSX) | ||||
Description | Pretty much as it says. On Linux/OSX, some "directories" have two locations. i.e. mod/data/config ~/.fs2_open/mod/data/config cf_exists will only find files in the 2nd location, even though valid files may be in the 1st location. It should probably search both locations, with the 2nd one having precedence. Definitely affects CF_TYPE_CONFIG, may affect other types as well. =========================== Note: cf_exists_full correctly (?? maybe, haven't checked precedence) finds files in both locations. | ||||
Steps To Reproduce | See attached mod. Press enter in the mainhall (or anywhere) to run a script that attempts to open test files in nearly all known locations. Failure to open the file generates a warning. Switch the cf.fileExists() 3rd param to true and all files will be found. Add the relevant files to the relevant directories in ~/.fs_open/ and the files will be found. | ||||
Additional Information | Found when using LUA cf.fileExists() with the 3rd param set to false. Note that setting the 3rd param to true is a workaround. | ||||
Tags | No tags attached. | ||||
|
|
|
3036_proposed.diff (1,105 bytes)
Index: code/cfile/cfile.cpp =================================================================== --- code/cfile/cfile.cpp (revision 11218) +++ code/cfile/cfile.cpp (working copy) @@ -492,23 +492,17 @@ // Returns 1 if the file exists, 0 if not. // Checks only the file system. +// cf_find_file_location checks the filesystem before VPs +// If offset is 0, it was found in the filesystem, so offset is boolean false +// If offset equates to boolean true, it was found in a VP and the logic will negate the function return int cf_exists(const char *filename, int dir_type) { - char longname[MAX_PATH_LEN]; + int offset = 1; - Assert(CF_TYPE_SPECIFIED(dir_type)); + if ( (filename == NULL) || !strlen(filename) ) + return 0; - cf_create_default_path_string(longname, sizeof(longname) - 1, dir_type, filename); - - FILE *fp = fopen(longname, "rb"); - if (fp) - { - // Goober5000 - these were switched, causing the fclose to be unreachable - fclose(fp); - return 1; - } - - return 0; + return (cf_find_file_location(filename, dir_type, 0, NULL, &offset, NULL) && !offset); } // Goober5000 |
|
I've attached a patch which should fix this issue, by causing this function to use the same lower level function as the other cf_exists* family of functions. This should simplify the code as a result, if there are no adverse effects from this behavior change. Since the behavioral difference appears to have been platform-specific, I don't anticipate issues. |
|
Update the steps to reproduce with what I believe is a typo fix since cf_exists doesn't have 3 arguments but the referenced Lua counterpart does. |
|
Patch doesn't seem to cause any issues for me on Windows with the MediaVPs and my recent trunk build, will test OS X tomorrow. Would like to hear results of general purpose gameplay testing and the mod test from a Linux user before I commit. |
|
Works fine on Linux both playing a mission with mediavps_2014 & running the attached test mod. |
|
Fix committed to trunk@11222. |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-04-30 04:30 | niffiwan | New Issue | |
2014-04-30 06:00 | niffiwan | Description Updated | |
2014-04-30 06:00 | niffiwan | Additional Information Updated | |
2014-05-09 03:46 | niffiwan | File Added: mantis3036_mod.7z | |
2014-05-09 03:49 | niffiwan | Steps to Reproduce Updated | |
2015-01-19 03:33 | chief1983 | Assigned To | => chief1983 |
2015-01-19 03:33 | chief1983 | Status | new => assigned |
2015-01-19 03:34 | chief1983 | File Added: 3036_proposed.diff | |
2015-01-19 03:35 | chief1983 | Note Added: 0016455 | |
2015-01-19 03:36 | chief1983 | Status | assigned => code review |
2015-01-19 03:40 | chief1983 | Note Added: 0016456 | |
2015-01-19 03:40 | chief1983 | Steps to Reproduce Updated | |
2015-01-19 03:41 | chief1983 | Note Added: 0016457 | |
2015-01-20 09:22 | niffiwan | Note Added: 0016458 | |
2015-01-22 19:21 | chief1983 | Changeset attached | => fs2open trunk r11222 |
2015-01-22 19:21 | chief1983 | Note Added: 0016459 | |
2015-01-22 19:21 | chief1983 | Status | code review => resolved |
2015-01-22 19:21 | chief1983 | Resolution | open => fixed |
2015-01-22 19:29 | chief1983 | Fixed in Version | => 3.7.2 RC5 |
2015-01-22 19:29 | chief1983 | Target Version | => 3.7.2 |