Much simplified the Wave "decoder". It will now use the MUtilities library to copy the file, rather than SHFileOperation(). For whatever reason, copying a file to a directory via SHFileOperation() prevents that directory from being deleted later. But only when trying to delete that directory from the same process where SHFileOperation() had been called. It can be deleted, e.g., in Windows Explorer just fine - even when the process that called SHFileOperation() is still running. Anyway, we simply avoid SHFileOperation() now.

This commit is contained in:
LoRd_MuldeR 2015-01-02 23:46:03 +01:00
parent b28d763cc4
commit 6b310b7c05
2 changed files with 16 additions and 37 deletions

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 13
#define VER_LAMEXP_BUILD 1664
#define VER_LAMEXP_BUILD 1667
#define VER_LAMEXP_CONFG 1558
///////////////////////////////////////////////////////////////////////////////

View File

@ -20,21 +20,15 @@
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
//Internal
#include "Decoder_Wave.h"
#include "Global.h"
//MUtils
#include <MUtils/OSSupport.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
//Windows includes
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <Shellapi.h>
#define FIX_SEPARATORS(STR) for(int i = 0; STR[i]; i++) { if(STR[i] == L'/') STR[i] = L'\\'; }
WaveDecoder::WaveDecoder(void)
{
@ -48,35 +42,20 @@ bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, v
{
emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
SHFILEOPSTRUCTW fileOperation;
memset(&fileOperation, 0, sizeof(SHFILEOPSTRUCTW));
fileOperation.wFunc = FO_COPY;
fileOperation.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_FILESONLY;
size_t srcLen = wcslen(reinterpret_cast<const wchar_t*>(sourceFile.utf16())) + 3;
wchar_t *srcBuffer = new wchar_t[srcLen];
memset(srcBuffer, 0, srcLen * sizeof(wchar_t));
wcsncpy_s(srcBuffer, srcLen, reinterpret_cast<const wchar_t*>(sourceFile.utf16()), _TRUNCATE);
FIX_SEPARATORS (srcBuffer);
fileOperation.pFrom = srcBuffer;
size_t outLen = wcslen(reinterpret_cast<const wchar_t*>(outputFile.utf16())) + 3;
wchar_t *outBuffer = new wchar_t[outLen];
memset(outBuffer, 0, outLen * sizeof(wchar_t));
wcsncpy_s(outBuffer, outLen, reinterpret_cast<const wchar_t*>(outputFile.utf16()), _TRUNCATE);
FIX_SEPARATORS (outBuffer);
fileOperation.pTo = outBuffer;
emit statusUpdated(0);
int result = SHFileOperation(&fileOperation);
const bool okay = MUtils::OS::copy_file(sourceFile, outputFile);
emit statusUpdated(100);
emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", result));
if(okay)
{
emit messageLogged("File copied successfully.");
}
else
{
emit messageLogged("Failed to copy file!");
}
delete [] srcBuffer;
delete [] outBuffer;
return (result == 0 && fileOperation.fAnyOperationsAborted == false);
return okay;
}
bool WaveDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)