mirror of https://github.com/tstellar/bygfoot.git
switching to a zip library instead of an executed command - there are still issues
This commit is contained in:
parent
3c0cadf40a
commit
fb4746f2ad
33
src/file.c
33
src/file.c
|
@ -822,11 +822,9 @@ file_compress_files(const gchar *destfile, const gchar *prefix)
|
||||||
|
|
||||||
zipClose(zf, NULL);
|
zipClose(zf, NULL);
|
||||||
|
|
||||||
|
file_remove_files(files);
|
||||||
chdir(pwd);
|
chdir(pwd);
|
||||||
|
|
||||||
g_string_sprintf(buf, "%s%s%s*", dirname, G_DIR_SEPARATOR_S, basename);
|
|
||||||
file_remove_files(buf);
|
|
||||||
|
|
||||||
g_string_free(buf, TRUE);
|
g_string_free(buf, TRUE);
|
||||||
free_gchar_array(&files);
|
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);
|
g_string_free(buf, TRUE);
|
||||||
|
free_gchar_array(&files_to_remove);
|
||||||
|
|
||||||
g_free(dirname);
|
g_free(dirname);
|
||||||
g_free(basename);
|
g_free(basename);
|
||||||
|
@ -886,25 +889,23 @@ file_decompress(const gchar *filename)
|
||||||
g_free(pwd);
|
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). */
|
as argument (can be directories or a regexp, too). */
|
||||||
void
|
void
|
||||||
file_remove_files(const GString *files)
|
file_remove_files(const GPtrArray *files)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("file_remove_files\n");
|
printf("file_remove_files\n");
|
||||||
#endif
|
#endif
|
||||||
|
gint i;
|
||||||
GString *buf = g_string_new("");
|
for(i=0;i<files->len;i++)
|
||||||
|
{
|
||||||
if(os_is_unix)
|
printf("Removing File %s\n", (gchar*)g_ptr_array_index(files, i));
|
||||||
g_string_sprintf(buf, "%s %s", const_str("string_fs_remove_file_command"), files->str);
|
int rc = g_remove((gchar*)g_ptr_array_index(files, i));
|
||||||
else
|
if (rc==-1) {
|
||||||
g_string_sprintf(buf, "%s \"%s\"", const_str("string_fs_remove_file_command"), files->str);
|
printf("Problem Removing File %s\n", (gchar*)g_ptr_array_index(files, i));
|
||||||
|
}
|
||||||
file_my_system(buf);
|
}
|
||||||
|
|
||||||
g_string_free(buf, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Execute the appropriate copy command. */
|
/** Execute the appropriate copy command. */
|
||||||
|
|
|
@ -100,7 +100,7 @@ void
|
||||||
file_decompress(const gchar *filename);
|
file_decompress(const gchar *filename);
|
||||||
|
|
||||||
void
|
void
|
||||||
file_remove_files(const GString *files);
|
file_remove_files(const GPtrArray *files);
|
||||||
|
|
||||||
void
|
void
|
||||||
file_copy_file(const gchar *source_file, const gchar *dest_file);
|
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.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
@ -70,8 +71,7 @@ load_save_save_game(const gchar *filename)
|
||||||
misc_string_assign(&save_file, fullname->str);
|
misc_string_assign(&save_file, fullname->str);
|
||||||
|
|
||||||
if(g_file_test(fullname->str, G_FILE_TEST_EXISTS))
|
if(g_file_test(fullname->str, G_FILE_TEST_EXISTS))
|
||||||
/*todo: replace with g_remove*/
|
g_remove(fullname->str);
|
||||||
file_remove_files(fullname);
|
|
||||||
|
|
||||||
if(debug > 60)
|
if(debug > 60)
|
||||||
g_print("load_save_save options\n");
|
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);
|
PIC_TYPE_LOAD);
|
||||||
|
|
||||||
g_string_sprintf(buf, "%s%s%s___*", dirname, G_DIR_SEPARATOR_S, prefix);
|
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);
|
misc_string_assign(&save_file, fullname);
|
||||||
|
|
||||||
|
|
|
@ -8,4 +8,3 @@ libminizip_la_SOURCES = \
|
||||||
unzip.c \
|
unzip.c \
|
||||||
unzip.h
|
unzip.h
|
||||||
|
|
||||||
CLEANFILES = *~
|
|
||||||
|
|
Loading…
Reference in New Issue