Author: hpoussin
Date: Fri Aug 3 17:47:51 2007
New Revision: 28133
URL:
http://svn.reactos.org/svn/reactos?rev=28133&view=rev
Log:
Add -O option, to define where are stored extracted resources
Modified:
trunk/reactos/tools/bin2res/bin2res.c
Modified: trunk/reactos/tools/bin2res/bin2res.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/bin2res/bin2res.c?re…
==============================================================================
--- trunk/reactos/tools/bin2res/bin2res.c (original)
+++ trunk/reactos/tools/bin2res/bin2res.c Fri Aug 3 17:47:51 2007
@@ -48,7 +48,7 @@
extern int mkstemps(char *template, int suffix_len);
int process_resources(const char* input_file_name, const char* specific_file_name,
- const char* relative_path,
+ const char* relative_path, const char* output_path,
int inserting, int force_processing, int verbose);
static const char* help =
@@ -172,7 +172,7 @@
}
void process_includes(const char* input_file_name, const char* specific_file_name,
- const char* relative_path,
+ const char* relative_path, const char* output_path,
int inserting, int force_processing, int verbose)
{
char filename[PATH_MAX];
@@ -187,14 +187,14 @@
if (!(include_file_name = parse_include(buffer))) continue;
if ( verbose ) printf ( "Processing included file %s\n", include_file_name);
process_resources(get_filename_with_full_path(filename, include_file_name,
relative_path),
- specific_file_name, relative_path,
+ specific_file_name, relative_path, output_path,
inserting, force_processing, verbose);
}
fclose(fin);
}
int process_resources(const char* input_file_name, const char* specific_file_name,
- const char* relative_path,
+ const char* relative_path, const char* output_path,
int inserting, int force_processing, int verbose)
{
char filename[PATH_MAX];
@@ -237,15 +237,17 @@
if (inserting) fputc(c, ftmp);
if (c == EOF) break;
- if (!(fres = fopen(get_filename_with_full_path(filename, res_file_name, relative_path),
- inserting ? "rb" : "wb"))) break;
if (inserting)
{
+ if (!(fres = fopen(get_filename_with_full_path(filename, res_file_name,
relative_path),
+ "rb"))) break;
if (!insert_hexdump(ftmp, fres)) break;
while ( (c = fgetc(fin)) != EOF && c != '}') /**/;
}
else
{
+ if (!(fres = fopen(get_filename_with_full_path(filename, res_file_name,
output_path),
+ "wb"))) break;
if (!extract_hexdump(fres, fin)) break;
}
fclose(fres);
@@ -272,7 +274,7 @@
}
else
{
- process_includes(input_file_name, specific_file_name, relative_path,
+ process_includes(input_file_name, specific_file_name, relative_path, output_path,
inserting, force_processing, verbose);
}
@@ -302,8 +304,9 @@
const char* input_file_name = 0;
const char* specific_file_name = 0;
const char* relative_path = 0;
-
- while((optc = getopt(argc, argv, "axi:o:b:fhv")) != EOF)
+ const char* output_path = 0;
+
+ while((optc = getopt(argc, argv, "axi:o:b:O:fhv")) != EOF)
{
switch(optc)
{
@@ -320,6 +323,10 @@
if (convert_dir && convert_dir != optc) usage();
convert_dir = optc;
break;
+ case 'O':
+ if (output_path) usage();
+ output_path = fix_path_sep(optarg);
+ break;
case 'b':
if (relative_path) usage();
relative_path = fix_path_sep(optarg);
@@ -345,6 +352,7 @@
if (!convert_dir) usage();
if (!process_resources(input_file_name, specific_file_name, relative_path,
+ output_path ? output_path : relative_path,
convert_dir == 'a', force_overwrite, verbose))
{
perror("Processing failed");