diff --git a/src/file.c b/src/file.c index 26156546..74febbfd 100644 --- a/src/file.c +++ b/src/file.c @@ -822,11 +822,9 @@ file_compress_files(const gchar *destfile, const gchar *prefix) zipClose(zf, NULL); + file_remove_files(files); chdir(pwd); - g_string_sprintf(buf, "%s%s%s*", dirname, G_DIR_SEPARATOR_S, basename); - file_remove_files(buf); - g_string_free(buf, TRUE); free_gchar_array(&files); @@ -877,7 +875,12 @@ file_decompress(const gchar *filename) } } + GPtrArray *files_to_remove = file_dir_get_contents(dirname, basename, ""); + file_remove_files(files_to_remove); + chdir(pwd); + g_string_free(buf, TRUE); + free_gchar_array(&files_to_remove); g_free(dirname); g_free(basename); @@ -886,25 +889,23 @@ file_decompress(const gchar *filename) g_free(pwd); } -/** Execute the appropriate remove command with 'files' +/** Remove the files defined in the 'files' array as argument (can be directories or a regexp, too). */ void -file_remove_files(const GString *files) +file_remove_files(const GPtrArray *files) { #ifdef DEBUG printf("file_remove_files\n"); #endif - - GString *buf = g_string_new(""); - - if(os_is_unix) - g_string_sprintf(buf, "%s %s", const_str("string_fs_remove_file_command"), files->str); - else - g_string_sprintf(buf, "%s \"%s\"", const_str("string_fs_remove_file_command"), files->str); - - file_my_system(buf); - - g_string_free(buf, TRUE); + gint i; + for(i=0;ilen;i++) + { + printf("Removing File %s\n", (gchar*)g_ptr_array_index(files, i)); + int rc = g_remove((gchar*)g_ptr_array_index(files, i)); + if (rc==-1) { + printf("Problem Removing File %s\n", (gchar*)g_ptr_array_index(files, i)); + } + } } /** Execute the appropriate copy command. */ diff --git a/src/file.h b/src/file.h index de19f85b..cbbc28aa 100644 --- a/src/file.h +++ b/src/file.h @@ -100,7 +100,7 @@ void file_decompress(const gchar *filename); void -file_remove_files(const GString *files); +file_remove_files(const GPtrArray *files); void file_copy_file(const gchar *source_file, const gchar *dest_file); diff --git a/src/load_save.c b/src/load_save.c index 2eaee920..f1ab9ea2 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include +#include #include "callbacks.h" #include "file.h" @@ -70,8 +71,7 @@ load_save_save_game(const gchar *filename) misc_string_assign(&save_file, fullname->str); if(g_file_test(fullname->str, G_FILE_TEST_EXISTS)) - /*todo: replace with g_remove*/ - file_remove_files(fullname); + g_remove(fullname->str); if(debug > 60) g_print("load_save_save options\n"); @@ -320,7 +320,7 @@ load_save_load_game(const gchar* filename, gboolean create_main_window) PIC_TYPE_LOAD); g_string_sprintf(buf, "%s%s%s___*", dirname, G_DIR_SEPARATOR_S, prefix); - file_remove_files(buf); + g_remove(buf->str); misc_string_assign(&save_file, fullname); diff --git a/src/zip/Makefile.am b/src/zip/Makefile.am index 25b03218..324cda64 100644 --- a/src/zip/Makefile.am +++ b/src/zip/Makefile.am @@ -8,4 +8,3 @@ libminizip_la_SOURCES = \ unzip.c \ unzip.h -CLEANFILES = *~