mirror of
https://github.com/tstellar/bygfoot.git
synced 2025-02-20 21:40:45 +01:00
switching to a zip library instead of an executed command - there are still issues
This commit is contained in:
parent
a00650e7fe
commit
72910b1f55
33
src/file.c
33
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;i<files->len;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. */
|
||||
|
@ -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);
|
||||
|
@ -23,6 +23,7 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
@ -8,4 +8,3 @@ libminizip_la_SOURCES = \
|
||||
unzip.c \
|
||||
unzip.h
|
||||
|
||||
CLEANFILES = *~
|
||||
|
Loading…
x
Reference in New Issue
Block a user