Index: dataobj/tabfile.cc =================================================================== --- dataobj/tabfile.cc (revision 8773) +++ dataobj/tabfile.cc (working copy) @@ -290,7 +290,7 @@ } -bool tabfile_t::read(tabfileobj_t &objinfo) +bool tabfile_t::read(tabfileobj_t &objinfo, FILE *fp) { bool lines = false; char line[4096]; @@ -440,10 +440,16 @@ printf("%s = %s\n", line_expand, delim_expand); objinfo.put(line_expand, delim_expand); + if (fp != NULL) { + fprintf(fp, "%s=%s\n", line_expand, delim_expand); + } } } else { objinfo.put(line, delim); + if (fp != NULL) { + fprintf(fp, "%s=%s\n", line, delim); + } } lines = true; } Index: dataobj/tabfile.h =================================================================== --- dataobj/tabfile.h (revision 8773) +++ dataobj/tabfile.h (working copy) @@ -113,7 +113,7 @@ * * @author V. Meyer */ - bool read(tabfileobj_t &objinfo); + bool read(tabfileobj_t &objinfo, FILE *fp = NULL); }; Index: descriptor/writer/root_writer.cc =================================================================== --- descriptor/writer/root_writer.cc (revision 8773) +++ descriptor/writer/root_writer.cc (working copy) @@ -479,3 +479,79 @@ printf("This program can pack the following object types (pak version %d) :\n", COMPILER_VERSION_CODE); show_capabilites(); } + + +void root_writer_t::expand_dat(const char* filename, int argc, char* argv[]) +{ + searchfolder_t find; + FILE* outfp = NULL; + bool generate_name = false; + string file = find.complete(filename, "dat"); + + if (file[file.size()-1] == '/') { + printf("writing individual files to %s\n", filename); + generate_name = true; + } + else { + outfp = fopen(file.c_str(), "wb"); + + if (!outfp) { + dbg->fatal( "Write dat", "Cannot create destination file %s", filename ); + exit(3); + } + printf("writing file %s\n", filename); + } + + for( int i=0; i==0 || ifatal( "Write pak", "Cannot create destination file %s", name.c_str() ); + exit(3); + } + printf(" writing file %s\n", name.c_str()); + } + // fprintf(outfp, "# Expanded file by makeobj\n"); + while(infile.read(obj, outfp)) { + fprintf(outfp, "---\n"); + } + + if(generate_name) { + fclose(outfp); + } + } + else { + dbg->warning( "Write dat", "Cannot read %s", i); + } + } + } + if(!generate_name) { + fclose(outfp); + } +} Index: descriptor/writer/root_writer.h =================================================================== --- descriptor/writer/root_writer.h (revision 8773) +++ descriptor/writer/root_writer.h (working copy) @@ -32,6 +32,19 @@ void list(int argc, char* argv[]); void copy(const char* name, int argc, char* argv[]); + /** + * @brief Expands makeobj pre-processor stuff + * + * Dat files can contain 'minified' pre-processor-like features, this + * function will run the dat on the tabfile reader and return write + * its output to a $filename-expanded.dat file. + * + * @param name Filename of the output file or folder + * @param argc Number of input files + * @param argv List of input files' paths + */ + void expand_dat(const char* name, int argc, char* argv[]); + /* makes single files from a merged file */ void uncopy(const char* name); Index: makeobj/makeobj.cc =================================================================== --- makeobj/makeobj.cc (revision 8773) +++ makeobj/makeobj.cc (working copy) @@ -106,6 +106,30 @@ } } + if (argc && !STRICMP(argv[0], "expand")) { + argv++, argc--; + + try { + const char* dest; + + if (argc) { + dest = argv[0]; + argv++, argc--; + } + else { + dest = "./"; + } + + root_writer_t::instance()->expand_dat(dest, argc, argv); + } + catch (const obj_pak_exception_t& e) { + dbg->error( e.get_class(), e.get_info() ); + return 1; + } + + return 0; + } + if (argc > 1) { if (!STRICMP(argv[0], "dump")) { argv++, argc--; @@ -153,6 +177,8 @@ " List the internal nodes of a file\n" " MakeObj MERGE \n" " Merges multiple pak files into one new pak file library\n" + " MakeObj EXPAND \n" + " Expands minified notation to complete notation on dat file(s)\n" " MakeObj EXTRACT \n" " Creates single files from a pak file library\n" "\n"