mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-10 12:41:35 -10:00
Fix for mantis 2814: don't check filename lengths when deleting .csg files Also change win32 to check for last . in filenames, not the 1st
git-svn-id: svn://svn.icculus.org/fs2open/trunk@9613 387891d4-d844-0410-90c0-e4c51a9137d3
This commit is contained in:
1 parent
f627a66488
commit
9ebbd7efce
2 files changed
+6
-12
No files matched your search
@@ -1447,12 +1447,9 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, char *filter,
|
||||
find_handle = _findfirst( filespec, &find );
|
||||
if (find_handle != -1) {
|
||||
do {
|
||||
if (strcmp(strstr(filter, "."), strstr(find.name,".")) != 0)
|
||||
if (strcmp(strrchr(filter, '.'), strrchr(find.name,'.')) != 0)
|
||||
continue;
|
||||
|
||||
if ( strlen(find.name) >= MAX_FILENAME_LEN )
|
||||
continue;
|
||||
|
||||
if (!(find.attrib & _A_SUBDIR)) {
|
||||
if ( !Get_file_list_filter || (*Get_file_list_filter)(find.name) ) {
|
||||
if ( check_duplicates && cf_file_already_in_list(list, find.name) ) {
|
||||
@@ -1488,9 +1485,6 @@ int cf_get_file_list( SCP_vector<SCP_string> &list, int pathtype, char *filter,
|
||||
dirp = opendir (filespec);
|
||||
if ( dirp ) {
|
||||
while ((dir = readdir (dirp)) != NULL) {
|
||||
if ( strlen(dir->d_name) >= MAX_FILENAME_LEN ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fnmatch(filter, dir->d_name, 0) != 0)
|
||||
continue;
|
||||
@@ -1650,7 +1644,7 @@ int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort
|
||||
if (num_files >= max)
|
||||
break;
|
||||
|
||||
if (strcmp(strstr(filter, "."), strstr(find.name,".")) != 0)
|
||||
if (strcmp(strrchr(filter, '.'), strrchr(find.name,'.')) != 0)
|
||||
continue;
|
||||
|
||||
if ( strlen(find.name) >= MAX_FILENAME_LEN )
|
||||
|
||||
@@ -814,9 +814,10 @@ void campaign_delete_save( char *cfn, char *pname)
|
||||
void mission_campaign_delete_all_savefiles( char *pilot_name )
|
||||
{
|
||||
int dir_type, num_files, i;
|
||||
char *names[MAX_CAMPAIGNS], file_spec[MAX_FILENAME_LEN + 2], *ext;
|
||||
char file_spec[MAX_FILENAME_LEN + 2], *ext;
|
||||
char filename[1024];
|
||||
int (*filter_save)(char *filename);
|
||||
SCP_vector<SCP_string> names;
|
||||
|
||||
ext = NOX(".csg");
|
||||
dir_type = CF_TYPE_PLAYERS;
|
||||
@@ -827,14 +828,13 @@ void mission_campaign_delete_all_savefiles( char *pilot_name )
|
||||
// be. I have to save any file filters
|
||||
filter_save = Get_file_list_filter;
|
||||
Get_file_list_filter = NULL;
|
||||
num_files = cf_get_file_list(MAX_CAMPAIGNS, names, dir_type, file_spec);
|
||||
num_files = cf_get_file_list(names, dir_type, const_cast<char *>(file_spec));
|
||||
Get_file_list_filter = filter_save;
|
||||
|
||||
for (i=0; i<num_files; i++) {
|
||||
strcpy_s(filename, names[i]);
|
||||
strcpy_s(filename, names[i].c_str());
|
||||
strcat_s(filename, ext);
|
||||
cf_delete(filename, dir_type);
|
||||
vm_free(names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user