[Extractor-gtk-cvslog] SF.net SVN: extractor-gtk: [31] trunk/extractor/extractor.c
Extract files from unusual archive formats
Brought to you by:
someone-guy
From: <som...@us...> - 2007-09-16 10:29:27
|
Revision: 31 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=31&view=rev Author: someone-guy Date: 2007-09-16 03:29:26 -0700 (Sun, 16 Sep 2007) Log Message: ----------- Factor out the file open function from the gui code Modified Paths: -------------- trunk/extractor/extractor.c Modified: trunk/extractor/extractor.c =================================================================== --- trunk/extractor/extractor.c 2007-09-16 10:29:17 UTC (rev 30) +++ trunk/extractor/extractor.c 2007-09-16 10:29:26 UTC (rev 31) @@ -111,6 +111,24 @@ } } +static int open_file(char *fname, fmt_desc_t *fmt) { + // close previous file and free its data + if (cur_fmt && flist) + cur_fmt->free_list(flist); + flist = NULL; + cur_fmt = fmt; + if (input_file) + fclose(input_file); + + // open new file + input_file = fopen(fname, "rb"); + if (!input_file) + return 0; + flist = cur_fmt->get_list(input_file); + set_treeview(flist); + return 1; +} + /** * \brief called when a new archive is selected */ @@ -126,24 +144,12 @@ goto err_out; } - // close previous file and free its data - if (cur_fmt && flist) - cur_fmt->free_list(flist); - flist = NULL; - cur_fmt = *fmt; - if (input_file) - fclose(input_file); - - // open new file - input_file = fopen(fname, "rb"); - if (!input_file) { + if (!open_file(fname, *fmt)) { SHOW_MSG(GTK_MESSAGE_ERROR, _("Error opening file '%s': %s"), fname, g_strerror(errno)); goto err_out; } g_free(fname); - flist = cur_fmt->get_list(input_file); - set_treeview(flist); return; err_out: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |