[Scummvm-cvs-logs] SF.net SVN: scummvm:[42082] tools/branches/gsoc2009-gui
Remere at users.sourceforge.net
Remere at users.sourceforge.net
Sat Jul 4 03:07:13 CEST 2009
Revision: 42082
http://scummvm.svn.sourceforge.net/scummvm/?rev=42082&view=rev
Author: Remere
Date: 2009-07-04 01:07:12 +0000 (Sat, 04 Jul 2009)
Log Message:
-----------
*Created a common base class for conversion/extraction tools, this will make the tools much easier to integrate into the GUI.
*Converted extract_agos and extract_gob_stk to use this new Tool class.
*Changed Filename to use std::string rather than char array, to integrate better with the new classes.
*Small fixes to File & Filename classes
*Small backstep on the GUI as it only supports two tools now (the converted one's), however the new tool format has many gains, the actual tool is not run yet as arguments are not passed between the UI and the tool itself.
[Due to the change of char to std::string, many files were modified, the interesting files are in addition to the new files extract_gob_stk.cpp, extract_agos.cpp, gui/pages.cpp, compress.cpp, compress.h, util.cpp and util.h]
Modified Paths:
--------------
tools/branches/gsoc2009-gui/compress.cpp
tools/branches/gsoc2009-gui/compress.h
tools/branches/gsoc2009-gui/compress_agos.cpp
tools/branches/gsoc2009-gui/compress_gob.cpp
tools/branches/gsoc2009-gui/compress_kyra.cpp
tools/branches/gsoc2009-gui/compress_queen.cpp
tools/branches/gsoc2009-gui/compress_saga.cpp
tools/branches/gsoc2009-gui/compress_scumm_bun.cpp
tools/branches/gsoc2009-gui/compress_scumm_san.cpp
tools/branches/gsoc2009-gui/compress_scumm_sou.cpp
tools/branches/gsoc2009-gui/compress_sword1.cpp
tools/branches/gsoc2009-gui/compress_sword2.cpp
tools/branches/gsoc2009-gui/compress_touche.cpp
tools/branches/gsoc2009-gui/compress_tucker.cpp
tools/branches/gsoc2009-gui/encode_dxa.cpp
tools/branches/gsoc2009-gui/extract_agos.cpp
tools/branches/gsoc2009-gui/extract_gob_stk.cpp
tools/branches/gsoc2009-gui/extract_kyra.cpp
tools/branches/gsoc2009-gui/extract_loom_tg16.cpp
tools/branches/gsoc2009-gui/extract_mm_c64.cpp
tools/branches/gsoc2009-gui/extract_mm_nes.cpp
tools/branches/gsoc2009-gui/extract_parallaction.cpp
tools/branches/gsoc2009-gui/extract_scumm_mac.cpp
tools/branches/gsoc2009-gui/extract_zak_c64.cpp
tools/branches/gsoc2009-gui/gui/configuration.h
tools/branches/gsoc2009-gui/gui/main.cpp
tools/branches/gsoc2009-gui/gui/pages.cpp
tools/branches/gsoc2009-gui/gui/pages.h
tools/branches/gsoc2009-gui/gui/tools.cpp
tools/branches/gsoc2009-gui/gui/tools.h
tools/branches/gsoc2009-gui/kyra_pak.cpp
tools/branches/gsoc2009-gui/util.cpp
tools/branches/gsoc2009-gui/util.h
Added Paths:
-----------
tools/branches/gsoc2009-gui/extract_agos.h
tools/branches/gsoc2009-gui/extract_gob_stk.h
tools/branches/gsoc2009-gui/tool.cpp
tools/branches/gsoc2009-gui/tool.h
Modified: tools/branches/gsoc2009-gui/compress.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -22,13 +22,20 @@
#include "compress.h"
-// The order should match the CompressMode enum
-const char *audio_extensions[] = {
- ".unk",
- ".mp3",
- ".ogg",
- ".fla"
-};
+// The order should match the AudioFormat enum
+const char *audio_extensions(AudioFormat format) {
+ switch(format) {
+ case AUDIO_MP3:
+ return ".mp3";
+ case AUDIO_VORBIS:
+ return ".ogg";
+ case AUDIO_FLAC:
+ return ".fla";
+ case AUDIO_NONE:
+ default:
+ return ".unk";
+ }
+}
typedef struct {
uint32 minBitr;
@@ -106,12 +113,12 @@
return 48000;
}
-void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode) {
+void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, AudioFormat compmode) {
bool err = false;
char fbuf[2048];
char *tmp = fbuf;
- if (compmode == kMP3Mode) {
+ if (compmode == AUDIO_MP3) {
tmp += sprintf(tmp, "lame -t ");
if (rawInput) {
tmp += sprintf(tmp, "-r ");
@@ -164,7 +171,7 @@
}
#ifdef DISABLE_BUILTIN_VORBIS
- if (compmode == kVorbisMode) {
+ if (compmode == AUDIO_VORBIS) {
tmp += sprintf(tmp, "oggenc ");
if (rawInput) {
tmp += sprintf(tmp, "--raw ");
@@ -208,7 +215,7 @@
#endif
#ifdef DISABLE_BUILTIN_FLAC
- if (compmode == kFlacMode) {
+ if (compmode == AUDIO_FLAC) {
/* --lax is needed to allow 11kHz, we dont need place for meta-tags, and no seektable */
/* -f is reqired to force override of unremoved temp file. See bug #1294648 */
tmp += sprintf(tmp, "flac -f --lax --no-padding --no-seektable --no-ogg ");
@@ -303,9 +310,9 @@
}
}
-void encodeRaw(char *rawData, int length, int samplerate, const char *outname, CompressMode compmode) {
+void encodeRaw(char *rawData, int length, int samplerate, const char *outname, AudioFormat compmode) {
#ifndef DISABLE_BUILTIN_VORBIS
- if (compmode == kVorbisMode) {
+ if (compmode == AUDIO_VORBIS) {
FILE *outputOgg;
char outputString[256] = "";
int numChannels = (rawAudioType.isStereo ? 2 : 1);
@@ -513,7 +520,7 @@
#endif
#ifndef DISABLE_BUILTIN_FLAC
- if (compmode == kFlacMode) {
+ if (compmode == AUDIO_FLAC) {
int i;
int numChannels = (rawAudioType.isStereo ? 2 : 1);
int samplesPerChannel = length / ((rawAudioType.bitsPerSample / 8) * numChannels);
@@ -576,7 +583,7 @@
#endif
}
-void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode) {
+void extractAndEncodeWAV(const char *outName, FILE *input, AudioFormat compMode) {
unsigned int length;
FILE *f;
char fbuf[2048];
@@ -602,7 +609,7 @@
encodeAudio(outName, false, -1, tempEncoded, compMode);
}
-void extractAndEncodeVOC(const char *outName, FILE *input, CompressMode compMode) {
+void extractAndEncodeVOC(const char *outName, FILE *input, AudioFormat compMode) {
FILE *f;
int bits;
int blocktype;
@@ -884,40 +891,87 @@
return 1;
}
-CompressMode process_audio_params(int argc, char *argv[], int* i) {
+AudioFormat process_audio_params(int argc, char *argv[], int* i) {
/* Compression mode */
- CompressMode compMode = kMP3Mode;
+ AudioFormat compMode = AUDIO_MP3;
for (; *i < argc - 2; ++*i) {
if (strcmp(argv[*i], "--mp3") == 0)
- compMode = kMP3Mode;
+ compMode = AUDIO_MP3;
else if (strcmp(argv[*i], "--vorbis") == 0)
- compMode = kVorbisMode;
+ compMode = AUDIO_VORBIS;
else if (strcmp(argv[*i], "--flac") == 0)
- compMode = kFlacMode;
+ compMode = AUDIO_FLAC;
else
break;
}
switch (compMode) {
- case kMP3Mode:
+ case AUDIO_MP3:
tempEncoded = TEMP_MP3;
if (!process_mp3_parms(argc - 2, argv, i))
- return kNoAudioMode;
+ return AUDIO_NONE;
break;
- case kVorbisMode:
+ case AUDIO_VORBIS:
tempEncoded = TEMP_OGG;
if (!process_ogg_parms(argc - 2, argv, i))
- return kNoAudioMode;
+ return AUDIO_NONE;
break;
- case kFlacMode:
+ case AUDIO_FLAC:
tempEncoded = TEMP_FLAC;
if (!process_flac_parms(argc - 2, argv, i))
- return kNoAudioMode;
+ return AUDIO_NONE;
break;
- case kNoAudioMode: // cannot occur but we check anyway to avoid compiler warnings
+ case AUDIO_NONE: // cannot occur but we check anyway to avoid compiler warnings
break;
}
return compMode;
}
+
+// Compression tool interface
+// Duplicates code above in the new way
+// The old code can be removed once all tools have been converted
+
+CompressionTool::CompressionTool(const std::string &name) : Tool(name) {
+}
+
+void CompressionTool::parseAudioArguments() {
+ AudioFormat format = AUDIO_NONE;
+
+ if (_arguments[_arguments_parsed] == "--mp3")
+ format = AUDIO_MP3;
+ else if (_arguments[_arguments_parsed] == "--vorbis")
+ format = AUDIO_VORBIS;
+ else if (_arguments[_arguments_parsed] == "--flac")
+ format = AUDIO_FLAC;
+ else
+ // No audio arguments then
+ return;
+
+ ++_arguments_parsed;
+
+ // Need workaround to be sign-correct
+ int arg = (int)_arguments_parsed;
+
+ switch (format) {
+ case AUDIO_MP3:
+ tempEncoded = TEMP_MP3;
+ if (!process_mp3_parms(_arguments.size() - 2, _argv, &arg))
+ throw ToolException("Could not parse command line arguments, use --help for options");
+ break;
+ case AUDIO_VORBIS:
+ tempEncoded = TEMP_OGG;
+ if (!process_ogg_parms(_arguments.size() - 2, _argv, &arg))
+ throw ToolException("Could not parse command line arguments, use --help for options");
+ break;
+ case AUDIO_FLAC:
+ tempEncoded = TEMP_FLAC;
+ if (!process_flac_parms(_arguments.size() - 2, _argv, &arg))
+ throw ToolException("Could not parse arguments: Use --help for options");
+ break;
+ default: // cannot occur but we check anyway to avoid compiler warnings
+ throw ToolException("Unknown audio format, should be impossible!");
+ }
+ _arguments_parsed = (size_t)arg;
+}
Modified: tools/branches/gsoc2009-gui/compress.h
===================================================================
--- tools/branches/gsoc2009-gui/compress.h 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress.h 2009-07-04 01:07:12 UTC (rev 42082)
@@ -23,7 +23,8 @@
#ifndef COMPRESS_H
#define COMPRESS_H
-#include "util.h"
+#include "tool.h"
+
#ifndef DISABLE_BUILTIN_VORBIS
#include <vorbis/vorbisenc.h>
#endif
@@ -56,32 +57,54 @@
#define TEMP_OGG "tempfile.ogg"
#define TEMP_FLAC "tempfile.fla"
-enum CompressMode {
- kNoAudioMode,
- kMP3Mode,
- kVorbisMode,
- kFlacMode
-};
-extern const char *audio_extensions[];
+/**
+ * Compression tool
+ * A tool, which can compress to either MP3, Vorbis or FLAC formats
+ */
+class CompressionTool : public Tool {
+public:
+ CompressionTool(const std::string &name);
+
+ void parseAudioArguments();
+public:
+ // Settings
+ // mp3 settings
+ std::string _mp3CompressionType;
+ std::string _mp3MpegQuality;
+ std::string _mp3ABRBitrate;
+ std::string _mp3VBRMinBitrate;
+ std::string _mp3VBRMaxBitrate;
+ std::string _mp3VBRQuality;
+
+ // flac
+ std::string _flacCompressionLevel;
+ std::string _flacBlockSize;
+
+ // vorbis
+ std::string _oggQuality;
+ std::string _oggMinBitrate;
+ std::string _oggAvgBitrate;
+ std::string _oggMaxBitrate;
+};
+
/*
* Stuff which is in compress.cpp
*/
-
const extern char *tempEncoded;
-extern CompressMode process_audio_params(int argc, char *argv[], int* i);
+extern AudioFormat process_audio_params(int argc, char *argv[], int* i);
extern int process_mp3_parms(int argc, char *argv[], int* i);
extern int process_ogg_parms(int argc, char *argv[], int* i);
extern int process_flac_parms(int argc, char *argv[], int* i);
-extern void extractAndEncodeVOC(const char *outName, FILE *input, CompressMode compMode);
-extern void extractAndEncodeWAV(const char *outName, FILE *input, CompressMode compMode);
+extern void extractAndEncodeVOC(const char *outName, FILE *input, AudioFormat compMode);
+extern void extractAndEncodeWAV(const char *outName, FILE *input, AudioFormat compMode);
-extern void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, CompressMode compmode);
-extern void encodeRaw(char *rawData, int length, int samplerate, const char *outname, CompressMode compmode);
+extern void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, AudioFormat compmode);
+extern void encodeRaw(char *rawData, int length, int samplerate, const char *outname, AudioFormat compmode);
extern void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample);
Modified: tools/branches/gsoc2009-gui/compress_agos.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_agos.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_agos.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -27,7 +27,7 @@
static FILE *input, *output_idx, *output_snd;
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
static void end(Filename *outPath) {
int size;
@@ -37,7 +37,7 @@
fclose(output_idx);
fclose(input);
- output_idx = fopen(outPath->getFullPath(), "wb");
+ output_idx = fopen(outPath->getFullPath().c_str(), "wb");
input = fopen(TEMP_IDX, "rb");
while ((size = fread(fbuf, 1, 2048, input)) > 0) {
@@ -134,9 +134,9 @@
uint32 filenums[32768];
uint32 offsets[32768];
- input = fopen(inputPath->getFullPath(), "rb");
+ input = fopen(inputPath->getFullPath().c_str(), "rb");
if (!input) {
- error("Cannot open file: %s", inputPath->getFullPath());
+ error("Cannot open file: %s", inputPath->getFullPath().c_str());
}
output_idx = fopen(TEMP_IDX, "wb");
@@ -177,7 +177,7 @@
uint32 offsets[32768];
inputPath->setFullName("voices.idx");
- input = fopen(inputPath->getFullPath(), "rb");
+ input = fopen(inputPath->getFullPath().c_str(), "rb");
if (!input) {
error("Cannot open file: %s", "voices.idx");
}
@@ -216,9 +216,9 @@
fclose(input);
}
- input = fopen(inputPath->getFullPath(), "rb");
+ input = fopen(inputPath->getFullPath().c_str(), "rb");
if (!input) {
- error("Cannot open file: %s", inputPath->getFullPath());
+ error("Cannot open file: %s", inputPath->getFullPath().c_str());
}
}
@@ -246,7 +246,7 @@
gCompMode = process_audio_params(argc, argv, &first_arg);
- if (gCompMode == kNoAudioMode) {
+ if (gCompMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -270,7 +270,7 @@
if (outpath.empty()) {
outpath = inpath;
- outpath.setExtension(audio_extensions[gCompMode]);
+ outpath.setExtension(audio_extensions(gCompMode));
}
if (convertMac) {
Modified: tools/branches/gsoc2009-gui/compress_gob.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_gob.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_gob.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -81,12 +81,12 @@
}
// Open input (config) file
- if (!(gobConf = fopen(inpath.getFullPath(), "r")))
- error("Couldn't open conf file '%s'", inpath.getFullPath());
+ if (!(gobConf = fopen(inpath.getFullPath().c_str(), "r")))
+ error("Couldn't open conf file '%s'", inpath.getFullPath().c_str());
// Open output filk
- if (!(stk = fopen(outpath.getFullPath(), "wb")))
- error("Couldn't create file \"%s\"", outpath.getFullPath());
+ if (!(stk = fopen(outpath.getFullPath().c_str(), "wb")))
+ error("Couldn't create file \"%s\"", outpath.getFullPath().c_str());
// Read the input into memory
chunks = readChunkConf(gobConf, chunkCount);
@@ -163,8 +163,8 @@
while (curChunk) {
inpath->setFullName(curChunk->name);
- if (!(src = fopen(inpath->getFullPath(), "rb")))
- error("Couldn't open conf file \"%s\"", inpath->getFullPath());
+ if (!(src = fopen(inpath->getFullPath().c_str(), "rb")))
+ error("Couldn't open conf file \"%s\"", inpath->getFullPath().c_str());
realSize = fileSize(src);
Modified: tools/branches/gsoc2009-gui/compress_kyra.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_kyra.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_kyra.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -29,7 +29,7 @@
#define TEMPFILE "TEMP.VOC"
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
int export_main(compress_kyra)(int argc, char *argv[]) {
const char *helptext = "\nUsage: %s [mode] [mode params] [-o out = ] <infile>\n" kCompressionAudioHelp;
@@ -43,7 +43,7 @@
// Compression mode
gCompMode = process_audio_params(argc, argv, &first_arg);
- if (gCompMode == kNoAudioMode) {
+ if (gCompMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -76,7 +76,7 @@
static void process(Filename *infile, Filename *outfile) {
PAKFile input, output;
- if (!input.loadFile(infile->getFullPath(), false))
+ if (!input.loadFile(infile->getFullPath().c_str(), false))
return;
if (!output.loadFile(NULL, false))
@@ -90,23 +90,22 @@
continue;
if (list->data[26] != 1) {
- warning("'%s' contains broken VOC file '%s' skipping it...", infile->getFullPath(), list->filename);
+ warning("'%s' contains broken VOC file '%s' skipping it...", infile->getFullPath().c_str(), list->filename);
continue;
}
Filename outputName;
input.outputFileAs(list->filename, TEMPFILE);
- strncpy(outputName._path, list->filename, 27);
- outputName._path[27] = 0;
+ outputName._path = list->filename;
FILE *tempFile = fopen(TEMPFILE, "rb");
fseek(tempFile, 26, SEEK_CUR);
extractAndEncodeVOC(TEMP_RAW, tempFile, gCompMode);
fclose(tempFile);
- outputName.setExtension(audio_extensions[gCompMode]);
+ outputName.setExtension(audio_extensions(gCompMode));
- output.addFile(outputName.getFullPath(), tempEncoded);
+ output.addFile(outputName.getFullPath().c_str(), tempEncoded);
unlink(TEMPFILE);
unlink(TEMP_RAW);
@@ -114,9 +113,9 @@
}
if (output.getFileList())
- output.saveFile(outfile->getFullPath());
+ output.saveFile(outfile->getFullPath().c_str());
else
- printf("file '%s' doesn't contain any .voc files\n", infile->getFullPath());
+ printf("file '%s' doesn't contain any .voc files\n", infile->getFullPath().c_str());
}
// Kyra3 specifc code
@@ -320,21 +319,21 @@
static void processKyra3(Filename *infile, Filename *outfile) {
if (infile->hasExtension("AUD")) {
- outfile->setExtension(audio_extensions[gCompMode]);
+ outfile->setExtension(audio_extensions(gCompMode));
- FILE *input = fopen(infile->getFullPath(), "rb");
+ FILE *input = fopen(infile->getFullPath().c_str(), "rb");
if (!input)
- error("Couldn't open file '%s'", infile->getFullPath());
+ error("Couldn't open file '%s'", infile->getFullPath().c_str());
- compressAUDFile(input, outfile->getFullPath());
+ compressAUDFile(input, outfile->getFullPath().c_str());
fclose(input);
} else if (infile->hasExtension("TLK")) {
PAKFile output;
- FILE *input = fopen(infile->getFullPath(), "rb");
+ FILE *input = fopen(infile->getFullPath().c_str(), "rb");
if (!input)
- error("Couldn't open file '%s'", infile->getFullPath());
+ error("Couldn't open file '%s'", infile->getFullPath().c_str());
if (!output.loadFile(NULL, false))
return;
@@ -348,12 +347,12 @@
uint32 resOffset = readUint32LE(input);
char outname[16];
- snprintf(outname, 16, "%.08u.%s", resFilename, audio_extensions[gCompMode]);
+ snprintf(outname, 16, "%.08u.%s", resFilename, audio_extensions(gCompMode));
const DuplicatedFile *file = findDuplicatedFile(resOffset, red, files);
if (file) {
char linkname[16];
- snprintf(linkname, 16, "%.08u.%s", file->resFilename, audio_extensions[gCompMode]);
+ snprintf(linkname, 16, "%.08u.%s", file->resFilename, audio_extensions(gCompMode));
output.linkFiles(outname, linkname);
} else {
@@ -377,9 +376,9 @@
fclose(input);
if (output.getFileList())
- output.saveFile(outfile->getFullPath());
+ output.saveFile(outfile->getFullPath().c_str());
} else {
- error("Unsupported file '%s'", infile->getFullPath());
+ error("Unsupported file '%s'", infile->getFullPath().c_str());
}
}
@@ -387,16 +386,16 @@
if (infile->hasExtension("AUD")) {
return true;
} else if (infile->hasExtension("VRM") || infile->hasExtension("PAK")) {
- if (!PAKFile::isPakFile(infile->getFullPath()))
- error("Unknown filetype of file: '%s'", infile->getFullPath());
+ if (!PAKFile::isPakFile(infile->getFullPath().c_str()))
+ error("Unknown filetype of file: '%s'", infile->getFullPath().c_str());
return false;
} else if (infile->hasExtension("TLK")) {
- if (PAKFile::isPakFile(infile->getFullPath()))
+ if (PAKFile::isPakFile(infile->getFullPath().c_str()))
return false;
- FILE *f = fopen(infile->getFullPath(), "rb");
+ FILE *f = fopen(infile->getFullPath().c_str(), "rb");
if (!f)
- error("Couldn't open file '%s'", infile->getFullPath());
+ error("Couldn't open file '%s'", infile->getFullPath().c_str());
uint16 entries = readUint16LE(f);
uint32 entryTableSize = (entries * 8);
@@ -404,7 +403,7 @@
if (entryTableSize + 2 > filesize) {
fclose(f);
- error("Unknown filetype of file: '%s'", infile->getFullPath());
+ error("Unknown filetype of file: '%s'", infile->getFullPath().c_str());
}
uint32 offset = 0;
@@ -413,13 +412,13 @@
offset = readUint32LE(f);
if (offset > filesize)
- error("Unknown filetype of file: '%s'", infile->getFullPath());
+ error("Unknown filetype of file: '%s'", infile->getFullPath().c_str());
}
return true;
}
- error("Unknown filetype of file: '%s'", infile->getFullPath());
+ error("Unknown filetype of file: '%s'", infile->getFullPath().c_str());
}
#if defined(UNIX) && defined(EXPORT_MAIN)
Modified: tools/branches/gsoc2009-gui/compress_queen.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_queen.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_queen.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -23,7 +23,7 @@
#include "compress.h"
static const uint32 QTBL = 'QTBL';
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
#define INPUT_TBL "queen.tbl"
#define FINAL_OUT "queen.1c"
@@ -169,8 +169,8 @@
inData = fopen(TEMP_DAT, "rb");
checkOpen(inData, TEMP_DAT);
- outFinal = fopen(outPath->getFullPath(), "wb");
- checkOpen(outFinal, outPath->getFullPath());
+ outFinal = fopen(outPath->getFullPath().c_str(), "wb");
+ checkOpen(outFinal, outPath->getFullPath().c_str());
dataStartOffset = fileSize(inTbl) + EXTRA_TBL_HEADER;
dataSize = fileSize(inData);
@@ -220,7 +220,7 @@
gCompMode = process_audio_params(argc, argv, &first_arg);
- if (gCompMode == kNoAudioMode) {
+ if (gCompMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -243,13 +243,13 @@
}
/* Open input file (QUEEN.1) */
- inputData = fopen(inpath.getFullPath(), "rb");
- checkOpen(inputData, inpath.getFullPath());
+ inputData = fopen(inpath.getFullPath().c_str(), "rb");
+ checkOpen(inputData, inpath.getFullPath().c_str());
/* Open TBL file (QUEEN.TBL) */
inpath.setFullName(INPUT_TBL);
- inputTbl = fopen(inpath.getFullPath(), "rb");
- checkOpen(inputTbl, inpath.getFullPath());
+ inputTbl = fopen(inpath.getFullPath().c_str(), "rb");
+ checkOpen(inputTbl, inpath.getFullPath().c_str());
size = fileSize(inputData);
fread(tmp, 1, 4, inputTbl);
Modified: tools/branches/gsoc2009-gui/compress_saga.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_saga.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_saga.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -1,3 +1,4 @@
+
/* compress_saga - Compress SAGA engine digital sound files into
* MP3 and Ogg Vorbis format
* Copyright (C) 2004, Marcoen Hirschberg
@@ -135,7 +136,7 @@
uint32 size;
} Record;
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
GameDescription *currentGameDescription = NULL;
GameFileDescription *currentFileDescription = NULL;
@@ -153,7 +154,7 @@
uint8 md5sum[16];
char md5str[32+1];
- Common::md5_file(infile->getFullPath(), md5sum, FILE_MD5_BYTES);
+ Common::md5_file(infile->getFullPath().c_str(), md5sum, FILE_MD5_BYTES);
printf("Input file name: %s\n", infile->getFullPath());
for (j = 0; j < 16; j++) {
sprintf(md5str + j*2, "%02x", (int)md5sum[j]);
@@ -176,7 +177,7 @@
// Filename based detection, used in IHNM, as all its sound files have the
// same encoding
- if (scumm_stricmp(gameDescriptions[i].filesDescriptions[j].fileName, infile->getFullName()) == 0) {
+ if (scumm_stricmp(gameDescriptions[i].filesDescriptions[j].fileName, infile->getFullName().c_str()) == 0) {
currentGameDescription = &gameDescriptions[i];
currentFileDescription = ¤tGameDescription->filesDescriptions[j];
@@ -349,7 +350,7 @@
Record *inputTable;
Record *outputTable;
- inputFile = fopen(inpath->getFullPath(), "rb");
+ inputFile = fopen(inpath->getFullPath().c_str(), "rb");
inputFileSize = fileSize(inputFile);
printf("Filesize: %ul\n", inputFileSize);
/*
@@ -402,7 +403,7 @@
*outpath = *inpath;
outpath->setExtension(".cmp");
}
- outputFile = fopen(outpath->getFullPath(), "wb");
+ outputFile = fopen(outpath->getFullPath().c_str(), "wb");
for (i = 0; i < resTableCount; i++) {
fseek(inputFile, inputTable[i].offset, SEEK_SET);
@@ -448,7 +449,7 @@
// compression mode
gCompMode = process_audio_params(argc, argv, &first_arg);
- if (gCompMode == kNoAudioMode) {
+ if (gCompMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -485,7 +486,7 @@
if (detectFile(&inpath)) {
sagaEncode(&inpath, &outpath);
} else {
- error("Failed to compress file %s", inpath.getFullPath());
+ error("Failed to compress file %s", inpath.getFullPath().c_str());
}
}
}
Modified: tools/branches/gsoc2009-gui/compress_scumm_bun.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_scumm_bun.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_scumm_bun.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -630,7 +630,7 @@
char fbuf2[2048];
sprintf(fbuf, "%s.wav", filename);
sprintf(fbuf2, "%s.fla", filename);
- encodeAudio(fbuf, false, -1, fbuf2, kFlacMode);
+ encodeAudio(fbuf, false, -1, fbuf2, AUDIO_FLAC);
}
void encodeWaveWithOgg(char *filename) {
@@ -638,7 +638,7 @@
char fbuf2[2048];
sprintf(fbuf, "%s.wav", filename);
sprintf(fbuf2, "%s.ogg", filename);
- encodeAudio(fbuf, false, -1, fbuf2, kVorbisMode);
+ encodeAudio(fbuf, false, -1, fbuf2, AUDIO_VORBIS);
}
void encodeWaveWithLame(char *filename) {
@@ -647,7 +647,7 @@
sprintf(fbuf, "%s.wav", filename);
sprintf(fbuf2, "%s.mp3", filename);
- encodeAudio(fbuf, false, -1, fbuf2, kMP3Mode);
+ encodeAudio(fbuf, false, -1, fbuf2, AUDIO_MP3);
}
void writeWaveHeader(int s_size, int rate, int chan) {
@@ -725,7 +725,7 @@
_waveDataSize += size;
}
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
typedef struct { int offset, size, codec; } CompTable;
@@ -881,7 +881,7 @@
static Region *_region;
static int _numRegions;
-void writeRegions(byte *ptr, int bits, int freq, int channels, char *dir, char *filename, FILE *output) {
+void writeRegions(byte *ptr, int bits, int freq, int channels, const char *dir, char *filename, FILE *output) {
char tmpPath[200];
for (int l = 0; l < _numRegions; l++) {
@@ -896,13 +896,13 @@
sprintf(tmpPath, "%s/%s_reg%03d", dir, filename, l);
switch (gCompMode) {
- case kMP3Mode:
+ case AUDIO_MP3:
encodeWaveWithLame(tmpPath);
break;
- case kVorbisMode:
+ case AUDIO_VORBIS:
encodeWaveWithOgg(tmpPath);
break;
- case kFlacMode:
+ case AUDIO_FLAC:
encodeWaveWithFlac(tmpPath);
break;
default:
@@ -914,15 +914,15 @@
int32 startPos = ftell(output);
switch (gCompMode) {
- case kMP3Mode:
+ case AUDIO_MP3:
sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.mp3", filename, l);
sprintf(tmpPath, "%s/%s_reg%03d.mp3", dir, filename, l);
break;
- case kVorbisMode:
+ case AUDIO_VORBIS:
sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.ogg", filename, l);
sprintf(tmpPath, "%s/%s_reg%03d.ogg", dir, filename, l);
break;
- case kFlacMode:
+ case AUDIO_FLAC:
sprintf(cbundleTable[cbundleCurIndex].filename, "%s_reg%03d.fla", filename, l);
sprintf(tmpPath, "%s/%s_reg%03d.fla", dir, filename, l);
break;
@@ -1097,7 +1097,7 @@
// compression mode
gCompMode = process_audio_params(argc, argv, &first_arg);
- if (gCompMode == kNoAudioMode) {
+ if (gCompMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -1117,9 +1117,9 @@
inpath.setFullPath(argv[first_arg]);
- FILE *input = fopen(inpath.getFullPath(), "rb");
+ FILE *input = fopen(inpath.getFullPath().c_str(), "rb");
if (!input) {
- error("Cannot open file: %s", inpath.getFullPath());
+ error("Cannot open file: %s", inpath.getFullPath().c_str());
}
if (outpath.empty()) {
@@ -1128,9 +1128,9 @@
outpath.setExtension(".bun");
}
- FILE *output = fopen(outpath.getFullPath(), "wb");
+ FILE *output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output) {
- error("Cannot open file: %s", outpath.getFullPath());
+ error("Cannot open file: %s", outpath.getFullPath().c_str());
}
writeUint32BE(output, 'LB23');
@@ -1172,9 +1172,7 @@
int32 size = 0;
byte *compFinal = decompressBundleSound(i, input, size);
writeToRMAPFile(compFinal, output, bundleTable[i].filename, offsetData, bits, freq, channels);
- char outdir[1024];
- outpath.getPath(outdir);
- writeRegions(compFinal + offsetData, bits, freq, channels, outdir, bundleTable[i].filename, output);
+ writeRegions(compFinal + offsetData, bits, freq, channels, outpath.getPath().c_str(), bundleTable[i].filename, output);
free(compFinal);
}
Modified: tools/branches/gsoc2009-gui/compress_scumm_san.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_scumm_san.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_scumm_san.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -64,7 +64,7 @@
char fbuf2[2048];
sprintf(fbuf, "%s.wav", filename);
sprintf(fbuf2, "%s.ogg", filename);
- encodeAudio(fbuf, false, -1, fbuf2, kVorbisMode);
+ encodeAudio(fbuf, false, -1, fbuf2, AUDIO_VORBIS);
}
void encodeSanWaveWithLame(char *filename) {
@@ -73,7 +73,7 @@
sprintf(fbuf, "%s.wav", filename);
sprintf(fbuf2, "%s.mp3", filename);
- encodeAudio(fbuf, false, -1, fbuf2, kMP3Mode);
+ encodeAudio(fbuf, false, -1, fbuf2, AUDIO_MP3);
}
void writeWaveHeader(int s_size) {
@@ -632,22 +632,21 @@
const char *helptext = "\nUsage: %s [mode] [mode-params] [-o outpufile = inputfile.san] <inputfile>\n" kCompressionAudioHelp;
Filename inpath, outpath;
- char outdir[768];
int first_arg = 1;
int last_arg = argc - 1;
parseHelpArguments(argv, argc, helptext);
// compression mode
- CompressMode compMode = process_audio_params(argc, argv, &first_arg);
+ AudioFormat compMode = process_audio_params(argc, argv, &first_arg);
// TODO
// Support flac too?
- if (compMode == kVorbisMode)
+ if (compMode == AUDIO_VORBIS)
_oggMode = true;
- else if (compMode != kMP3Mode)
+ else if (compMode != AUDIO_MP3)
notice("Only ogg vorbis and MP3 is supported for this tool.");
- if (compMode == kNoAudioMode) {
+ if (compMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -672,18 +671,14 @@
outpath.setExtension(".san");
}
- // We need this path for some functions, alot quicker than rewriting
- // them to use the Filename class
- outpath.getPath(outdir);
-
- FILE *input = fopen(inpath.getFullPath(), "rb");
+ FILE *input = fopen(inpath.getFullPath().c_str(), "rb");
if (!input) {
- error("Cannot open file: %s", inpath.getFullPath());
+ error("Cannot open file: %s", inpath.getFullPath().c_str());
}
- FILE *output = fopen(outpath.getFullPath(), "wb");
+ FILE *output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output) {
- error("Cannot open file: %s", outpath.getFullPath());
+ error("Cannot open file: %s", outpath.getFullPath().c_str());
}
Filename flupath(inpath);
@@ -691,14 +686,14 @@
FILE *flu_in = NULL;
FILE *flu_out = NULL;
- flu_in = fopen(flupath.getFullPath(), "rb");
+ flu_in = fopen(flupath.getFullPath().c_str(), "rb");
if (flu_in) {
flupath = outpath;
flupath.setExtension(".flu");
- flu_out = fopen(flupath.getFullPath(), "wb");
+ flu_out = fopen(flupath.getFullPath().c_str(), "wb");
if (!flu_out) {
- error("Cannot open ancillary file: %s", flupath.getFullPath());
+ error("Cannot open ancillary file: %s", flupath.getFullPath().c_str());
}
}
@@ -785,9 +780,9 @@
int unk = readUint16LE(input);
int track_flags = readUint16LE(input);
if ((code == 8) && (track_flags == 0) && (unk == 0) && (flags == 46)) {
- handleComiIACT(input, size, outdir, inpath.getFullName());
+ handleComiIACT(input, size, outpath.getPath().c_str(), inpath.getFullName().c_str());
} else if ((code == 8) && (track_flags != 0) && (unk == 0) && (flags == 46)) {
- handleDigIACT(input, size, outdir, inpath.getFullName(), flags, track_flags, l);
+ handleDigIACT(input, size, outpath.getPath().c_str(), inpath.getFullName().c_str(), flags, track_flags, l);
tracksCompress = true;
fps = 12;
} else {
@@ -803,7 +798,7 @@
continue;
} else if ((tag == 'PSAD') && (!flu_in)) {
size = readUint32BE(input); // chunk size
- handlePSAD(input, size, outdir, inpath.getFullName(), l);
+ handlePSAD(input, size, outpath.getPath().c_str(), inpath.getFullName().c_str(), l);
if ((size & 1) != 0) {
fseek(input, 1, SEEK_CUR);
size++;
@@ -826,20 +821,20 @@
}
if (tracksCompress) {
- prepareForMixing(outdir, inpath.getFullName());
+ prepareForMixing(outpath.getPath().c_str(), inpath.getFullName().c_str());
assert(fps);
- mixing(outdir, inpath.getFullName(), nbframes, fps);
+ mixing(outpath.getPath().c_str(), inpath.getFullName().c_str(), nbframes, fps);
}
if (_waveTmpFile) {
char tmpPath[1024];
writeWaveHeader(_waveDataSize);
- sprintf(tmpPath, "%s/%s", outdir, inpath.getFullName());
+ sprintf(tmpPath, "%s/%s", outpath.getPath().c_str(), inpath.getFullName().c_str());
if (_oggMode)
encodeSanWaveWithOgg(tmpPath);
else
encodeSanWaveWithLame(tmpPath);
- sprintf(tmpPath, "%s/%s.wav", outdir, inpath.getFullName());
+ sprintf(tmpPath, "%s/%s.wav", outpath.getPath().c_str(), inpath.getFullName().c_str());
unlink(tmpPath);
}
Modified: tools/branches/gsoc2009-gui/compress_scumm_sou.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_scumm_sou.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_scumm_sou.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -1,3 +1,4 @@
+
/* compress_scumm_sou - monster.sou to MP3-compressed monster.so3 converter
* Copyright (C) 2002-2006 The ScummVM Team
*
@@ -38,7 +39,7 @@
static FILE *input, *output_idx, *output_snd;
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
void end_of_file(const char *inputPath) {
@@ -155,7 +156,7 @@
// compression mode
gCompMode = process_audio_params(argc, argv, &first_arg);
- if (gCompMode == kNoAudioMode) {
+ if (gCompMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -168,13 +169,13 @@
last_arg -= 2;
else {
switch(gCompMode) {
- case kMP3Mode:
+ case AUDIO_MP3:
g_output_filename = OUTPUT_MP3;
break;
- case kVorbisMode:
+ case AUDIO_VORBIS:
g_output_filename = OUTPUT_OGG;
break;
- case kFlacMode:
+ case AUDIO_FLAC:
g_output_filename = OUTPUT_FLAC;
break;
default:
@@ -185,9 +186,9 @@
inpath.setFullPath(argv[first_arg]);
- input = fopen(inpath.getFullPath(), "rb");
+ input = fopen(inpath.getFullPath().c_str(), "rb");
if (!input) {
- error("Cannot open file: %s", inpath.getFullPath());
+ error("Cannot open file: %s", inpath.getFullPath().c_str());
}
output_idx = fopen(TEMP_IDX, "wb");
@@ -206,7 +207,7 @@
}
while (1)
- get_part(inpath.getFullPath());
+ get_part(inpath.getFullPath().c_str());
return 0;
}
Modified: tools/branches/gsoc2009-gui/compress_sword1.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_sword1.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_sword1.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -349,7 +349,7 @@
}
}
-uint8 *convertData(uint8 *rawData, uint32 rawSize, CompressMode compMode, uint32 *resSize) {
+uint8 *convertData(uint8 *rawData, uint32 rawSize, AudioFormat compMode, uint32 *resSize) {
FILE *temp;
uint8 *resBuf;
@@ -368,7 +368,7 @@
return resBuf;
}
-void convertClu(FILE *clu, FILE *cl3, CompressMode compMode) {
+void convertClu(FILE *clu, FILE *cl3, AudioFormat compMode) {
uint32 *cowHeader;
uint32 numRooms;
uint32 numSamples;
@@ -434,33 +434,29 @@
free(cowHeader);
}
-void compressSpeech(CompressMode compMode, const Filename *inpath, const Filename *outpath) {
+void compressSpeech(AudioFormat compMode, const Filename *inpath, const Filename *outpath) {
FILE *clu, *cl3 = NULL;
int i;
char cluName[256], outName[256];
- char inputDir[256], outDir[256];
- inpath->getPath(inputDir);
- outpath->getPath(outDir);
-
setRawAudioType(true, false, 16);
for (i = 1; i <= 2; i++) {
- sprintf(cluName, "%s/SPEECH/SPEECH%d.CLU", inputDir, i);
+ sprintf(cluName, "%s/SPEECH/SPEECH%d.CLU", inpath->getPath().c_str(), i);
clu = fopen(cluName, "rb");
if (!clu) {
printf("Unable to open \"SPEECH%d.CLU\".\n", i);
printf("Please copy the \"SPEECH.CLU\" from CD %d\nand rename it to \"SPEECH%d.CLU\".\n", i, i);
} else {
switch (compMode) {
- case kMP3Mode:
- sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outDir, i, "CL3");
+ case AUDIO_MP3:
+ sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outpath->getPath().c_str(), i, "CL3");
break;
- case kVorbisMode:
- sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outDir, i, "CLV");
+ case AUDIO_VORBIS:
+ sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outpath->getPath().c_str(), i, "CLV");
break;
- case kFlacMode:
- sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outDir, i, "CLF");
+ case AUDIO_FLAC:
+ sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outpath->getPath().c_str(), i, "CLF");
break;
default:
error("Unknown encoding method");
@@ -484,17 +480,13 @@
unlink(tempOutName);
}
-void compressMusic(CompressMode compMode, const Filename *inpath, const Filename *outpath) {
+void compressMusic(AudioFormat compMode, const Filename *inpath, const Filename *outpath) {
int i;
FILE *inf;
char fNameIn[256], fNameOut[256];
- char inputDir[256], outDir[256];
- inpath->getPath(inputDir);
- outpath->getPath(outDir);
-
for (i = 0; i < TOTAL_TUNES; i++) {
- sprintf(fNameIn, "%s/MUSIC/%s.WAV", inputDir, musicNames[i].fileName);
+ sprintf(fNameIn, "%s/MUSIC/%s.WAV", inpath->getPath().c_str(), musicNames[i].fileName);
inf = fopen(fNameIn, "rb");
if (!inf) {
@@ -505,14 +497,14 @@
fclose(inf);
switch (compMode) {
- case kMP3Mode:
- sprintf(fNameOut, "%s/MUSIC/%s.%s", outDir, musicNames[i].fileName, "MP3");
+ case AUDIO_MP3:
+ sprintf(fNameOut, "%s/MUSIC/%s.%s", outpath->getPath().c_str(), musicNames[i].fileName, "MP3");
break;
- case kVorbisMode:
- sprintf(fNameOut, "%s/MUSIC/%s.%s", outDir, musicNames[i].fileName, "OGG");
+ case AUDIO_VORBIS:
+ sprintf(fNameOut, "%s/MUSIC/%s.%s", outpath->getPath().c_str(), musicNames[i].fileName, "OGG");
break;
- case kFlacMode:
- sprintf(fNameOut, "%s/MUSIC/%s.%s", outDir, musicNames[i].fileName, "FLA");
+ case AUDIO_FLAC:
+ sprintf(fNameOut, "%s/MUSIC/%s.%s", outpath->getPath().c_str(), musicNames[i].fileName, "FLA");
break;
default:
error("Unknown encoding method");
@@ -527,14 +519,12 @@
void checkFilesExist(bool checkSpeech, bool checkMusic, const Filename *inpath) {
int i;
FILE *testFile;
- char fileName[256], inputDir[256];
+ char fileName[256];
bool speechFound = false, musicFound = false;
- inpath->getPath(inputDir);
-
if (checkSpeech) {
for (i = 1; i <= 2; i++) {
- sprintf(fileName, "%s/SPEECH/SPEECH%d.CLU", inputDir, i);
+ sprintf(fileName, "%s/SPEECH/SPEECH%d.CLU", inpath->getPath().c_str(), i);
testFile = fopen(fileName, "rb");
if (testFile){
@@ -555,7 +545,7 @@
if (checkMusic) {
for (i = 0; i < 20; i++) { /* Check the first 20 music files */
- sprintf(fileName, "%s/MUSIC/%s.WAV", inputDir, musicNames[i].fileName);
+ sprintf(fileName, "%s/MUSIC/%s.WAV", inpath->getPath().c_str(), musicNames[i].fileName);
testFile = fopen(fileName, "rb");
if (testFile) {
@@ -587,7 +577,7 @@
" --music-only only encode music files\n"
kCompressionAudioHelp;
- CompressMode compMode = kMP3Mode;
+ AudioFormat compMode = AUDIO_MP3;
Filename inpath, outpath;
int first_arg = 1;
int last_arg = argc - 1;
@@ -608,7 +598,7 @@
// compression mode
compMode = process_audio_params(argc, argv, &first_arg);
- if (compMode == kNoAudioMode) {
+ if (compMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -621,13 +611,13 @@
last_arg -= 2;
switch(compMode) {
- case kMP3Mode:
+ case AUDIO_MP3:
tempOutName = TEMP_MP3;
break;
- case kVorbisMode:
+ case AUDIO_VORBIS:
tempOutName = TEMP_OGG;
break;
- case kFlacMode:
+ case AUDIO_FLAC:
tempOutName = TEMP_FLAC;
break;
default:
Modified: tools/branches/gsoc2009-gui/compress_sword2.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_sword2.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_sword2.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -27,7 +27,7 @@
static FILE *input, *output_idx, *output_snd;
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
uint32 append_to_file(FILE *f1, const char *filename) {
FILE *f2;
@@ -87,13 +87,13 @@
last_arg -= 2;
switch(gCompMode) {
- case kMP3Mode:
+ case AUDIO_MP3:
tempEncoded = TEMP_MP3;
break;
- case kVorbisMode:
+ case AUDIO_VORBIS:
tempEncoded = TEMP_OGG;
break;
- case kFlacMode:
+ case AUDIO_FLAC:
tempEncoded = TEMP_FLAC;
break;
default:
@@ -107,9 +107,9 @@
// Extensions change between the in/out files, so we can use the same directory
outpath = inpath;
- input = fopen(inpath.getFullPath(), "rb");
+ input = fopen(inpath.getFullPath().c_str(), "rb");
if (!input) {
- error("Cannot open file: %s", inpath.getFullPath());
+ error("Cannot open file: %s", inpath.getFullPath().c_str());
}
indexSize = readUint32LE(input);
@@ -220,9 +220,9 @@
fclose(output_idx);
fclose(output_snd);
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output) {
- error("Cannot open file %s for writing", outpath.getFullPath());
+ error("Cannot open file %s for writing", outpath.getFullPath().c_str());
}
append_to_file(output, TEMP_IDX);
Modified: tools/branches/gsoc2009-gui/compress_touche.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_touche.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_touche.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -1,3 +1,5 @@
+
+
/* compress_touche - Compress Touche Speech Data Files
* Copyright (C) 2006 The ScummVM Team
*
@@ -32,7 +34,7 @@
#define OUTPUT_OGG "TOUCHE.SOG"
#define OUTPUT_FLA "TOUCHE.SOF"
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
static uint32 input_OBJ_offs[OBJ_HDR_LEN];
static uint32 input_OBJ_size[OBJ_HDR_LEN];
@@ -104,9 +106,9 @@
uint32 current_offset;
uint32 offsets_table[MAX_OFFSETS];
- output = fopen(outpath->getFullPath(), "wb");
+ output = fopen(outpath->getFullPath().c_str(), "wb");
if (!output) {
- error("Cannot open file '%s' for writing", outpath->getFullPath());
+ error("Cannot open file '%s' for writing", outpath->getFullPath().c_str());
}
writeUint16LE(output, 1); /* current version */
@@ -123,7 +125,7 @@
/* process 'OBJ' file */
inpath->setFullName("OBJ");
- input = fopen(inpath->getFullPath(), "rb");
+ input = fopen(inpath->getFullPath().c_str(), "rb");
if (!input) {
error("Cannot open file 'OBJ' for reading");
}
@@ -131,7 +133,7 @@
offsets_table[0] = current_offset;
current_offset = compress_sound_data_file(current_offset, output, input, input_OBJ_offs, input_OBJ_size, OBJ_HDR_LEN);
fclose(input);
- printf("Processed '%s'.\n", inpath->getFullPath());
+ printf("Processed '%s'.\n", inpath->getFullPath().c_str());
/* process Vxx files */
for (i = 1; i < MAX_OFFSETS; ++i) {
@@ -140,12 +142,12 @@
sprintf(d, "V%d", i);
inpath->setFullName(d);
- input = fopen(inpath->getFullPath(), "rb");
+ input = fopen(inpath->getFullPath().c_str(), "rb");
if (input) {
offsets_table[i] = current_offset;
current_offset = compress_sound_data_file(current_offset, output, input, input_Vxx_offs, input_Vxx_size, Vxx_HDR_LEN);
fclose(input);
- printf("Processed '%s'.\n", inpath->getFullPath());
+ printf("Processed '%s'.\n", inpath->getFullPath().c_str());
}
}
@@ -177,7 +179,7 @@
// compression mode
gCompMode = process_audio_params(argc, argv, &first_arg);
- if (gCompMode == kNoAudioMode) {
+ if (gCompMode == AUDIO_NONE) {
// Unknown mode (failed to parse arguments), display help and exit
displayHelp(helptext, argv[0]);
}
@@ -190,13 +192,13 @@
last_arg -= 2;
else {
switch(gCompMode) {
- case kMP3Mode:
+ case AUDIO_MP3:
outpath.setFullName(OUTPUT_MP3);
break;
- case kVorbisMode:
+ case AUDIO_VORBIS:
outpath.setFullName(OUTPUT_OGG);
break;
- case kFlacMode:
+ case AUDIO_FLAC:
outpath.setFullName(OUTPUT_FLA);
break;
default:
@@ -209,7 +211,7 @@
// Append '/' if it's not already done
// TODO: We need a way to detect a directory here!
- size_t s = strlen(inpath._path);
+ size_t s = inpath._path.size();
if (inpath._path[s-1] == '/' || inpath._path[s-1] == '\\') {
inpath._path[s] = '/';
inpath._path[s+1] = '\0';
Modified: tools/branches/gsoc2009-gui/compress_tucker.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_tucker.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/compress_tucker.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -30,7 +30,7 @@
#define OUTPUT_OGG "TUCKER.SOG"
#define OUTPUT_FLA "TUCKER.SOF"
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
struct CompressedData {
int offset;
@@ -96,19 +96,16 @@
static uint32 compress_sounds_directory(const Filename *inpath, const Filename *outpath, FILE *output, const struct SoundDirectory *dir) {
char filepath[1024];
- char inputDir[1024];
char *filename;
//struct stat s;
int i, pos;
uint32 current_offset;
FILE *input;
- inpath->getPath(inputDir);
-
assert(dir->count <= ARRAYSIZE(temp_table));
// We can't use setFullName since dir->name can contain '/'
- snprintf(filepath, sizeof(filepath), "%s/%s", inputDir, dir->name);
+ snprintf(filepath, sizeof(filepath), "%s/%s", inpath->getPath().c_str(), dir->name);
/* stat is NOT standard C, but rather a POSIX call and fails under MSVC
* this could be factored out to Filename::isDirectory ?
if (stat(filepath, &s) != 0 || !S_ISDIR(s.st_mode)) {
@@ -392,9 +389,6 @@
char entry_name[13];
bool is_16LE;
- char inputDir[1024];
- inpath->getPath(inputDir);
-
assert(ARRAYSIZE(audio_wav_fileslist) == AUDIO_WAV_COUNT);
pos = ftell(output);
@@ -412,7 +406,7 @@
temp_table[i].offset = current_offset;
switch (index) {
case 0: /* .wav */
- sprintf(filepath, "%s/audio/%s", inputDir, audio_wav_fileslist[i]);
+ sprintf(filepath, "%s/audio/%s", inpath->getPath().c_str(), audio_wav_fileslist[i]);
input = fopen(filepath, "rb");
if (!input) {
error("Cannot open file '%s'", filepath);
@@ -424,7 +418,7 @@
is_16LE = bsearch(audio_raw_fileslist[i], audio_raw_fileslist_16LE,
ARRAYSIZE(audio_raw_fileslist_16LE), sizeof(const char *), cmp_helper) != NULL;
temp_table[i].offset = current_offset;
- sprintf(filepath, "%s/audio/%s", inputDir, audio_raw_fileslist[i]);
+ sprintf(filepath, "%s/audio/%s", inpath->getPath().c_str(), audio_raw_fileslist[i]);
input = fopen(filepath, "rb");
if (input) {
fclose(input);
@@ -459,9 +453,9 @@
uint32 audio_directory_size[AUDIO_TYPES_COUNT];
const uint16 flags = 0; // HEADER_FLAG_AUDIO_INTRO;
- output = fopen(outpath->getFullPath(), "wb");
+ output = fopen(outpath->getFullPath().c_str(), "wb");
if (!output) {
- error("Cannot open file '%s' for writing", outpath->getFullPath());
+ error("Cannot open file '%s' for writing", outpath->getFullPath().c_str());
}
writeUint16LE(output, CURRENT_VER);
@@ -549,15 +543,15 @@
// Temporary output file
switch(gCompMode) {
- case kMP3Mode:
+ case AUDIO_MP3:
tempEncoded = TEMP_MP3;
outpath.setFullName(OUTPUT_MP3);
break;
- case kVorbisMode:
+ case AUDIO_VORBIS:
tempEncoded = TEMP_OGG;
outpath.setFullName(OUTPUT_OGG);
break;
- case kFlacMode:
+ case AUDIO_FLAC:
tempEncoded = TEMP_FLAC;
outpath.setFullName(OUTPUT_FLA);
break;
Modified: tools/branches/gsoc2009-gui/encode_dxa.cpp
===================================================================
--- tools/branches/gsoc2009-gui/encode_dxa.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/encode_dxa.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -38,7 +38,7 @@
#define BLOCKW 4
#define BLOCKH 4
-static CompressMode gCompMode = kMP3Mode;
+static AudioFormat gCompMode = AUDIO_MP3;
enum ScaleMode { S_NONE, S_INTERLACED, S_DOUBLE };
@@ -625,9 +625,9 @@
void readVideoInfo(Filename *filename, int &width, int &height, int &framerate, int &frames,
ScaleMode &scaleMode) {
- FILE *smk = fopen(filename->getFullPath(), "rb");
+ FILE *smk = fopen(filename->getFullPath().c_str(), "rb");
if (!smk) {
- error("readVideoInfo: Cannot open file: %s", filename->getFullPath());
+ error("readVideoInfo: Cannot open file: %s", filename->getFullPath().c_str());
}
scaleMode = S_NONE;
@@ -677,7 +677,7 @@
printf("Encoding audio...");
fflush(stdout);
- encodeAudio(inpath->getFullPath(), false, -1, outpath->getFullPath(), gCompMode);
+ encodeAudio(inpath->getFullPath().c_str(), false, -1, outpath->getFullPath().c_str(), gCompMode);
}
@@ -718,8 +718,8 @@
Filename wavpath(inpath);
wavpath.setExtension(".wav");
struct stat statinfo;
- if (!stat(wavpath.getFullPath(), &statinfo)) {
- outpath.setExtension(audio_extensions[gCompMode]);
+ if (!stat(wavpath.getFullPath().c_str(), &statinfo)) {
+ outpath.setExtension(audio_extensions(gCompMode));
convertWAV(&wavpath, &outpath);
}
@@ -731,7 +731,7 @@
// create the encoder object
outpath.setExtension(".dxa");
- DxaEncoder dxe(outpath.getFullPath(), width, height, framerate, scaleMode);
+ DxaEncoder dxe(outpath.getFullPath().c_str(), width, height, framerate, scaleMode);
// No sound block
dxe.writeNULL();
@@ -744,7 +744,7 @@
fflush(stdout);
char fullname[1024];
- strcpy(fullname, inpath.getFullPath());
+ strcpy(fullname, inpath.getFullPath().c_str());
for (int f = 0; f < frames; f++) {
char strbuf[1024];
if (frames > 999)
@@ -757,7 +757,7 @@
sprintf(strbuf, "%s%d.png", fullname, framenum);
inpath.setFullName(strbuf);
- int r = read_png_file(inpath.getFullPath(), image, palette, width, height);
+ int r = read_png_file(inpath.getFullPath().c_str(), image, palette, width, height);
if (!palette) {
error("8-bit 256-color image expected");
Modified: tools/branches/gsoc2009-gui/extract_agos.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_agos.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_agos.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -25,9 +25,40 @@
#include <string.h>
#include <iostream>
-#include "util.h"
+#include "extract_agos.h"
-size_t filelen;
+ExtractAgos::ExtractAgos(const std::string &name) : Tool(name) {
+ _filelen = 0;
+
+ _helptext = "\nUsage: " + _name + " [-o outputname] infilename\n";
+}
+
+// Run the actual tool
+void ExtractAgos::execute() {
+ // Loop through all input files
+ for (std::vector<std::string>::const_iterator iter = _inputPaths.begin(); iter != _inputPaths.end(); ++iter) {
+ Filename infilename(*iter);
+ uint8 *x = (uint8 *)loadfile(infilename);
+
+ _outputPath.setFullName(infilename.getFullName());
+
+ uint32 decrlen = simon_decr_length(x, (uint32) _filelen);
+ uint8 *out = (uint8 *)malloc(decrlen);
+
+ if (out) {
+ if (simon_decr(x, out, _filelen)) {
+ savefile(_outputPath.getFullPath(), out, decrlen);
+ }
+ else {
+ print("%s: decrunch error\n", iter->c_str());
+ }
+
+ free(x);
+ free(out);
+ }
+ }
+}
+
#define EndGetM32(a) ((((a)[0])<<24)|(((a)[1])<<16)|(((a)[2])<<8)|((a)[3]))
#define SD_GETBIT(var) do { \
@@ -42,7 +73,7 @@
#define SD_TYPE_LITERAL (0)
#define SD_TYPE_MATCH (1)
-int simon_decr(uint8 *src, uint8 *dest, uint32 srclen) {
+int ExtractAgos::simon_decr(uint8 *src, uint8 *dest, uint32 srclen) {
uint8 *s = &src[srclen - 4];
uint32 destlen = EndGetM32(s);
uint32 bb, x, y;
@@ -132,7 +163,7 @@
return 1;
}
-uint32 simon_decr_length(uint8 *src, uint32 srclen) {
+uint32 ExtractAgos::simon_decr_length(uint8 *src, uint32 srclen) {
return EndGetM32(&src[srclen - 4]);
}
@@ -145,15 +176,15 @@
*
* @param name The name of the file to be loaded
*/
-void *loadfile(const Filename &name) {
+void *ExtractAgos::loadfile(const Filename &name) {
File file(name, FILEMODE_READ);
// Using global here is not pretty
- filelen = file.size();
+ _filelen = file.size();
void *mem = malloc(file.size());
// Read data
- file.read(file, 1, filelen);
+ file.read(file, 1, _filelen);
return mem;
}
@@ -166,71 +197,14 @@
* @param mem Where to get data from
* @param length How many bytes to write
*/
-void savefile(const Filename &name, void *mem, size_t length) {
+void ExtractAgos::savefile(const Filename &name, void *mem, size_t length) {
File file(name, FILEMODE_WRITE);
file.write(mem, 1, length);
}
-// Run the actual tool
-int run(int argc, char *argv[]) {
- int first_arg = 1;
- int last_arg = argc;
-
- Filename inpath, outpath;
-
- // Check if we should display some helpful text
- parseHelpArguments(argv, argc);
-
- // Now we try to find the proper output directory
- // also make sure we skip those arguments
- if (parseOutputDirectoryArguments(&outpath, argv, argc, first_arg))
- first_arg += 2;
- else if (parseOutputDirectoryArguments(&outpath, argv, argc, last_arg - 2))
- last_arg -= 2;
- else
- // Standard output dir
- outpath.setFullPath("out/");
-
- // Loop through all input files
- for (int parsed_args = first_arg; parsed_args <= last_arg; ++parsed_args) {
- const char *filename = argv[parsed_args];
- uint8 *x = (uint8 *)loadfile(filename);
-
- inpath.setFullPath(filename);
- outpath.setFullName(inpath.getFullName());
-
- uint32 decrlen = simon_decr_length(x, (uint32) filelen);
- uint8 *out = (uint8 *) malloc(decrlen);
-
- if (out) {
- if (simon_decr(x, out, filelen)) {
- savefile(outpath.getFullPath(), out, decrlen);
- }
- else {
- notice("%s: decrunch error\n", filename);
- }
-
- free((void *) x);
- }
- }
-
- return 0;
-}
-
-int export_main(extract_agos)(int argc, char *argv[]) {
- try {
- run(argc, argv);
- } catch(ToolException &err) {
- std::cout << "FATAL ERROR: " << err.what();
- return err._retcode;
- }
- return 0;
-}
-
-#if defined(UNIX) && defined(EXPORT_MAIN)
-int main(int argc, char *argv[]) __attribute__((weak));
+#ifdef STANDALONE_MAIN
int main(int argc, char *argv[]) {
- return export_main(extract_agos)(argc, argv);
+ ExtractAgos agos(argv[0]);
+ return agos.run(argc, argv);
}
#endif
-
Added: tools/branches/gsoc2009-gui/extract_agos.h
===================================================================
--- tools/branches/gsoc2009-gui/extract_agos.h (rev 0)
+++ tools/branches/gsoc2009-gui/extract_agos.h 2009-07-04 01:07:12 UTC (rev 42082)
@@ -0,0 +1,43 @@
+/* extract_gob_stk.h - Extracts the packed files used in the Amiga and AtariST versions
+ * Copyright (C) 2009 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL
+ * $Id
+ *
+ */
+
+#ifndef EXTRACT_AGOS_H
+#define EXTRACT_AGOS_H
+
+#include "tool.h"
+
+class ExtractAgos : public Tool {
+public:
+ ExtractAgos(const std::string &name = "extract_agos");
+
+ virtual void execute();
+
+protected:
+ size_t _filelen;
+
+ int simon_decr(uint8 *src, uint8 *dest, uint32 srclen);
+ uint32 simon_decr_length(uint8 *src, uint32 srclen);
+ void *loadfile(const Filename &name);
+ void savefile(const Filename &name, void *mem, size_t length);
+};
+
+#endif
Property changes on: tools/branches/gsoc2009-gui/extract_agos.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: tools/branches/gsoc2009-gui/extract_gob_stk.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_gob_stk.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_gob_stk.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -21,6 +21,8 @@
*/
#include "util.h"
+#include "extract_gob_stk.h"
+
#define confSTK21 "STK21"
#define confSTK10 "STK10"
@@ -36,97 +38,68 @@
~Chunk() { delete next; }
};
-void reportExtractionError(FILE *f1, FILE *f2, Chunk *chunks, const char *msg);
-Chunk *readChunkList(FILE *stk, FILE *gobConf);
-Chunk *readChunkListV2(FILE *stk, FILE *gobConf);
-void extractChunks(Filename *outpath, FILE *stk, Chunk *chunks);
-byte *unpackData(byte *src, uint32 &size);
-byte *unpackPreGobData(byte *src, uint32 &size, uint32 &compSize);
+ExtractGobStk::ExtractGobStk(const std::string &name) : Tool(name) {
+ _chunks = NULL;
-int export_main(extract_gob_stk)(int argc, char *argv[]) {
- char signature[7];
- Chunk *chunks;
- FILE *stk;
- FILE *gobConf;
+ _helptext = "\nUsage: " + _name + " [-o outputname] infilename\n";
+}
- int first_arg = 1;
- int last_arg = argc - 1;
+ExtractGobStk::~ExtractGobStk() {
+ delete _chunks;
+}
- Filename inpath, outpath;
+void ExtractGobStk::execute() {
+ char signature[7];
+ File stk;
+ File gobConf;
- // Check if we should display some helpful text
- parseHelpArguments(argv, argc);
-
- // Continuing with finding out output directory
- // also make sure we skip those arguments
- if (parseOutputDirectoryArguments(&outpath, argv, argc, first_arg))
- first_arg += 2;
- else if (parseOutputDirectoryArguments(&outpath, argv, argc, last_arg - 2))
- last_arg -= 2;
- else
- outpath.setFullPath("./");
+ File f1;
+ File f2;
+ std::auto_ptr<Chunk> _chunk;
-
// We only got one input file
- if (last_arg != first_arg)
+ if (_inputPaths.size() > 1)
error("Only one input file expected!");
+ Filename inpath(_inputPaths[0]);
- inpath.setFullPath(argv[first_arg]);
+ stk.open(inpath.getFullPath(), "rb");
- if (!(stk = fopen(inpath.getFullPath(), "rb")))
- error("Couldn't open file \"%s\"", inpath.getFullPath());
-
- if (outpath.empty())
- outpath = inpath;
+ if (_outputPath.empty())
+ _outputPath = inpath;
else
- outpath.setFullName(inpath.getFullName());
- outpath.setExtension(".gob");
+ _outputPath.setFullName(inpath.getFullName());
- if (!(gobConf = fopen(outpath.getFullPath(), "w")))
- error("Couldn't create config file \"%s\"", outpath.getFullPath());
+ _outputPath.setExtension(".gob");
- if (fread(signature, 1, 6, stk) < 6)
- error("Unexpected EOF while reading signature in \"%s\"", inpath.getFullPath());
+ gobConf.open(_outputPath.getFullPath(), "w");
+ stk.read(signature, 1, 6);
+
if (strncmp(signature, "STK2.1", 6) == 0) {
- warning("Signature of new STK format (STK 2.1) detected in file \"%s\"", inpath.getFullPath());
+ print("Signature of new STK format (STK 2.1) detected in file \"%s\"", inpath.getFullPath());
fprintf(gobConf, "%s\n", confSTK21);
- chunks = readChunkListV2(stk, gobConf);
+ readChunkListV2(stk, gobConf);
} else {
fprintf(gobConf, "%s\n", confSTK10);
rewind(stk);
- chunks = readChunkList(stk, gobConf);
+ readChunkList(stk, gobConf);
}
- fclose(gobConf);
-
- extractChunks(&outpath, stk, chunks);
-
- delete chunks;
- fclose(stk);
-
- return 0;
+ extractChunks(_outputPath, stk);
}
-void reportExtractionError(FILE *f1, FILE *f2, Chunk *chunks, const char *msg) {
- if (f1)
- fclose(f1);
- if (f2)
- fclose(f2);
- delete chunks;
-
- error(msg);
-}
-
-Chunk *readChunkList(FILE *stk, FILE *gobConf) {
+void ExtractGobStk::readChunkList(File &stk, File &gobConf) {
uint16 numDataChunks = readUint16LE(stk);
- Chunk *chunks = new Chunk;
- Chunk *curChunk = chunks;
+
+ // If we are run multiple times, free previous chunk list
+ if(_chunks)
+ delete _chunks;
+ _chunks = new Chunk;
+ Chunk *curChunk = _chunks;
char *fakeTotPtr;
while (numDataChunks-- > 0) {
- if (fread(curChunk->name, 1, 13, stk) < 13)
- reportExtractionError(stk, gobConf, chunks, "Unexpected EOF");
+ stk.read(curChunk->name, 1, 13);
curChunk->size = readUint32LE(stk);
curChunk->offset = readUint32LE(stk);
@@ -149,14 +122,12 @@
curChunk = curChunk->next;
}
}
-
- return chunks;
}
-Chunk *readChunkListV2(FILE *stk, FILE *gobConf) {
+void ExtractGobStk::readChunkListV2(File &stk, File &gobConf) {
uint32 numDataChunks;
- Chunk *chunks = new Chunk;
- Chunk *curChunk = chunks;
+ _chunks = new Chunk;
+ Chunk *curChunk = _chunks;
// char *fakeTotPtr;
@@ -177,18 +148,17 @@
// + 08 bytes : Name / acronym of STK/ITK creator
// + 04 bytes : Start position of Filenames Section
- if (fread(buffer, 1, 14, stk) < 14)
- reportExtractionError(stk, gobConf, chunks, "Unexpected EOF");
+ stk.read(buffer, 1, 14);
buffer[14] = '\0';
sprintf(debugStr, "File generated on %s by ", buffer);
if (fread(buffer, 1, 8, stk) < 8)
- reportExtractionError(stk, gobConf, chunks, "Unexpected EOF");
+ throw ToolException("Unexpected EOF");
buffer[8] = '\0';
strcat(debugStr, buffer);
- printf("%s\n",debugStr);
+ print("%s\n",debugStr);
filenamePos = readUint32LE(stk);
// Filenames - Header
@@ -197,14 +167,13 @@
// + 04 bytes : Number of files stored in STK/ITK
// + 04 bytes : Start position of Misc Section
- if (fseek(stk, filenamePos, SEEK_SET) != 0)
- reportExtractionError(stk, gobConf, chunks, "Unable to locate Filename Section");
+ stk.seek(filenamePos, SEEK_SET);
numDataChunks = readUint32LE(stk);
miscPos = readUint32LE(stk);
if (numDataChunks == 0)
- reportExtractionError(stk, gobConf, chunks, "Empty ITK/STK !");
+ throw ToolException("Empty ITK/STK !");
while (numDataChunks-- > 0) {
// Misc
@@ -223,16 +192,16 @@
// + 04 bytes : Compression flag (AFAIK : 0= uncompressed, 1= compressed)
if (fseek(stk, miscPos + (cpt * 61), SEEK_SET) != 0)
- reportExtractionError(stk, gobConf, chunks, "Unable to locate Misc Section");
+ throw ToolException("Unable to locate Misc Section");
filenamePos = readUint32LE(stk);
if (fread(buffer, 1, 36, stk) < 36)
- reportExtractionError(stk, gobConf, chunks, "Unexpected EOF in Misc Section");
+ throw ToolException("Unexpected EOF in Misc Section");
curChunk->size = readUint32LE(stk);
decompSize = readUint32LE(stk);
if (fread(buffer, 1, 5, stk) < 5)
- reportExtractionError(stk, gobConf, chunks, "Unexpected EOF in Misc Section");
+ throw ToolException("Unexpected EOF in Misc Section");
filePos = readUint32LE(stk);
compressFlag = readUint32LE(stk);
@@ -244,7 +213,7 @@
sprintf(debugStr,
"Unexpected value in compress flag : %d - Size : %d Uncompressed size : %d",
compressFlag, curChunk->size, decompSize);
- reportExtractionError(stk, gobConf, chunks, debugStr);
+ throw ToolException(debugStr);
} else {
curChunk->packed=false;
}
@@ -256,10 +225,10 @@
// Those are now long filenames, at the opposite of previous STK version.
if (fseek(stk, filenamePos, SEEK_SET) != 0)
- reportExtractionError(stk, gobConf, chunks, "Unable to locate filename");
+ throw ToolException("Unable to locate filename");
if (fgets(curChunk->name, 64, stk) == 0)
- reportExtractionError(stk, gobConf, chunks, "Unable to read filename");
+ throw ToolException("Unable to read filename");
// Files
// =====
@@ -279,58 +248,54 @@
}
cpt++;
}
-
- return chunks;
}
-void extractChunks(Filename *outpath, FILE *stk, Chunk *chunks) {
- Chunk *curChunk = chunks;
- byte *unpackedData;
+void ExtractGobStk::extractChunks(Filename &outpath, File &stk) {
+ Chunk *curChunk = _chunks;
+ byte *unpackedData = NULL;
while (curChunk != 0) {
- printf("Extracting \"%s\"\n", curChunk->name);
+ print("Extracting \"%s\"\n", curChunk->name);
- FILE *chunkFile;
- outpath->setFullName(curChunk->name);
- if (!(chunkFile = fopen(outpath->getFullPath(), "wb")))
- reportExtractionError(stk, 0, chunks, "Couldn't write file");
+ outpath.setFullName(curChunk->name);
+ File chunkFile(outpath, "wb");
- if (fseek(stk, curChunk->offset, SEEK_SET) == -1)
- reportExtractionError(stk, chunkFile, chunks, "Unexpected EOF");
+ chunkFile.seek(curChunk->offset, SEEK_SET);
byte *data = new byte[curChunk->size];
- if (fread((char *) data, curChunk->size, 1, stk) < 1)
- reportExtractionError(stk, chunkFile, chunks, "Unexpected EOF");
+ stk.read((char *) data, curChunk->size, 1);
- if (curChunk->packed) {
- uint32 realSize;
+ try {
+ if (curChunk->packed) {
+ uint32 realSize;
- if (curChunk->preGob) {
- unpackedData = unpackPreGobData(data, realSize, curChunk->size);
- } else {
- unpackedData = unpackData(data, realSize);
- }
+ if (curChunk->preGob) {
+ unpackedData = unpackPreGobData(data, realSize, curChunk->size);
+ } else {
+ unpackedData = unpackData(data, realSize);
+ }
- if (fwrite((char *) unpackedData, realSize, 1, chunkFile) < 1)
- reportExtractionError(stk, chunkFile, chunks, "Couldn't write");
+ chunkFile.write((char *) unpackedData, realSize, 1);
+ delete[] unpackedData;
+ } else {
+ chunkFile.write((char *) data, curChunk->size, 1);
+ }
+ } catch(...) {
+ delete[] data;
delete[] unpackedData;
-
- } else {
- if (fwrite((char *) data, curChunk->size, 1, chunkFile) < 1)
- reportExtractionError(stk, chunkFile, chunks, "Couldn't write");
+ throw;
}
delete[] data;
- fclose(chunkFile);
curChunk = curChunk->next;
}
}
// Some LZ77-variant
-byte *unpackData(byte *src, uint32 &size) {
+byte *ExtractGobStk::unpackData(byte *src, uint32 &size) {
uint32 counter;
uint16 cmd;
byte tmpBuf[4114];
@@ -389,7 +354,7 @@
}
// Some LZ77-variant
-byte *unpackPreGobData(byte *src, uint32 &size, uint32 &compSize) {
+byte *ExtractGobStk::unpackPreGobData(byte *src, uint32 &size, uint32 &compSize) {
uint16 cmd;
byte tmpBuf[4114];
int16 off;
@@ -410,9 +375,9 @@
// - bytes 2&3 : Either the real size or 0x007D. Directly related to the size of the file.
// - bytes 4&5 : 0x0000 (files are small) ;)
if (dummy1 == 0xFFFF)
- printf("Real size %d\n", READ_LE_UINT32(src));
+ print("Real size %d\n", READ_LE_UINT32(src));
else
- printf("Unknown real size %xX %xX\n", dummy1>>8, dummy1 & 0x00FF);
+ print("Unknown real size %xX %xX\n", dummy1>>8, dummy1 & 0x00FF);
// counter = size = READ_LE_UINT32(src);
@@ -471,10 +436,10 @@
return unpacked;
}
-#if defined(UNIX) && defined(EXPORT_MAIN)
-int main(int argc, char *argv[]) __attribute__((weak));
+#ifdef STANDALONE_MAIN
int main(int argc, char *argv[]) {
- return export_main(extract_gob_stk)(argc, argv);
+ ExtractGobStk gob_stk(argv[0]);
+ return gob_stk.run(argc, argv);
}
#endif
Added: tools/branches/gsoc2009-gui/extract_gob_stk.h
===================================================================
--- tools/branches/gsoc2009-gui/extract_gob_stk.h (rev 0)
+++ tools/branches/gsoc2009-gui/extract_gob_stk.h 2009-07-04 01:07:12 UTC (rev 42082)
@@ -0,0 +1,47 @@
+/* extract_gob_stk.h - Extractor for Coktel Vision game's .stk/.itk archives
+ * Copyright (C) 2009 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL
+ * $Id
+ *
+ */
+
+#ifndef EXTRACT_GOB_STK_H
+#define EXTRACT_GOB_STK_H
+
+#include "tool.h"
+
+struct Chunk;
+
+class ExtractGobStk : public Tool {
+public:
+ ExtractGobStk(const std::string &name = "extract_gob_stk");
+ ~ExtractGobStk();
+
+ virtual void execute();
+
+protected:
+ Chunk *_chunks;
+
+ void readChunkList(File &stk, File &gobConf);
+ void readChunkListV2(File &stk, File &gobConf);
+ void extractChunks(Filename &outpath, File &stk);
+ byte *unpackData(byte *src, uint32 &size);
+ byte *unpackPreGobData(byte *src, uint32 &size, uint32 &compSize);
+};
+
+#endif
Property changes on: tools/branches/gsoc2009-gui/extract_gob_stk.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: tools/branches/gsoc2009-gui/extract_kyra.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_kyra.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_kyra.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -88,12 +88,12 @@
inputpath.setFullPath(argv[param]);
Extractor *extract = 0;
if (isHoFInstaller) {
- extract = new HoFInstaller(inputpath.getFullPath());
+ extract = new HoFInstaller(inputpath.getFullPath().c_str());
} else {
PAKFile *myfile = new PAKFile;
- if (!myfile->loadFile(inputpath.getFullPath(), isAmiga)) {
+ if (!myfile->loadFile(inputpath.getFullPath().c_str(), isAmiga)) {
delete myfile;
- error("Couldn't load file '%s'", inputpath.getFullPath());
+ error("Couldn't load file '%s'", inputpath.getFullPath().c_str());
}
extract = myfile;
@@ -104,7 +104,7 @@
extract->outputAllFiles(&outpath);
} else if (extractOne) {
inputpath.setFullName(singleFilename);
- extract->outputFileAs(singleFilename, inputpath.getFullPath());
+ extract->outputFileAs(singleFilename, inputpath.getFullPath().c_str());
} else {
extract->drawFileList();
}
Modified: tools/branches/gsoc2009-gui/extract_loom_tg16.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_loom_tg16.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_loom_tg16.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -1282,7 +1282,7 @@
sprintf(fname, "%02i.LFL", lfl->num);
outpath.setFullName(fname);
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output)
error("unable to create %s", fname);
@@ -1319,7 +1319,7 @@
}
outpath.setFullName("00.LFL");
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output)
error("Unable to create index file!");
notice("Creating 00.LFL...");
@@ -1372,7 +1372,7 @@
fclose(output);
outpath.setFullName("97.LFL");
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output)
error("Unable to create charset file 97.LFL");
@@ -1381,7 +1381,7 @@
fclose(output);
outpath.setFullName("98.LFL");
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output)
error("Unable to create charset file 98.LFL");
notice("Creating 98.LFL...");
@@ -1389,7 +1389,7 @@
fclose(output);
outpath.setFullName("99.LFL");
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output)
error("Unable to create charset file 99.LFL");
notice("Creating 99.LFL...");
Modified: tools/branches/gsoc2009-gui/extract_mm_c64.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_mm_c64.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_mm_c64.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -97,7 +97,7 @@
error("Signature not found in disk 2!");
outpath.setFullName("00.LFL");
- if (!(output = fopen(outpath.getFullPath(), "wb")))
+ if (!(output = fopen(outpath.getFullPath().c_str(), "wb")))
error("Unable to create index file!");
notice("Creating 00.LFL...");
@@ -149,7 +149,7 @@
sprintf(fname, "%02i.LFL", i);
outpath.setFullName(fname);
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (output == NULL) {
error("Unable to create %s!", fname);
Modified: tools/branches/gsoc2009-gui/extract_mm_nes.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_mm_nes.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_mm_nes.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -1248,7 +1248,7 @@
sprintf(fname, "%02i.LFL", lfl->num);
outpath.setFullName(fname);
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output)
error("Unable to create %s", fname);
notice("Creating %s...", fname);
@@ -1319,7 +1319,7 @@
}
outpath.setFullName("00.LFL");
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (!output)
error("Unable to create index file");
notice("Creating 00.LFL...");
Modified: tools/branches/gsoc2009-gui/extract_parallaction.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_parallaction.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_parallaction.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -314,7 +314,7 @@
outpath->setFullName(d);
- FILE *ofile = fopen(outpath->getFullPath(), "wb");
+ FILE *ofile = fopen(outpath->getFullPath().c_str(), "wb");
fwrite(arc._fileData, 1, arc._fileSize, ofile);
fclose(ofile);
}
Modified: tools/branches/gsoc2009-gui/extract_scumm_mac.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_scumm_mac.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_scumm_mac.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -138,7 +138,7 @@
}
outpath.setFullName(file_name);
- ofp = fopen(outpath.getFullPath(), "wb");
+ ofp = fopen(outpath.getFullPath().c_str(), "wb");
if (!(buf = (char *)malloc(file_len))) {
fclose(ifp);
@@ -155,8 +155,9 @@
return 0;
}
+#if defined(UNIX) && defined(EXPORT_MAIN)
int main(int argc, char *argv[]) __attribute__((weak));
int main(int argc, char *argv[]) {
return export_main(extract_scumm_mac)(argc, argv);
}
-
+#endif
Modified: tools/branches/gsoc2009-gui/extract_zak_c64.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_zak_c64.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/extract_zak_c64.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -96,7 +96,7 @@
if (signature != 0x0132)
error("Signature not found in disk 2!");
outpath.setFullName("00.LFL");
- if (!(output = fopen(outpath.getFullPath(), "wb")))
+ if (!(output = fopen(outpath.getFullPath().c_str(), "wb")))
error("Unable to create index file!");
notice("Creating 00.LFL...");
@@ -151,7 +151,7 @@
sprintf(fname,"%02i.LFL", i);
outpath.setFullName(fname);
- output = fopen(outpath.getFullPath(), "wb");
+ output = fopen(outpath.getFullPath().c_str(), "wb");
if (output == NULL) {
error("Unable to create %s!", fname);
Modified: tools/branches/gsoc2009-gui/gui/configuration.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/configuration.h 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/gui/configuration.h 2009-07-04 01:07:12 UTC (rev 42082)
@@ -25,18 +25,9 @@
#include <wx/string.h>
-class Tool;
+#include "../util.h"
-/**
- * Different audio formats
- * You can bitwise them to represent several formats
- */
-enum AudioFormat {
- AUDIO_VORBIS = 1,
- AUDIO_FLAC = 2,
- AUDIO_MP3 = 4,
- AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
-};
+class ToolGUI;
/**
* Current state of the wizard
@@ -56,7 +47,7 @@
/** The name of the game we are extracting or compressing */
wxString selectedGame;
/** The tool the user chose to use, NULL if none has been chosen yet */
- const Tool* selectedTool;
+ const ToolGUI* selectedTool;
/** Input files selected */
wxArrayString inputFilePaths;
Modified: tools/branches/gsoc2009-gui/gui/main.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/gui/main.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -35,6 +35,7 @@
#include "main.h"
#include "pages.h"
+#include "tools.h"
class ScummVMToolsApp : public wxApp
{
@@ -45,10 +46,15 @@
bool ScummVMToolsApp::OnInit()
{
+ // Init tools
+ g_tools.init();
+
+ // Create window & display
ScummToolsFrame *frame = new ScummToolsFrame(wxT("ScummVM Tools"), wxDefaultPosition, wxSize(600,400));
frame->SetMinSize(wxSize(600, 400));
frame->Show(true);
SetTopWindow(frame);
+
return true;
}
Modified: tools/branches/gsoc2009-gui/gui/pages.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -304,7 +304,7 @@
sizer->AddSpacer(15);
- const Tool &tool = *_configuration.selectedTool;
+ const ToolGUI &tool = *_configuration.selectedTool;
// some help perhaps?
sizer->Add(new wxStaticText(panel, wxID_ANY, tool._inoutHelpText));
@@ -347,7 +347,7 @@
// Create output selection
- if (tool._outputToDirectory) {
+ if (tool.outputToDirectory()) {
wxStaticBoxSizer *box = new wxStaticBoxSizer(wxHORIZONTAL, panel, wxT("Destination folder"));
box->Add(new wxDirPickerCtrl(
@@ -378,14 +378,32 @@
void ChooseInOutPage::save(wxWindow *panel) {
wxWindow *outputWindow = panel->FindWindowByName(wxT("OutputPicker"));
wxDirPickerCtrl *outDirWindow = dynamic_cast<wxDirPickerCtrl *>(outputWindow);
- wxFilePickerCtrl *inDirWindow = dynamic_cast<wxFilePickerCtrl *>(outputWindow);
+ wxFilePickerCtrl *outFileWindow = dynamic_cast<wxFilePickerCtrl *>(outputWindow);
if (outDirWindow)
_configuration.outputPath = outDirWindow->GetPath();
- if (inDirWindow)
- _configuration.outputPath = inDirWindow->GetPath();
+ if (outFileWindow)
+ _configuration.outputPath = outFileWindow->GetPath();
- // TODO: save input, unsure of exact format
+ const ToolGUI &tool = *_configuration.selectedTool;
+
+ int i = 1;
+ for (ToolInputs::const_iterator iter = tool._inputs.begin(); iter != tool._inputs.end(); ++iter) {
+ const ToolInput &input = *iter;
+
+ wxString windowName = wxT("InputPicker");
+ windowName << i;
+
+ wxDirPickerCtrl *inDirWindow = dynamic_cast<wxDirPickerCtrl *>(panel->FindWindowByName(windowName));
+ wxFilePickerCtrl *inFileWindow = dynamic_cast<wxFilePickerCtrl *>(panel->FindWindowByName(windowName));
+
+ if (inDirWindow)
+ _configuration.inputFilePaths.Add(inDirWindow ->GetPath());
+ if (inFileWindow)
+ _configuration.inputFilePaths.Add(inFileWindow->GetPath());
+
+ ++i;
+ }
}
void ChooseInOutPage::onNext(wxWindow *panel) {
@@ -856,89 +874,22 @@
return panel;
}
-std::pair<int, char **> ProcessPage::createCommandLine() {
- Configuration &conf = _topframe->_configuration;
-
- // Contruct the arguments in unicode mode first
- wxArrayString cli;
-
- cli.Add(conf.selectedTool->getExecutable());
-
- // Audio format args
- if (conf.compressing) {
- cli.Add(wxT("--mp3"));
- if (conf.selectedAudioFormat == AUDIO_VORBIS) {
- cli.Add(wxT("--vorbis"));
- cli.Add(wxT("-b"));
- cli.Add(conf.oggAvgBitrate);
- cli.Add(wxT("-m"));
- cli.Add(conf.oggMinBitrate);
- cli.Add(wxT("-M"));
- cli.Add(conf.oggMaxBitrate);
- cli.Add(wxT("-q"));
- cli.Add(conf.oggQuality);
- } else if (conf.selectedAudioFormat == AUDIO_FLAC) {
- cli.Add(wxT("--flac"));
- cli.Add(wxT("-"));
- cli.Add(conf.flacCompressionLevel);
- cli.Add(wxT("-b"));
- cli.Add(conf.flacBlockSize);
- } else if (conf.selectedAudioFormat == AUDIO_MP3) {
- if (conf.mp3CompressionType == wxT("ABR")) {
- cli.Add(wxT("--abr"));
- cli.Add(wxT("-b"));
- cli.Add(conf.mp3ABRBitrate);
- cli.Add(wxT("-b"));
- cli.Add(conf.mp3VBRMinBitrate);
- } else {
- cli.Add(wxT("--vbr"));
- cli.Add(wxT("-b"));
- cli.Add(conf.mp3VBRMinBitrate);
- cli.Add(wxT("-B"));
- cli.Add(conf.mp3VBRMaxBitrate);
- }
-
- cli.Add(wxT("-q"));
- cli.Add(conf.mp3MpegQuality);
- }
- }
-
- cli.Add(wxT("-o"));
- cli.Add(conf.outputPath);
- for (wxArrayString::const_iterator iter = conf.inputFilePaths.begin(); iter != conf.inputFilePaths.end(); ++iter)
- cli.Add(*iter);
-
- // And now convert to a plain char * string
- char **real_cli = new char *[cli.size()];
- int i = 0;
- for (wxArrayString::const_iterator iter = cli.begin(); iter != cli.end(); ++iter, ++i) {
- const char *in = (const char *)iter->mb_str();
- real_cli[i] = new char[strlen(in)];
- strcpy(real_cli[i], in);
- }
-
- return std::make_pair(i, real_cli);
+void ProcessPage::writeToOutput(void *udata, const char *text) {
+ wxTextCtrl *outwin = reinterpret_cast<wxTextCtrl *>(udata);
+ outwin->WriteText(wxString(text, wxConvUTF8));
}
void ProcessPage::runTool(wxTextCtrl *outwin) {
- // Build command line arguments...
- std::pair<int, char **> cli = createCommandLine();
-
- // TODO
- // Redirect output
-
- // Run the tool
- int ret = _topframe->_configuration.selectedTool->invoke(cli.first, cli.second);
- _finished = true;
- _success = (ret == 0);
-
- // Free memory in use by the CLI args
- for (int i = 0; i != cli.first; ++i) {
- delete[] cli.second[i];
+ const ToolGUI *tool = _topframe->_configuration.selectedTool;
+ tool->_backend->setPrintFunction(writeToOutput, reinterpret_cast<void *>(outwin));
+ try {
+ tool->run();
+ _success = true;
+ } catch(std::exception &err) {
+ outwin->WriteText(wxString(err.what(), wxConvUTF8));
+ _success = false;
}
- delete[] cli.second;
-
- // Cancel output redirection
+ _finished = true;
}
bool ProcessPage::onIdle(wxPanel *panel) {
Modified: tools/branches/gsoc2009-gui/gui/pages.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.h 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/gui/pages.h 2009-07-04 01:07:12 UTC (rev 42082)
@@ -318,13 +318,9 @@
wxWindow *CreatePanel(wxWindow *parent);
/**
- * Creates a list of command line arguments
- * The list is allocated, and needed to be looped through and delete[] ed
- * and then the list itself delete[]ed
- *
- * @return A pair containing number of args, and the list of CLI args themselves
+ * Write to the output window pointed to by udata
*/
- std::pair<int, char **> createCommandLine();
+ static void writeToOutput(void *udata, const char *text);
/**
* Runs the specified tool, output will be put in outwin
Modified: tools/branches/gsoc2009-gui/gui/tools.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/gui/tools.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -34,10 +34,26 @@
#include "tools.h"
+// Include all tools
+#include "../extract_agos.h"
+#include "../extract_gob_stk.h"
+
+
+// Our global tools object, which holds all tools
Tools g_tools;
Tools::Tools() {
+}
+void Tools::init() {
+
+ // Compress agos also has a --mac parameter, need to add an additional page / option for this
+ addTool(new ToolGUI(new ExtractAgos()));
+
+ // extract_gob_stk
+ addTool(new ToolGUI(new ExtractGobStk()));
+
+ /* "Old" tool list, will be converted incrementally
// Compression tools
// Compress agos also has a --mac parameter, need to add an additional page / option for this
@@ -108,16 +124,6 @@
// Extraction tools
- // Compress agos also has a --mac parameter, need to add an additional page / option for this
- Tool extract_agos(wxT("extract_agos"), main_extract_agos, wxT("*."));
- extract_agos.addGame(wxT("Feeble Files")),
- extract_agos.addGame(wxT("Simon the Sorcerer I/II")),
- addTool(extract_agos);
-
- // extract_gob_stk
- Tool extract_gob_stk(wxT("extract_gob_stk"), main_extract_gob_stk, wxT("*.*"));
- addTool(extract_gob_stk);
-
// extract_kyra
Tool extract_kyra(wxT("extract_kyra"), main_extract_kyra, wxT("*.*"));
extract_kyra.addGame(wxT("The Legend of Kyrandia")),
@@ -161,16 +167,22 @@
Tool extract_zak_c64(wxT("extract_zak_c64"), main_extract_zak_c64, wxT(".d64"));
extract_zak_c64.addGame(wxT("Bud Tucker in Double Trouble")),
addTool(extract_zak_c64);
+ */
}
-void Tools::addTool(const Tool& tool) {
- tools[tool._name] = tool;
+Tools::~Tools() {
+ for (std::map<wxString, ToolGUI *>::iterator iter = tools.begin(); iter != tools.end(); ++iter)
+ delete iter->second;
}
+void Tools::addTool(ToolGUI* tool) {
+ tools[tool->_name] = tool;
+}
+
wxArrayString Tools::getToolList(ToolType tt) const {
wxArrayString l;
- for (std::map<wxString, Tool>::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
- if (tt == TOOLTYPE_ALL || iter->second._type == tt)
+ for (std::map<wxString, ToolGUI *>::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
+ if (tt == TOOLTYPE_ALL || iter->second->_type == tt)
l.Add(iter->first);
l.Sort();
std::unique(l.begin(), l.end());
@@ -179,56 +191,56 @@
wxArrayString Tools::getGameList(ToolType tt) const {
wxArrayString l;
- for (std::map<wxString, Tool>::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
- if (tt == TOOLTYPE_ALL || iter->second._type == tt)
- for (wxArrayString::const_iterator citer = iter->second._games.begin(); citer != iter->second._games.end(); ++citer)
+ for (std::map<wxString, ToolGUI *>::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
+ if (tt == TOOLTYPE_ALL || iter->second->_type == tt)
+ for (wxArrayString::const_iterator citer = iter->second->_games.begin(); citer != iter->second->_games.end(); ++citer)
l.Add(*citer);
l.Sort();
std::unique(l.begin(), l.end());
return l;
}
-const Tool &Tools::operator[](const wxString& name) const {
- std::map<wxString, Tool>::const_iterator iter = tools.find(name);
+const ToolGUI &Tools::operator[](const wxString& name) const {
+ std::map<wxString, ToolGUI *>::const_iterator iter = tools.find(name);
wxASSERT_MSG(iter != tools.end(), wxT("All tools should be added, never try to access a tool that does not exist."));
- return iter->second;
+ return *iter->second;
}
-const Tool *Tools::get(const wxString& name) const {
- std::map<wxString, Tool>::const_iterator iter = tools.find(name);
+const ToolGUI *Tools::get(const wxString& name) const {
+ std::map<wxString, ToolGUI *>::const_iterator iter = tools.find(name);
if (iter == tools.end())
return NULL;
- return &iter->second;
+ return iter->second;
}
-const Tool *Tools::getByGame(const wxString &gamename, ToolType type) const {
- for (std::map<wxString, Tool>::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
- if (type == TOOLTYPE_ALL || iter->second._type == type)
- for (wxArrayString::const_iterator citer = iter->second._games.begin(); citer != iter->second._games.end(); ++citer)
+const ToolGUI *Tools::getByGame(const wxString &gamename, ToolType type) const {
+ for (std::map<wxString, ToolGUI *>::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
+ if (type == TOOLTYPE_ALL || iter->second->_type == type)
+ for (wxArrayString::const_iterator citer = iter->second->_games.begin(); citer != iter->second->_games.end(); ++citer)
if (*citer == gamename)
- return &iter->second;
+ return iter->second;
return NULL;
}
// The Tool class
-Tool::Tool() {
+ToolGUI::ToolGUI() {
// Seems std is allowed to create dummy objects in maps.
//wxLogError(wxT("Created empty tool, should never happened."));
}
-Tool::Tool(wxString name, MainFunction main, wxString input_extensions) {
- _name = name;
- invoke = main;
+ToolGUI::ToolGUI(Tool *tool, wxString input_extensions) {
+ _backend = tool;
+ _name = wxString(tool->_name.c_str(), wxConvUTF8);
- if (name.Find(wxT("extract")) != wxNOT_FOUND)
+ if (_name.Find(wxT("extract")) != wxNOT_FOUND)
_type = TOOLTYPE_EXTRACTION;
- else if (name.Find(wxT("compress")) != wxNOT_FOUND)
+ else if (_name.Find(wxT("compress")) != wxNOT_FOUND)
_type = TOOLTYPE_COMPRESSION;
else {
wxLogError(wxT("Tools with unknown type shouldn't exist."));
@@ -236,25 +248,30 @@
}
// Sensible defaults
- _supportedFormats = AUDIO_ALL;
ToolInput input;
input._extension = input_extensions;
input._file = true;
_inputs.push_back(input);
- _outputToDirectory = true;
_inoutHelpText = wxT("Output files produced by the tool will be put in this directory.");
}
-void Tool::addGame(const wxString &game_name) {
+void ToolGUI::addGame(const wxString &game_name) {
_games.Add(game_name);
}
-bool Tool::supportsAudioFormat(AudioFormat format) const {
- return (_supportedFormats & format) == format;
+bool ToolGUI::supportsAudioFormat(AudioFormat format) const {
+ return (_backend->_supported_formats & format) == format;
}
-wxString Tool::getExecutable() const {
+bool ToolGUI::outputToDirectory() const {
+ return _backend->_outputToDirectory;
+}
+
+void ToolGUI::run() const {
+}
+
+wxString ToolGUI::getExecutable() const {
#ifdef WIN32
return _name + wxT(".exe");
#else
Modified: tools/branches/gsoc2009-gui/gui/tools.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.h 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/gui/tools.h 2009-07-04 01:07:12 UTC (rev 42082)
@@ -29,7 +29,7 @@
#include <vector>
#include "configuration.h"
-#include "../tool_entry_points.h"
+#include "../tool.h"
/** Different types of tools, used to differentiate them when
@@ -61,12 +61,15 @@
/**
* A tool supported by the Wizard, holds all information about what format it supports
* what input it requires etc.
+ * This is just the frontend, for the backend, the 'Tool' class is used, which this class
+ * holds an instance off.
*
+ * @todo Move some logic to the 'Tool' class
* @todo Add some way to represent extra arguments to the tool
*/
-class Tool {
+class ToolGUI {
public:
- Tool();
+ ToolGUI();
/**
* Creates a new tool, can be stack allocated and copied without problems
* The type of tool is deduced from the name, if it contains 'extract', it's an extraction tool
@@ -77,7 +80,7 @@
* @param main The tool entry point, defined in tool_entry_point.h
* @param input_extenion Filename filter of the input to expect.
*/
- Tool(wxString name, MainFunction main, wxString input_extension = wxT("*.*"));
+ ToolGUI(Tool *tool, wxString input_extension = wxT("*.*"));
/**
* Adds a supported game to this tool
@@ -94,25 +97,32 @@
* @param format The audio format(s) to test for
*/
bool supportsAudioFormat(AudioFormat format) const;
+
/**
+ * Returns true if the tool outputs to an entire directory, not a single file
+ */
+ bool outputToDirectory() const;
+
+ /**
* Returns the name of the executable of this tool.
* This simple returns the name under *nix, and name.exe under Windows
*/
wxString getExecutable() const;
+ /**
+ * Runs the actual tool, will throw errors if it fails
+ */
+ void run() const;
+
/** Name of the tool */
wxString _name;
- /** Entry point of the tool, for invoking it, accepts CLI in the same format as the classic main function */
- MainFunction invoke;
+ /** The actual tool instance, which runs the compression/extraction */
+ Tool *_backend;
/** Type of tool, either extract, compress or unknown */
ToolType _type;
- /* Formats supported by the tool, bitwise ORed */
- AudioFormat _supportedFormats;
/** List of all inputs this tool expects */
ToolInputs _inputs;
- /** Try if this tool does not output a single file, but rather an entire directory */
- bool _outputToDirectory;
/** The help text displayed on the input/output page */
wxString _inoutHelpText;
/** A list of all games supported by this tool */
@@ -123,8 +133,16 @@
class Tools {
public:
Tools();
-
+ ~Tools();
+
/**
+ * Must be called before the tools can be used
+ * Setup cannot be done in the constructor since it depends on wx setup code
+ * that must be run before it.
+ */
+ void init();
+
+ /**
* Returns a tool by name
* asserts if the tool is not found
*
@@ -132,14 +150,14 @@
* @return A reference to the tool, tools cannot be modified.
*/
- const Tool &operator[](const wxString &name) const;
+ const ToolGUI &operator[](const wxString &name) const;
/**
* Returns a tool by name
*
* @param name Name of the tool to fetch
* @return A pointer to the tool, NULL if there is no tool by that name.
*/
- const Tool *get(const wxString &name) const;
+ const ToolGUI *get(const wxString &name) const;
/**
* Returns a tool that supports the selected game
@@ -148,7 +166,7 @@
* @param type The type of tool we're looking for
* @return The tool that supports this game, and NULL if no tool does
*/
- const Tool *getByGame(const wxString &game, ToolType type = TOOLTYPE_ALL) const;
+ const ToolGUI *getByGame(const wxString &game, ToolType type = TOOLTYPE_ALL) const;
/**
* Returns a list of all tools
@@ -172,9 +190,9 @@
*
* @param tool the tool to add.
*/
- void addTool(const Tool &tool);
+ void addTool(ToolGUI *tool);
- std::map<wxString, Tool> tools;
+ std::map<wxString, ToolGUI *> tools;
};
extern Tools g_tools;
Modified: tools/branches/gsoc2009-gui/kyra_pak.cpp
===================================================================
--- tools/branches/gsoc2009-gui/kyra_pak.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/kyra_pak.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -442,7 +442,7 @@
for (const LinkList *entry = _links; entry; entry = entry->next) {
outputPath->setFullName(entry->filename);
- if (!outputFileAs(entry->linksTo, outputPath->getFullPath()))
+ if (!outputFileAs(entry->linksTo, outputPath->getFullPath().c_str()))
return false;
}
@@ -475,7 +475,7 @@
while (cur) {
outputPath->setFullName(cur->filename);
- FILE *file = fopen(outputPath->getFullPath(), "wb");
+ FILE *file = fopen(outputPath->getFullPath().c_str(), "wb");
if (!file) {
error("couldn't open file '%s' for writing", outputPath->getFullPath());
return false;
Added: tools/branches/gsoc2009-gui/tool.cpp
===================================================================
--- tools/branches/gsoc2009-gui/tool.cpp (rev 0)
+++ tools/branches/gsoc2009-gui/tool.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -0,0 +1,157 @@
+/* tool.cpp - Common base class for all tools (implementation)
+ * Copyright (C) 2009 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL
+ * $Id
+ *
+ */
+
+
+#include <stdarg.h>
+
+#include "util.h"
+#include "tool.h"
+
+Tool::Tool(const std::string &name) {
+ _name = name;
+
+ _arguments_parsed = 0;
+ _argv = NULL;
+
+ _outputToDirectory = true;
+ _supported_formats = AUDIO_NONE;
+
+ _internalPrint = printToSTDOUT;
+ _print_udata = NULL;
+
+ _helptext = "\nUsage: tool [-o outputname] <infile>\n";
+}
+
+Tool::~Tool() {
+ // ...
+}
+
+int Tool::run(int argc, char *argv[]) {
+ argc -= 1;
+ argv += 1;
+
+ _arguments.clear();
+ for(int i = 0; i < argc; ++i)
+ _arguments.push_back(argv[i]);
+ _arguments_parsed = 0;
+ _argv = 0;
+
+ // Check for help
+ if(_arguments.empty() || _arguments[0] == "-h" || _arguments[0] == "--help") {
+ print(_helptext.c_str());
+ return 2;
+ }
+
+ // Read standard arguments
+ if(_supported_formats != AUDIO_NONE)
+ parseAudioArguments();
+ parseOutputArguments();
+ // Read tool specific arguments
+ parseExtraArguments();
+
+ // Read input files from CLI
+ while(_arguments_parsed < _arguments.size()) {
+ _inputPaths.push_back(_arguments[_arguments_parsed++]);
+ }
+
+ if(_inputPaths.empty()) {
+ // Display help text if we got no input
+ print(_helptext.c_str());
+ return 2;
+ }
+
+ // Run the tool, with error handling
+ try {
+ run();
+ } catch(ToolException &err) {
+ const char *what = err.what();
+ print("Fatal Error : %s", what);
+ return err._retcode;
+ }
+ return 0;
+}
+
+void Tool::run() {
+ // Not much done here, but we might want extra handling later
+ execute();
+}
+
+void Tool::setPrintFunction(void (*f)(void *, const char *), void *udata) {
+ _internalPrint = f;
+ _print_udata = udata;
+}
+
+void Tool::error(const char *format, ...) {
+ char buf[4096];
+ va_list va;
+
+ va_start(va, format);
+ vsnprintf(buf, 4096, format, va);
+ va_end(va);
+
+ throw ToolException(buf);
+}
+
+void Tool::print(const char *format, ...) {
+ char buf[4096] = "";
+ va_list va;
+
+ va_start(va, format);
+ vsnprintf(buf, 4096, format, va);
+ va_end(va);
+
+ _internalPrint(_print_udata, buf);
+}
+
+void Tool::parseAudioArguments() {
+}
+
+void Tool::parseOutputArguments() {
+ if(_arguments_parsed >= _arguments.size())
+ return;
+ if(_arguments[_arguments_parsed] == "-o" || _arguments[_arguments_parsed] == "--output") {
+ // It's an -o argument
+
+ if (_arguments_parsed + 1 < _arguments.size()) {
+ _outputPath = _arguments[_arguments_parsed + 1];
+
+ if (_outputToDirectory) {
+ // Ensure last character is a /, this way we force directory output
+ char lastchr = _outputPath.getFullPath()[_outputPath.getFullPath().size() - 1];
+ if (lastchr != '/' && lastchr != '\\') {
+ _outputPath._path += '/';
+ }
+ }
+ _arguments_parsed += 2;
+ } else {
+ throw ToolException("Could not parse arguments: Expected path after '-o' or '--output'.");
+ }
+ }
+}
+
+void Tool::parseExtraArguments() {
+}
+
+// Standard print function
+void Tool::printToSTDOUT(void * /*udata*/, const char *text) {
+ puts(text);
+}
\ No newline at end of file
Property changes on: tools/branches/gsoc2009-gui/tool.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/branches/gsoc2009-gui/tool.h
===================================================================
--- tools/branches/gsoc2009-gui/tool.h (rev 0)
+++ tools/branches/gsoc2009-gui/tool.h 2009-07-04 01:07:12 UTC (rev 42082)
@@ -0,0 +1,104 @@
+/* tool.h - Common base class for all tools
+ * Copyright (C) 2009 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL
+ * $Id
+ *
+ */
+
+#ifndef TOOL_H
+#define TOOL_H
+
+#include <vector>
+#include <string>
+
+#include "util.h"
+
+class ToolGUI;
+
+class Tool {
+public:
+ Tool(const std::string &name);
+ virtual ~Tool();
+
+ // Run with CLI args (parses them, and then calls run())
+ // This version also catches all errors and prints them before exiting
+ int run(int argc, char *argv[]);
+ // Parse with args set already
+ // passes through errors
+ void run();
+
+ void error(const char *format, ...);
+ void print(const char *format, ...);
+
+ /** Returns name of the tool */
+ std::string getName() const;
+
+ /**
+ * This function will be called when the tool needs to output something
+ *
+ * @param f the function to be called, it takes a userdata argument in addition to text to print
+ * @param udata The userdata to call to the print function each time it is called
+ */
+ void setPrintFunction(void f(void *, const char *), void *udata);
+
+protected:
+ virtual void parseAudioArguments();
+ void parseOutputArguments();
+
+ // Parses the arguments only this tool takes
+ virtual void parseExtraArguments();
+
+ // Runs the internal tool (the 'main')
+ virtual void execute() = 0;
+
+public:
+
+ // Input
+ std::vector<std::string> _inputPaths;
+
+ // Output
+ Filename _outputPath;
+
+protected:
+ // Command line arguments we are parsing...
+ std::vector<std::string> _arguments;
+ size_t _arguments_parsed;
+ // We need to keep the raw arguments to invoke some functions
+ char **_argv;
+
+ // What does this tool support?
+ bool _outputToDirectory;
+ AudioFormat _supported_formats;
+ std::vector<std::string> _games;
+
+ /** Name of the tool */
+ std::string _name;
+ /** The text to display to help the user */
+ std::string _helptext;
+
+private:
+ typedef void (*PrintFunction)(void *, const char *);
+ PrintFunction _internalPrint;
+ void *_print_udata;
+ static void printToSTDOUT(void *udata, const char *message);
+
+ friend class ToolGUI;
+};
+
+#endif
+
Property changes on: tools/branches/gsoc2009-gui/tool.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: tools/branches/gsoc2009-gui/util.cpp
===================================================================
--- tools/branches/gsoc2009-gui/util.cpp 2009-07-03 23:37:08 UTC (rev 42081)
+++ tools/branches/gsoc2009-gui/util.cpp 2009-07-04 01:07:12 UTC (rev 42082)
@@ -51,7 +51,7 @@
fprintf(stderr, "WARNING: %s!\n", buf);
}
-void debug(int level, const char *s, ...) {
+void debug(int /*level*/, const char *s, ...) {
char buf[1024];
va_list va;
@@ -148,121 +148,112 @@
// Filenname implementation
Filename::Filename(const char *path) {
- strcpy(_path, path);
+ _path = path;
}
+Filename::Filename(std::string path) {
+ _path = path;
+}
Filename::Filename(const Filename& filename) {
- strcpy(_path, filename._path);
+ _path = filename._path;
}
Filename& Filename::operator=(const Filename& filename) {
- strcpy(_path, filename._path);
+ _path = filename._path;
return *this;
}
-void Filename::setFullPath(const char *path) {
- strcpy(_path, path);
+void Filename::setFullPath(std::string path) {
+ _path = path;
}
-Filename *Filename::setFullName(const char *newname) {
- char p[1024];
- if (getPath(p)) {
- strcat(p, newname);
- strcpy(_path, p);
- return this;
- }
- return NULL;
+void Filename::setFullName(std::string newname) {
+ _path = getPath() + newname;
}
-void Filename::addExtension(const char *ext) {
- strcat(_path, ext);
+void Filename::addExtension(std::string ext) {
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list