removed some ugly defines

This commit is contained in:
Luis Ángel San Martín
2013-08-22 23:12:56 +02:00
parent e43721fe8e
commit fa19b4b1ea
14 changed files with 418 additions and 413 deletions

View File

@ -28,11 +28,11 @@ static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propI
NCOM::CPropVariant prop;
RINOK(archive->GetProperty(index, propID, &prop));
if (prop.vt == VT_BOOL)
result = VARIANT_BOOLToBool(prop.boolVal);
result = VARIANT_BOOLToBool(prop.boolVal);
else if (prop.vt == VT_EMPTY)
result = false;
result = false;
else
return E_FAIL;
return E_FAIL;
return S_OK;
}
static HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result)
@ -71,11 +71,11 @@ private:
UInt32 _index;
struct CProcessedFileInfo
{
FILETIME MTime;
UInt32 Attrib;
bool isDir;
bool AttribDefined;
bool MTimeDefined;
FILETIME MTime;
UInt32 Attrib;
bool isDir;
bool AttribDefined;
bool MTimeDefined;
} _processedFileInfo;
COutFileStream *_outFileStreamSpec;
@ -111,89 +111,89 @@ STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 * /* completeVal
}
STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
ISequentialOutStream **outStream, Int32 askExtractMode)
ISequentialOutStream **outStream, Int32 askExtractMode)
{
*outStream = 0;
_outFileStream.Release();
_index = index;
{
// Get Name
NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
UString fullPath;
if (prop.vt == VT_EMPTY)
fullPath = kEmptyFileAlias;
else
{
if (prop.vt != VT_BSTR)
return E_FAIL;
fullPath = prop.bstrVal;
}
_filePath = fullPath;
// Get Name
NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
UString fullPath;
if (prop.vt == VT_EMPTY)
fullPath = kEmptyFileAlias;
else
{
if (prop.vt != VT_BSTR)
return E_FAIL;
fullPath = prop.bstrVal;
}
_filePath = fullPath;
}
//if (askExtractMode != NArchive::NExtract::NAskMode::kExtract)
//return S_OK;
//return S_OK;
{
// Get Attrib
NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop));
if (prop.vt == VT_EMPTY)
{
_processedFileInfo.Attrib = 0;
_processedFileInfo.AttribDefined = false;
}
else
{
if (prop.vt != VT_UI4)
return E_FAIL;
_processedFileInfo.Attrib = prop.ulVal;
_processedFileInfo.AttribDefined = true;
}
// Get Attrib
NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop));
if (prop.vt == VT_EMPTY)
{
_processedFileInfo.Attrib = 0;
_processedFileInfo.AttribDefined = false;
}
else
{
if (prop.vt != VT_UI4)
return E_FAIL;
_processedFileInfo.Attrib = prop.ulVal;
_processedFileInfo.AttribDefined = true;
}
}
RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.isDir));
{
// Get Modified Time
NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop));
_processedFileInfo.MTimeDefined = false;
switch(prop.vt)
{
case VT_EMPTY:
// _processedFileInfo.MTime = _utcMTimeDefault;
break;
case VT_FILETIME:
_processedFileInfo.MTime = prop.filetime;
_processedFileInfo.MTimeDefined = true;
break;
default:
return E_FAIL;
}
// Get Modified Time
NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop));
_processedFileInfo.MTimeDefined = false;
switch(prop.vt)
{
case VT_EMPTY:
// _processedFileInfo.MTime = _utcMTimeDefault;
break;
case VT_FILETIME:
_processedFileInfo.MTime = prop.filetime;
_processedFileInfo.MTimeDefined = true;
break;
default:
return E_FAIL;
}
}
//se necesita conocer el tama<6D>o del archivo para poder reservar suficiente memoria
bool newFileSizeDefined;
{
// Get Size
NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
newFileSizeDefined = (prop.vt != VT_EMPTY);
if (newFileSizeDefined)
newFileSize = ConvertPropVariantToUInt64(prop);
// Get Size
NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
newFileSizeDefined = (prop.vt != VT_EMPTY);
if (newFileSizeDefined)
newFileSize = ConvertPropVariantToUInt64(prop);
}
//No hay que crear ning<6E>n fichero, ni directorios intermedios
/*{
// Create folders for file
int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (slashPos >= 0)
NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos));
// Create folders for file
int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (slashPos >= 0)
NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos));
}
UString fullProcessedPath = _directoryPath + _filePath;
@ -201,7 +201,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
*/
if (_processedFileInfo.isDir)
{
//NFile::NDirectory::CreateComplexDirectory(fullProcessedPath);
//NFile::NDirectory::CreateComplexDirectory(fullProcessedPath);
}
else
{
@ -236,13 +236,13 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
_extractMode = false;
switch (askExtractMode)
{
case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break;
case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break;
};
/* switch (askExtractMode)
{
case NArchive::NExtract::NAskMode::kExtract: qDebug() << (kExtractingString); break;
case NArchive::NExtract::NAskMode::kTest: qDebug() <<(kTestingString); break;
case NArchive::NExtract::NAskMode::kSkip: qDebug() <<(kSkippingString); break;
case NArchive::NExtract::NAskMode::kExtract: qDebug() << (kExtractingString); break;
case NArchive::NExtract::NAskMode::kTest: qDebug() <<(kTestingString); break;
case NArchive::NExtract::NAskMode::kSkip: qDebug() <<(kSkippingString); break;
};*/
//qDebug() << _filePath;
return S_OK;
@ -252,7 +252,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
{
switch(operationResult)
{
case NArchive::NExtract::NOperationResult::kOK:
case NArchive::NExtract::NOperationResult::kOK:
if(all && !_processedFileInfo.isDir)
{
QByteArray rawData((char *)data,newFileSize);
@ -264,45 +264,45 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
allFiles.append(rawData);
}
}
break;
default:
{
NumErrors++;
qDebug() << " ";
switch(operationResult)
{
case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
break;
default:
{
NumErrors++;
qDebug() << " ";
switch(operationResult)
{
case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
if(delegate != 0)
delegate->unknownError(_index);
qDebug() << kUnsupportedMethod;
break;
case NArchive::NExtract::NOperationResult::kCRCError:
qDebug() << kUnsupportedMethod;
break;
case NArchive::NExtract::NOperationResult::kCRCError:
if(delegate != 0)
delegate->crcError(_index);
qDebug() << kCRCFailed;
break;
case NArchive::NExtract::NOperationResult::kDataError:
qDebug() << kCRCFailed;
break;
case NArchive::NExtract::NOperationResult::kDataError:
if(delegate != 0)
delegate->unknownError(_index);
qDebug() << kDataError;
break;
default:
qDebug() << kDataError;
break;
default:
if(delegate != 0)
delegate->unknownError(_index);
qDebug() << kUnknownError;
}
}
qDebug() << kUnknownError;
}
}
}
/*
if (_outFileStream != NULL)
{
if (_processedFileInfo.MTimeDefined)
_outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
RINOK(_outFileStreamSpec->Close());
if (_processedFileInfo.MTimeDefined)
_outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
RINOK(_outFileStreamSpec->Close());
}
_outFileStream.Release();
if (_extractMode && _processedFileInfo.AttribDefined)
NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attrib);*/
NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attrib);*/
//qDebug() << endl;
return S_OK;
}
@ -312,11 +312,11 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
{
if (!PasswordIsDefined)
{
// You can ask real password here from user
// Password = GetPassword(OutStream);
// PasswordIsDefined = true;
qDebug() << "Password is not defined" << endl;
return E_ABORT;
// You can ask real password here from user
// Password = GetPassword(OutStream);
// PasswordIsDefined = true;
qDebug() << "Password is not defined" << endl;
return E_ABORT;
}
return StringToBstr(Password, password);
}