mirror of
https://github.com/scummvm/scummvm-tools.git
synced 2026-05-21 05:40:44 +00:00
Replace calls to unlink() by new function Common::removeFile()
svn-id: r48937
This commit is contained in:
@@ -24,6 +24,10 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h> // for unlink()
|
||||
#endif
|
||||
|
||||
|
||||
namespace Common {
|
||||
|
||||
@@ -486,5 +490,9 @@ uint32 File::size() const {
|
||||
return sz;
|
||||
}
|
||||
|
||||
int removeFile(const char *path) {
|
||||
return unlink(path);
|
||||
}
|
||||
|
||||
} // End of namespace Common
|
||||
|
||||
|
||||
@@ -392,6 +392,15 @@ protected:
|
||||
uint8 _xormode;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Remove the specified file.
|
||||
* Currently this simply call unlink() internally,
|
||||
* but by using this wrapper we have an easier time
|
||||
* staying compatible with Windows.
|
||||
*/
|
||||
int removeFile(const char *path);
|
||||
|
||||
} // End of namespace Common
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -688,7 +688,7 @@ void CompressionTool::extractAndEncodeAIFF(const char *inName, const char *outNa
|
||||
encodeAudio(TEMP_RAW, true, sampleRate, outName, compmode);
|
||||
|
||||
// Delete temporary file
|
||||
unlink(TEMP_RAW);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
}
|
||||
|
||||
void CompressionTool::extractAndEncodeVOC(const char *outName, Common::File &input, AudioFormat compMode) {
|
||||
|
||||
@@ -64,11 +64,11 @@ void CompressAgos::end() {
|
||||
outputFile.close();
|
||||
|
||||
/* And some clean-up :-) */
|
||||
unlink(TEMP_IDX);
|
||||
unlink(TEMP_DAT);
|
||||
unlink(TEMP_RAW);
|
||||
unlink(tempEncoded);
|
||||
unlink(TEMP_WAV);
|
||||
Common::removeFile(TEMP_IDX);
|
||||
Common::removeFile(TEMP_DAT);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(tempEncoded);
|
||||
Common::removeFile(TEMP_WAV);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -99,9 +99,9 @@ void CompressKyra::process(Common::Filename *infile, Common::Filename *outfile)
|
||||
|
||||
output.addFile(outputName.getFullPath().c_str(), tempEncoded);
|
||||
|
||||
unlink(TEMPFILE);
|
||||
unlink(TEMP_RAW);
|
||||
unlink(tempEncoded);
|
||||
Common::removeFile(TEMPFILE);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(tempEncoded);
|
||||
}
|
||||
|
||||
if (output.getFileList())
|
||||
@@ -285,7 +285,7 @@ void CompressKyra::compressAUDFile(Common::File &input, const char *outfile) {
|
||||
|
||||
encodeAudio(TEMP_RAW, true, header.freq, outfile, _format);
|
||||
|
||||
unlink(TEMP_RAW);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
}
|
||||
|
||||
struct CompressKyra::DuplicatedFile {
|
||||
@@ -345,7 +345,7 @@ void CompressKyra::processKyra3(Common::Filename *infile, Common::Filename *outf
|
||||
|
||||
output.addFile(outname, outname);
|
||||
|
||||
unlink(outname);
|
||||
Common::removeFile(outname);
|
||||
|
||||
input.seek(pos, SEEK_SET);
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ void PAKFile::generateLinkEntry() {
|
||||
|
||||
addFile("LINKLIST", "LINKLIST.TMP");
|
||||
|
||||
unlink("LINKLIST.TMP");
|
||||
Common::removeFile("LINKLIST.TMP");
|
||||
delete[] linkList;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,8 +168,8 @@ void CompressQueen::createFinalFile(Common::Filename outPath) {
|
||||
fromFileToFile(inData, outFinal, dataSize);
|
||||
|
||||
/* Cleanup */
|
||||
unlink(TEMP_TBL);
|
||||
unlink(TEMP_DAT);
|
||||
Common::removeFile(TEMP_TBL);
|
||||
Common::removeFile(TEMP_DAT);
|
||||
}
|
||||
|
||||
void CompressQueen::execute() {
|
||||
@@ -275,8 +275,8 @@ void CompressQueen::execute() {
|
||||
compFile.close();
|
||||
|
||||
/* Delete temporary files */
|
||||
unlink(TEMP_SB);
|
||||
unlink(tempEncoded);
|
||||
Common::removeFile(TEMP_SB);
|
||||
Common::removeFile(tempEncoded);
|
||||
} else {
|
||||
/* Non .SB file */
|
||||
bool patched = false;
|
||||
|
||||
@@ -430,8 +430,8 @@ void CompressSaga::sagaEncode(Common::Filename *inpath, Common::Filename *outpat
|
||||
free(outputTable);
|
||||
|
||||
// Cleanup
|
||||
unlink(TEMP_RAW);
|
||||
unlink(tempEncoded);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(tempEncoded);
|
||||
|
||||
print("Done!\n");
|
||||
}
|
||||
|
||||
@@ -405,8 +405,8 @@ void CompressSci::execute() {
|
||||
}
|
||||
|
||||
/* And some clean-up :-) */
|
||||
unlink(TEMP_RAW);
|
||||
unlink(TEMP_ENC);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(TEMP_ENC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -895,7 +895,7 @@ void CompressScummBun::writeRegions(byte *ptr, int bits, int freq, int channels,
|
||||
}
|
||||
|
||||
sprintf(tmpPath, "%s%s_reg%03d.wav", dir, filename, l);
|
||||
unlink(tmpPath);
|
||||
Common::removeFile(tmpPath);
|
||||
|
||||
int32 startPos = output.pos();
|
||||
switch (_format) {
|
||||
@@ -923,7 +923,7 @@ void CompressScummBun::writeRegions(byte *ptr, int bits, int freq, int channels,
|
||||
byte *tmpBuf = (byte *)malloc(size);
|
||||
cmpFile.read_throwsOnError(tmpBuf, size);
|
||||
cmpFile.close();
|
||||
unlink(tmpPath);
|
||||
Common::removeFile(tmpPath);
|
||||
|
||||
output.write(tmpBuf, size);
|
||||
free(tmpBuf);
|
||||
|
||||
@@ -304,7 +304,7 @@ void CompressScummSan::mixing(const std::string &outputDir, const std::string &i
|
||||
byte *tmpBuf = (byte *)malloc(fileSize);
|
||||
_audioTracks[l].file.read_throwsOnError(tmpBuf, fileSize);
|
||||
_audioTracks[l].file.close();
|
||||
unlink(filename);
|
||||
Common::removeFile(filename);
|
||||
|
||||
byte *wavBuf = (byte *)malloc(fileSize);
|
||||
memset(wavBuf, 0, fileSize);
|
||||
@@ -760,7 +760,7 @@ skip:
|
||||
else
|
||||
encodeSanWaveWithLame(tmpPath);
|
||||
tmpPath += ".raw";
|
||||
unlink(tmpPath.c_str());
|
||||
Common::removeFile(tmpPath.c_str());
|
||||
}
|
||||
|
||||
input.close();
|
||||
|
||||
@@ -69,10 +69,10 @@ void CompressScummSou::end_of_file() {
|
||||
_input.close();
|
||||
|
||||
/* And some clean-up :-) */
|
||||
unlink(TEMP_IDX);
|
||||
unlink(TEMP_DAT);
|
||||
unlink(TEMP_RAW);
|
||||
unlink(tempEncoded);
|
||||
Common::removeFile(TEMP_IDX);
|
||||
Common::removeFile(TEMP_DAT);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(tempEncoded);
|
||||
}
|
||||
|
||||
void CompressScummSou::append_byte(int size, char buf[]) {
|
||||
|
||||
@@ -522,8 +522,8 @@ void CompressSword1::compressSpeech(const Common::Filename *inpath, const Common
|
||||
print("Converting CD %d...\n", i);
|
||||
convertClu(clu, cl3);
|
||||
}
|
||||
unlink(TEMP_RAW);
|
||||
unlink(_audioOuputFilename.c_str());
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(_audioOuputFilename.c_str());
|
||||
}
|
||||
|
||||
void CompressSword1::compressMusic(const Common::Filename *inpath, const Common::Filename *outpath) {
|
||||
@@ -535,7 +535,7 @@ void CompressSword1::compressMusic(const Common::Filename *inpath, const Common:
|
||||
try {
|
||||
Common::File outf(outName, "wb");
|
||||
outf.close();
|
||||
unlink(outName);
|
||||
Common::removeFile(outName);
|
||||
} catch(Common::FileException& err) {
|
||||
_useOutputMusicSubdir = false;
|
||||
print("Cannot create files in %s/MUSIC/; will try in %s/\n", outpath->getPath().c_str(), outpath->getPath().c_str());
|
||||
|
||||
@@ -203,12 +203,12 @@ void CompressSword2::execute() {
|
||||
|
||||
output.close();
|
||||
|
||||
unlink(TEMP_DAT);
|
||||
unlink(TEMP_IDX);
|
||||
unlink(TEMP_MP3);
|
||||
unlink(TEMP_OGG);
|
||||
unlink(TEMP_FLAC);
|
||||
unlink(TEMP_WAV);
|
||||
Common::removeFile(TEMP_DAT);
|
||||
Common::removeFile(TEMP_IDX);
|
||||
Common::removeFile(TEMP_MP3);
|
||||
Common::removeFile(TEMP_OGG);
|
||||
Common::removeFile(TEMP_FLAC);
|
||||
Common::removeFile(TEMP_WAV);
|
||||
}
|
||||
|
||||
#ifdef STANDALONE_MAIN
|
||||
|
||||
@@ -73,7 +73,7 @@ void CompressTinsel::convertTinselRawSample (uint32 sampleSize) {
|
||||
|
||||
print("Assuming DW1 sample being 8-bit raw...\n");
|
||||
|
||||
unlink(TEMP_RAW); unlink(TEMP_ENC);
|
||||
Common::removeFile(TEMP_RAW); Common::removeFile(TEMP_ENC);
|
||||
curFileHandle.open(TEMP_RAW, "wb");
|
||||
copyLeft = sampleSize;
|
||||
while (copyLeft > 0) {
|
||||
@@ -224,8 +224,8 @@ void CompressTinsel::convertTinselADPCMSample (uint32 sampleSize) {
|
||||
chunkPos = (chunkPos + 1) % 4;
|
||||
}
|
||||
|
||||
unlink(TEMP_RAW);
|
||||
unlink(TEMP_ENC);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(TEMP_ENC);
|
||||
|
||||
curFileHandle.open(TEMP_RAW, "wb");
|
||||
curFileHandle.write(outBuffer, decodedCount*2);
|
||||
@@ -268,10 +268,10 @@ void CompressTinsel::execute() {
|
||||
_input_idx.open(inpath_idx, "rb");
|
||||
_input_smp.open(inpath_smp, "rb");
|
||||
|
||||
unlink(TEMP_IDX);
|
||||
Common::removeFile(TEMP_IDX);
|
||||
_output_idx.open(TEMP_IDX, "wb");
|
||||
|
||||
unlink(TEMP_SMP);
|
||||
Common::removeFile(TEMP_SMP);
|
||||
_output_smp.open(TEMP_SMP, "wb");
|
||||
|
||||
_input_idx.seek(0, SEEK_END);
|
||||
@@ -330,8 +330,8 @@ void CompressTinsel::execute() {
|
||||
}
|
||||
|
||||
/* And some clean-up :-) */
|
||||
unlink(TEMP_RAW);
|
||||
unlink(TEMP_ENC);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(TEMP_ENC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "compress.h"
|
||||
#include "compress_touche.h"
|
||||
@@ -176,8 +173,8 @@ void CompressTouche::compress_sound_data(Common::Filename *inpath, Common::Filen
|
||||
output.close();
|
||||
|
||||
/* cleanup */
|
||||
unlink(TEMP_RAW);
|
||||
unlink(tempEncoded);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(tempEncoded);
|
||||
|
||||
print("Done.\n");
|
||||
}
|
||||
|
||||
@@ -412,9 +412,9 @@ void CompressTucker::compress_sound_files(const Common::Filename *inpath, const
|
||||
output.close();
|
||||
|
||||
/* cleanup */
|
||||
unlink(TEMP_WAV);
|
||||
unlink(TEMP_RAW);
|
||||
unlink(tempEncoded);
|
||||
Common::removeFile(TEMP_WAV);
|
||||
Common::removeFile(TEMP_RAW);
|
||||
Common::removeFile(tempEncoded);
|
||||
|
||||
print("Done.\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user