diff options
author | 2015-01-11 08:10:25 +0100 | |
---|---|---|
committer | 2015-01-11 08:10:25 +0100 | |
commit | 6a23c2f3b766cf4fc7028628f76b5ff9396383f0 (patch) | |
tree | a01e16637118ae0c80f337119898bdf18f081e24 /3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp | |
parent | 45ac9b351e0076c371de4c7453f59567b27b1cb6 (diff) |
Added full lzma sdk source (nw)
Diffstat (limited to '3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp')
-rw-r--r-- | 3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp b/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp new file mode 100644 index 00000000000..7e6f460226a --- /dev/null +++ b/3rdparty/lzma/CPP/7zip/Archive/Common/HandlerOut.cpp @@ -0,0 +1,141 @@ +// HandlerOut.cpp + +#include "StdAfx.h" + +#ifndef _7ZIP_ST +#include "../../../Windows/System.h" +#endif + +#include "../Common/ParseProperties.h" + +#include "HandlerOut.h" + +using namespace NWindows; + +namespace NArchive { + +static void SetMethodProp32(COneMethodInfo &m, PROPID propID, UInt32 value) +{ + if (m.FindProp(propID) < 0) + m.AddProp32(propID, value); +} + +void CMultiMethodProps::SetGlobalLevelAndThreads(COneMethodInfo &oneMethodInfo + #ifndef _7ZIP_ST + , UInt32 numThreads + #endif + ) +{ + UInt32 level = _level; + if (level != (UInt32)(UInt32)-1) + SetMethodProp32(oneMethodInfo, NCoderPropID::kLevel, (UInt32)level); + #ifndef _7ZIP_ST + SetMethodProp32(oneMethodInfo, NCoderPropID::kNumThreads, numThreads); + #endif +} + +void CMultiMethodProps::Init() +{ + #ifndef _7ZIP_ST + _numProcessors = _numThreads = NSystem::GetNumberOfProcessors(); + #endif + + _level = (UInt32)(UInt32)-1; + _autoFilter = true; + _crcSize = 4; + _filterMethod.Clear(); + _methods.Clear(); +} + +HRESULT CMultiMethodProps::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value) +{ + UString name = nameSpec; + name.MakeUpper(); + if (name.IsEmpty()) + return E_INVALIDARG; + + if (name[0] == 'X') + { + name.Delete(0); + _level = 9; + return ParsePropToUInt32(name, value, _level); + } + + if (name == L"CRC") + { + name.Delete(0, 3); + _crcSize = 4; + return ParsePropToUInt32(name, value, _crcSize); + } + + UInt32 number; + int index = ParseStringToUInt32(name, number); + UString realName = name.Mid(index); + if (index == 0) + { + if (name.Left(2).CompareNoCase(L"MT") == 0) + { + #ifndef _7ZIP_ST + RINOK(ParseMtProp(name.Mid(2), value, _numProcessors, _numThreads)); + #endif + return S_OK; + } + if (name.CompareNoCase(L"F") == 0) + { + HRESULT res = PROPVARIANT_to_bool(value, _autoFilter); + if (res == S_OK) + return res; + if (value.vt != VT_BSTR) + return E_INVALIDARG; + return _filterMethod.ParseMethodFromPROPVARIANT(L"", value); + } + number = 0; + } + if (number > 64) + return E_FAIL; + for (int j = _methods.Size(); j <= (int)number; j++) + _methods.Add(COneMethodInfo()); + return _methods[number].ParseMethodFromPROPVARIANT(realName, value); +} + +void CSingleMethodProps::Init() +{ + Clear(); + #ifndef _7ZIP_ST + _numProcessors = _numThreads = NWindows::NSystem::GetNumberOfProcessors(); + AddNumThreadsProp(_numThreads); + #endif + _level = (UInt32)(UInt32)-1; +} + +HRESULT CSingleMethodProps::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps) +{ + Init(); + for (int i = 0; i < numProps; i++) + { + UString name = names[i]; + name.MakeUpper(); + if (name.IsEmpty()) + return E_INVALIDARG; + const PROPVARIANT &value = values[i]; + if (name[0] == L'X') + { + UInt32 a = 9; + RINOK(ParsePropToUInt32(name.Mid(1), value, a)); + _level = a; + AddLevelProp(a); + } + else if (name.Left(2).CompareNoCase(L"MT") == 0) + { + #ifndef _7ZIP_ST + RINOK(ParseMtProp(name.Mid(2), value, _numProcessors, _numThreads)); + AddNumThreadsProp(_numThreads); + #endif + } + else + return ParseParamsFromPROPVARIANT(name, value); + } + return S_OK; +} + +} |