init repo
This commit is contained in:
704
ActiveX/Common/DocxFormat/Source/SystemUtility/File.h
Normal file
704
ActiveX/Common/DocxFormat/Source/SystemUtility/File.h
Normal file
@@ -0,0 +1,704 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../XML/XmlUtils.h"
|
||||
|
||||
class CFile
|
||||
{
|
||||
public:
|
||||
CFile()
|
||||
{
|
||||
m_hFileHandle = NULL;
|
||||
m_lFileSize = 0;
|
||||
m_lFilePosition = 0;
|
||||
}
|
||||
|
||||
virtual ~CFile()
|
||||
{
|
||||
CloseFile();
|
||||
}
|
||||
HRESULT OpenOrCreate(CString strFileName)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
HRESULT hRes = S_OK;
|
||||
DWORD AccessMode = GENERIC_READ | GENERIC_WRITE;
|
||||
DWORD ShareMode = FILE_SHARE_WRITE;
|
||||
DWORD Disposition = OPEN_ALWAYS;
|
||||
m_hFileHandle = ::CreateFile(strFileName, AccessMode, ShareMode, NULL, Disposition, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle)
|
||||
hRes = S_FALSE;
|
||||
else
|
||||
{
|
||||
ULARGE_INTEGER nTempSize;
|
||||
nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart);
|
||||
m_lFileSize = nTempSize.QuadPart;
|
||||
|
||||
SetPosition(m_lFileSize);
|
||||
}
|
||||
|
||||
return hRes;
|
||||
}
|
||||
virtual HRESULT OpenFile(CString FileName)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
HRESULT hRes = S_OK;
|
||||
DWORD AccessMode = GENERIC_READ;
|
||||
DWORD ShareMode = FILE_SHARE_READ;
|
||||
DWORD Disposition = OPEN_EXISTING;
|
||||
m_hFileHandle = ::CreateFile(FileName, AccessMode, ShareMode, NULL, Disposition, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle)
|
||||
hRes = S_FALSE;
|
||||
else
|
||||
{
|
||||
ULARGE_INTEGER nTempSize;
|
||||
nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart);
|
||||
m_lFileSize = nTempSize.QuadPart;
|
||||
|
||||
SetPosition(0);
|
||||
}
|
||||
|
||||
return hRes;
|
||||
}
|
||||
|
||||
virtual HRESULT OpenFileRW(CString FileName)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
HRESULT hRes = S_OK;
|
||||
DWORD AccessMode = GENERIC_READ | GENERIC_WRITE;
|
||||
DWORD ShareMode = FILE_SHARE_READ;
|
||||
DWORD Disposition = OPEN_EXISTING;
|
||||
m_hFileHandle = ::CreateFile(FileName, AccessMode, ShareMode, NULL, Disposition, 0, 0);
|
||||
|
||||
if (NULL == m_hFileHandle || INVALID_HANDLE_VALUE == m_hFileHandle)
|
||||
{
|
||||
hRes = S_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ULARGE_INTEGER nTempSize;
|
||||
nTempSize.LowPart = ::GetFileSize(m_hFileHandle, &nTempSize.HighPart);
|
||||
m_lFileSize = nTempSize.QuadPart;
|
||||
|
||||
SetPosition(0);
|
||||
}
|
||||
|
||||
return hRes;
|
||||
}
|
||||
|
||||
HRESULT ReadFile(BYTE* pData, DWORD nBytesToRead)
|
||||
{
|
||||
DWORD nBytesRead = 0;
|
||||
if(NULL == pData)
|
||||
return S_FALSE;
|
||||
|
||||
if(m_hFileHandle && (pData))
|
||||
{
|
||||
SetPosition(m_lFilePosition);
|
||||
::ReadFile(m_hFileHandle, pData, nBytesToRead, &nBytesRead, NULL);
|
||||
m_lFilePosition += nBytesRead;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT ReadFile2(BYTE* pData, DWORD nBytesToRead)
|
||||
{
|
||||
DWORD nBytesRead = 0;
|
||||
if(NULL == pData)
|
||||
return S_FALSE;
|
||||
|
||||
if(m_hFileHandle && (pData))
|
||||
{
|
||||
SetPosition(m_lFilePosition);
|
||||
::ReadFile(m_hFileHandle, pData, nBytesToRead, &nBytesRead, NULL);
|
||||
m_lFilePosition += nBytesRead;
|
||||
|
||||
for (size_t index = 0; index < nBytesToRead / 2; ++index)
|
||||
{
|
||||
BYTE temp = pData[index];
|
||||
pData[index] = pData[nBytesToRead - index - 1];
|
||||
pData[nBytesToRead - index - 1] = temp;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT ReadFile3(void* pData, DWORD nBytesToRead)
|
||||
{
|
||||
DWORD nBytesRead = 0;
|
||||
if(NULL == pData)
|
||||
return S_FALSE;
|
||||
|
||||
if(m_hFileHandle && (pData))
|
||||
{
|
||||
SetPosition(m_lFilePosition);
|
||||
::ReadFile(m_hFileHandle, pData, nBytesToRead, &nBytesRead, NULL);
|
||||
m_lFilePosition += nBytesRead;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT WriteFile(void* pData, DWORD nBytesToWrite)
|
||||
{
|
||||
if(m_hFileHandle)
|
||||
{
|
||||
DWORD dwWritten = 0;
|
||||
::WriteFile(m_hFileHandle, pData, nBytesToWrite, &dwWritten, NULL);
|
||||
m_lFilePosition += nBytesToWrite;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT WriteFile2(void* pData, DWORD nBytesToWrite)
|
||||
{
|
||||
if(m_hFileHandle)
|
||||
{
|
||||
BYTE* mem = new BYTE[nBytesToWrite];
|
||||
memcpy(mem, pData, nBytesToWrite);
|
||||
|
||||
for (size_t index = 0; index < nBytesToWrite / 2; ++index)
|
||||
{
|
||||
BYTE temp = mem[index];
|
||||
mem[index] = mem[nBytesToWrite - index - 1];
|
||||
mem[nBytesToWrite - index - 1] = temp;
|
||||
}
|
||||
|
||||
DWORD dwWritten = 0;
|
||||
::WriteFile(m_hFileHandle, (void*)mem, nBytesToWrite, &dwWritten, NULL);
|
||||
m_lFilePosition += nBytesToWrite;
|
||||
RELEASEARRAYOBJECTS(mem);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CreateFile(CString strFileName)
|
||||
{
|
||||
CloseFile();
|
||||
DWORD AccessMode = GENERIC_WRITE;
|
||||
DWORD ShareMode = FILE_SHARE_WRITE;
|
||||
DWORD Disposition = CREATE_ALWAYS;
|
||||
m_hFileHandle = ::CreateFile(strFileName, AccessMode, ShareMode, NULL, Disposition, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
return SetPosition(0);
|
||||
}
|
||||
HRESULT SetPosition( ULONG64 nPos )
|
||||
{
|
||||
if (m_hFileHandle && nPos <= (ULONG)m_lFileSize)
|
||||
{
|
||||
LARGE_INTEGER nTempPos;
|
||||
nTempPos.QuadPart = nPos;
|
||||
::SetFilePointer(m_hFileHandle, nTempPos.LowPart, &nTempPos.HighPart, FILE_BEGIN);
|
||||
m_lFilePosition = nPos;
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (INVALID_HANDLE_VALUE == m_hFileHandle) ? S_FALSE : S_OK;
|
||||
}
|
||||
}
|
||||
LONG64 GetPosition()
|
||||
{
|
||||
return m_lFilePosition;
|
||||
}
|
||||
HRESULT SkipBytes(ULONG64 nCount)
|
||||
{
|
||||
return SetPosition(m_lFilePosition + nCount);
|
||||
}
|
||||
|
||||
HRESULT CloseFile()
|
||||
{
|
||||
m_lFileSize = 0;
|
||||
m_lFilePosition = 0;
|
||||
RELEASEHANDLE(m_hFileHandle);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ULONG64 GetFileSize()
|
||||
{
|
||||
return m_lFileSize;
|
||||
}
|
||||
|
||||
HRESULT WriteReserved(DWORD dwCount)
|
||||
{
|
||||
BYTE* buf = new BYTE[dwCount];
|
||||
memset(buf, 0, (size_t)dwCount);
|
||||
HRESULT hr = WriteFile(buf, dwCount);
|
||||
RELEASEARRAYOBJECTS(buf);
|
||||
return hr;
|
||||
}
|
||||
HRESULT WriteReserved2(DWORD dwCount)
|
||||
{
|
||||
BYTE* buf = new BYTE[dwCount];
|
||||
memset(buf, 0xFF, (size_t)dwCount);
|
||||
HRESULT hr = WriteFile(buf, dwCount);
|
||||
RELEASEARRAYOBJECTS(buf);
|
||||
return hr;
|
||||
}
|
||||
HRESULT WriteReservedTo(DWORD dwPoint)
|
||||
{
|
||||
if (m_lFilePosition >= dwPoint)
|
||||
return S_OK;
|
||||
|
||||
DWORD dwCount = dwPoint - (DWORD)m_lFilePosition;
|
||||
BYTE* buf = new BYTE[dwCount];
|
||||
memset(buf, 0, (size_t)dwCount);
|
||||
HRESULT hr = WriteFile(buf, dwCount);
|
||||
RELEASEARRAYOBJECTS(buf);
|
||||
return hr;
|
||||
}
|
||||
HRESULT SkipReservedTo(DWORD dwPoint)
|
||||
{
|
||||
if (m_lFilePosition >= dwPoint)
|
||||
return S_OK;
|
||||
|
||||
DWORD dwCount = dwPoint - (DWORD)m_lFilePosition;
|
||||
return SkipBytes(dwCount);
|
||||
}
|
||||
|
||||
LONG GetProgress()
|
||||
{
|
||||
if (0 >= m_lFileSize)
|
||||
return -1;
|
||||
|
||||
double dVal = (double)(100 * m_lFilePosition);
|
||||
LONG lProgress = (LONG)(dVal / m_lFileSize);
|
||||
return lProgress;
|
||||
}
|
||||
|
||||
void WriteStringUTF8(CString& strXml)
|
||||
{
|
||||
int nLength = strXml.GetLength();
|
||||
|
||||
CStringA saStr;
|
||||
|
||||
#ifdef UNICODE
|
||||
|
||||
WideCharToMultiByte(CP_UTF8, 0, strXml.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL);
|
||||
saStr.ReleaseBuffer();
|
||||
#else
|
||||
wchar_t* pWStr = new wchar_t[nLength + 1];
|
||||
if (!pWStr)
|
||||
return;
|
||||
|
||||
|
||||
pWStr[nLength] = 0;
|
||||
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, strXml, nLength, pWStr, nLength);
|
||||
|
||||
int nLengthW = (int)wcslen(pWStr);
|
||||
|
||||
|
||||
WideCharToMultiByte(CP_UTF8, 0, pWStr, nLengthW + 1, saStr.GetBuffer(nLengthW*3 + 1), nLengthW*3, NULL, NULL);
|
||||
saStr.ReleaseBuffer();
|
||||
|
||||
delete[] pWStr;
|
||||
#endif
|
||||
|
||||
WriteFile((void*)saStr.GetBuffer(), saStr.GetLength());
|
||||
}
|
||||
|
||||
protected:
|
||||
HANDLE m_hFileHandle;
|
||||
LONG64 m_lFileSize;
|
||||
LONG64 m_lFilePosition;
|
||||
};
|
||||
|
||||
namespace CDirectory
|
||||
{
|
||||
static CString GetFolderName(CString strFolderPath)
|
||||
{
|
||||
int n1 = strFolderPath.ReverseFind('\\');
|
||||
if (-1 == n1)
|
||||
return _T("");
|
||||
|
||||
return strFolderPath.Mid(n1 + 1);
|
||||
}
|
||||
static CString GetFolderPath(CString strFolderPath)
|
||||
{
|
||||
int n1 = strFolderPath.ReverseFind('\\');
|
||||
if (-1 == n1)
|
||||
return _T("");
|
||||
|
||||
return strFolderPath.Mid(0, n1);
|
||||
}
|
||||
static BOOL OpenFile(CString strFolderPath, CString strFileName, CFile* pFile)
|
||||
{
|
||||
CString strFile = strFolderPath + '\\' + strFileName;
|
||||
return (S_OK == pFile->OpenFile(strFile));
|
||||
}
|
||||
static BOOL CreateFile(CString strFolderPath, CString strFileName, CFile* pFile)
|
||||
{
|
||||
CString strFile = strFolderPath + '\\' + strFileName;
|
||||
return (S_OK == pFile->CreateFile(strFile));
|
||||
}
|
||||
static BOOL CreateDirectory(CString strFolderPathRoot, CString strFolderName)
|
||||
{
|
||||
CString strFolder = strFolderPathRoot + '\\' + strFolderName;
|
||||
return ::CreateDirectory(strFolder, NULL);
|
||||
}
|
||||
static BOOL CreateDirectory(CString strFolderPath)
|
||||
{
|
||||
return ::CreateDirectory(strFolderPath, NULL);
|
||||
}
|
||||
|
||||
static BOOL MoveFile(CString strExists, CString strNew, LPPROGRESS_ROUTINE lpFunc, LPVOID lpData)
|
||||
{
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
return ::MoveFileWithProgress(strExists, strNew, lpFunc, lpData, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
|
||||
#else
|
||||
return ::MoveFileEx(strExists, strNew, MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL CopyFile(CString strExists, CString strNew, LPPROGRESS_ROUTINE lpFunc, LPVOID lpData)
|
||||
{
|
||||
DeleteFile(strNew);
|
||||
return ::CopyFileEx(strExists, strNew, lpFunc, lpData, FALSE, 0);
|
||||
}
|
||||
|
||||
static CString GetUnder(CString strFolderPathRoot, CString strFolderName)
|
||||
{
|
||||
CString strFolder = strFolderPathRoot + '\\' + strFolderName;
|
||||
return strFolder;
|
||||
}
|
||||
|
||||
static CString GetFileName(CString strFullName)
|
||||
{
|
||||
int nStart = strFullName.ReverseFind('\\');
|
||||
CString strName = strFullName.Mid(nStart + 1);
|
||||
return strName;
|
||||
}
|
||||
|
||||
static CString BYTEArrayToString(BYTE* arr, size_t nCount)
|
||||
{
|
||||
CString str;
|
||||
for (size_t index = 0; index < nCount; ++index)
|
||||
{
|
||||
if ('\0' != (char)(arr[index]))
|
||||
str += (char)(arr[index]);
|
||||
}
|
||||
if (str.GetLength() == 0)
|
||||
str = _T("0");
|
||||
return str;
|
||||
}
|
||||
|
||||
static CStringW BYTEArrayToStringW(BYTE* arr, size_t nCount)
|
||||
{
|
||||
CStringW str;
|
||||
wchar_t* pArr = (wchar_t*)arr;
|
||||
size_t nCountNew = nCount / 2;
|
||||
for (size_t index = 0; index < nCountNew; ++index)
|
||||
{
|
||||
str += pArr[index];
|
||||
}
|
||||
if (str.GetLength() == 0)
|
||||
str = _T("0");
|
||||
return str;
|
||||
}
|
||||
|
||||
static CString BYTEArrayToString2(USHORT* arr, size_t nCount)
|
||||
{
|
||||
CString str;
|
||||
for (size_t index = 0; index < nCount; ++index)
|
||||
{
|
||||
if ('\0' != (char)(arr[index]))
|
||||
str += (char)(arr[index]);
|
||||
}
|
||||
if (str.GetLength() == 0)
|
||||
str = _T("0");
|
||||
return str;
|
||||
}
|
||||
|
||||
static CString ToString(DWORD val)
|
||||
{
|
||||
CString str = _T("");
|
||||
str.Format(_T("%d"), (LONG)val);
|
||||
return str;
|
||||
}
|
||||
|
||||
static CString ToString(UINT64 val, bool bInit)
|
||||
{
|
||||
CString strCoarse = ToString((DWORD)(val >> 32));
|
||||
if (_T("0") != strCoarse)
|
||||
{
|
||||
return strCoarse + ToString((DWORD)val);
|
||||
}
|
||||
|
||||
return ToString((DWORD)val);
|
||||
}
|
||||
|
||||
static UINT64 GetUINT64(CString strVal)
|
||||
{
|
||||
UINT64 nRet = 0;
|
||||
int nLen = strVal.GetLength();
|
||||
while (nLen > 0)
|
||||
{
|
||||
int nDig = XmlUtils::GetDigit(strVal[0]);
|
||||
nRet *= 10;
|
||||
nRet += nDig;
|
||||
strVal.Delete(0);
|
||||
--nLen;
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
static UINT GetUINT(CString strVal)
|
||||
{
|
||||
return (UINT)GetUINT64(strVal);
|
||||
}
|
||||
|
||||
static void WriteValueToNode(CString strName, DWORD value, XmlUtils::CXmlWriter* pWriter)
|
||||
{
|
||||
pWriter->WriteNodeBegin(strName);
|
||||
pWriter->WriteString(CDirectory::ToString(value));
|
||||
pWriter->WriteNodeEnd(strName);
|
||||
}
|
||||
static void WriteValueToNode(CString strName, LONG value, XmlUtils::CXmlWriter* pWriter)
|
||||
{
|
||||
pWriter->WriteNodeBegin(strName);
|
||||
CString strLONG = _T("");
|
||||
strLONG.Format(_T("%d"), value);
|
||||
pWriter->WriteString(strLONG);
|
||||
pWriter->WriteNodeEnd(strName);
|
||||
}
|
||||
static void WriteValueToNode(CString strName, CString value, XmlUtils::CXmlWriter* pWriter)
|
||||
{
|
||||
pWriter->WriteNodeBegin(strName);
|
||||
pWriter->WriteString(value);
|
||||
pWriter->WriteNodeEnd(strName);
|
||||
}
|
||||
static void WriteValueToNode(CString strName, WCHAR value, XmlUtils::CXmlWriter* pWriter)
|
||||
{
|
||||
CString str(value);
|
||||
|
||||
pWriter->WriteNodeBegin(strName);
|
||||
pWriter->WriteString(str);
|
||||
pWriter->WriteNodeEnd(strName);
|
||||
}
|
||||
static void WriteValueToNode(CString strName, bool value, XmlUtils::CXmlWriter* pWriter)
|
||||
{
|
||||
pWriter->WriteNodeBegin(strName);
|
||||
CString str = (true == value) ? _T("1") : _T("0");
|
||||
pWriter->WriteString(str);
|
||||
pWriter->WriteNodeEnd(strName);
|
||||
}
|
||||
static double FixedPointToDouble(DWORD point)
|
||||
{
|
||||
double dVal = (double)(point % 65536) / 65536;
|
||||
dVal += (point / 65536);
|
||||
return dVal;
|
||||
}
|
||||
static LONG NormFixedPoint(DWORD point, LONG base)
|
||||
{
|
||||
return (LONG)(FixedPointToDouble(point) * base);
|
||||
}
|
||||
static void SaveToFile(CString strFileName, CString strXml)
|
||||
{
|
||||
int nLength = strXml.GetLength();
|
||||
|
||||
CStringA saStr;
|
||||
|
||||
#ifdef UNICODE
|
||||
|
||||
WideCharToMultiByte(CP_UTF8, 0, strXml.GetBuffer(), nLength + 1, saStr.GetBuffer(nLength*3 + 1), nLength*3, NULL, NULL);
|
||||
saStr.ReleaseBuffer();
|
||||
#else
|
||||
wchar_t* pWStr = new wchar_t[nLength + 1];
|
||||
if (!pWStr)
|
||||
return;
|
||||
|
||||
|
||||
pWStr[nLength] = 0;
|
||||
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, strXml, nLength, pWStr, nLength);
|
||||
|
||||
int nLengthW = (int)wcslen(pWStr);
|
||||
|
||||
|
||||
WideCharToMultiByte(CP_UTF8, 0, pWStr, nLengthW + 1, saStr.GetBuffer(nLengthW*3 + 1), nLengthW*3, NULL, NULL);
|
||||
saStr.ReleaseBuffer();
|
||||
|
||||
delete[] pWStr;
|
||||
#endif
|
||||
|
||||
CFile oFile;
|
||||
oFile.CreateFile(strFileName);
|
||||
oFile.WriteFile((void*)saStr.GetBuffer(), saStr.GetLength());
|
||||
oFile.CloseFile();
|
||||
}
|
||||
|
||||
static void SaveToFile2(CString strFileName, CStringA strVal)
|
||||
{
|
||||
CFile oFile;
|
||||
HRESULT hr = oFile.OpenFileRW(strFileName);
|
||||
|
||||
if (S_OK != hr)
|
||||
oFile.CreateFile(strFileName);
|
||||
|
||||
oFile.SkipBytes(oFile.GetFileSize());
|
||||
oFile.WriteFile((void*)strVal.GetBuffer(), strVal.GetLength());
|
||||
oFile.CloseFile();
|
||||
}
|
||||
}
|
||||
|
||||
namespace StreamUtils
|
||||
{
|
||||
static BYTE ReadBYTE(IStream* pStream)
|
||||
{
|
||||
BYTE lMem = 0;
|
||||
ULONG lReadByte = 0;
|
||||
pStream->Read(&lMem, 1, &lReadByte);
|
||||
if (lReadByte < 1)
|
||||
{
|
||||
lMem = 0;
|
||||
}
|
||||
return lMem;
|
||||
}
|
||||
static WORD ReadWORD(IStream* pStream)
|
||||
{
|
||||
WORD lWord = 0;
|
||||
BYTE pMem[2];
|
||||
ULONG lReadByte = 0;
|
||||
pStream->Read(pMem, 2, &lReadByte);
|
||||
if (lReadByte == 2)
|
||||
{
|
||||
lWord = ((pMem[1] << 8) | pMem[0]);
|
||||
}
|
||||
return lWord;
|
||||
}
|
||||
static DWORD ReadDWORD(IStream* pStream)
|
||||
{
|
||||
DWORD lDWord = 0;
|
||||
BYTE pMem[4];
|
||||
ULONG lReadByte = 0;
|
||||
pStream->Read(pMem, 4, &lReadByte);
|
||||
|
||||
#ifdef _DEBUG
|
||||
ATLASSERT(4 == lReadByte);
|
||||
#endif
|
||||
|
||||
if (lReadByte == 4)
|
||||
{
|
||||
lDWord = ((pMem[3] << 24) | (pMem[2] << 16) | (pMem[1] << 8) | pMem[0]);
|
||||
}
|
||||
return lDWord;
|
||||
}
|
||||
static SHORT ReadSHORT(IStream* pStream)
|
||||
{
|
||||
return (SHORT)ReadWORD(pStream);
|
||||
}
|
||||
static LONG ReadLONG(IStream* pStream)
|
||||
{
|
||||
return (LONG)ReadDWORD(pStream);
|
||||
}
|
||||
|
||||
static FLOAT ReadFLOAT ( IStream* pStream )
|
||||
{
|
||||
FLOAT Value = 0.0f;
|
||||
pStream->Read ( &Value, sizeof (FLOAT), NULL );
|
||||
return Value;
|
||||
}
|
||||
|
||||
static CString ReadCString(IStream* pStream, LONG lLen)
|
||||
{
|
||||
char* pData = new char[lLen + 1];
|
||||
ULONG lReadByte = 0;
|
||||
pStream->Read(pData, lLen, &lReadByte);
|
||||
|
||||
pData[lLen] = 0;
|
||||
|
||||
CString str(pData);
|
||||
|
||||
delete[] pData;
|
||||
return str;
|
||||
}
|
||||
static CStringW ReadCStringW(IStream* pStream, LONG lLen)
|
||||
{
|
||||
wchar_t* pData = new wchar_t[lLen + 1];
|
||||
ULONG lReadByte = 0;
|
||||
pStream->Read(pData, 2 * lLen, &lReadByte);
|
||||
|
||||
pData[lLen] = 0;
|
||||
|
||||
CStringW str(pData);
|
||||
delete[] pData;
|
||||
return str;
|
||||
}
|
||||
static CString ConvertCStringWToCString(CStringW& strW)
|
||||
{
|
||||
|
||||
|
||||
|
||||
BSTR bstr = strW.AllocSysString();
|
||||
CString str(bstr);
|
||||
SysFreeString(bstr);
|
||||
|
||||
return str;
|
||||
}
|
||||
static void StreamSeek(long lOffset, IStream* pStream)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
li.LowPart = lOffset;
|
||||
li.HighPart = 0;
|
||||
pStream->Seek(li, STREAM_SEEK_SET, NULL);
|
||||
}
|
||||
static void StreamPosition(long& lPosition, IStream* pStream)
|
||||
{
|
||||
ULARGE_INTEGER uli;
|
||||
LARGE_INTEGER li;
|
||||
li.LowPart = 0;
|
||||
li.HighPart = 0;
|
||||
pStream->Seek(li, STREAM_SEEK_CUR, &uli);
|
||||
lPosition = (LONG)uli.LowPart;
|
||||
}
|
||||
static void StreamSkip(long lCount, IStream* pStream)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
li.LowPart = lCount;
|
||||
li.HighPart = 0;
|
||||
pStream->Seek(li, STREAM_SEEK_CUR, NULL);
|
||||
}
|
||||
static void StreamSkipBack(long lCount, IStream* pStream)
|
||||
{
|
||||
ULARGE_INTEGER ulPos;
|
||||
LARGE_INTEGER li;
|
||||
li.LowPart = 0;
|
||||
li.HighPart = 0;
|
||||
pStream->Seek(li, STREAM_SEEK_CUR, &ulPos);
|
||||
|
||||
StreamSeek((long)(ulPos.LowPart - lCount), pStream);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "Directory.h"
|
||||
|
||||
#include <shlobj.h>
|
||||
|
||||
namespace FileSystem {
|
||||
LPCTSTR Directory::GetCurrentDirectory() {
|
||||
static const int bufferSize = MAX_PATH;
|
||||
LPTSTR directory = new TCHAR[bufferSize];
|
||||
|
||||
DWORD lenght = ::GetCurrentDirectory(bufferSize, directory);
|
||||
if (lenght == 0) {
|
||||
delete[] directory;
|
||||
directory = NULL;
|
||||
}
|
||||
|
||||
return directory;
|
||||
}
|
||||
String Directory::GetCurrentDirectoryS() {
|
||||
LPCTSTR directory = GetCurrentDirectory();
|
||||
if (directory == NULL)
|
||||
return String();
|
||||
|
||||
return String(directory);
|
||||
}
|
||||
|
||||
bool Directory::CreateDirectory(LPCTSTR path) {
|
||||
bool directoryCreated = false;
|
||||
if (::CreateDirectory(path, NULL) == TRUE)
|
||||
directoryCreated = true;
|
||||
return directoryCreated;
|
||||
}
|
||||
bool Directory::CreateDirectory(const String& path) {
|
||||
return CreateDirectory(path.c_str());
|
||||
}
|
||||
bool Directory::CreateDirectories(LPCTSTR path)
|
||||
{
|
||||
int codeResult = ERROR_SUCCESS;
|
||||
|
||||
codeResult = SHCreateDirectory(NULL, path);
|
||||
|
||||
bool created = false;
|
||||
if (codeResult == ERROR_SUCCESS)
|
||||
created = true;
|
||||
|
||||
return created;
|
||||
}
|
||||
|
||||
StringArray Directory::GetFilesInDirectory(LPCTSTR path, const bool& andSubdirectories) {
|
||||
size_t pathLength = 0;
|
||||
StringCchLength(path, MAX_PATH, &pathLength);
|
||||
++pathLength;
|
||||
size_t pathToFilesLength = pathLength + 3;
|
||||
LPTSTR pathToFiles = new TCHAR[pathToFilesLength];
|
||||
|
||||
StringCchCopy(pathToFiles, pathLength, path);
|
||||
StringCchCat(pathToFiles, pathToFilesLength, TEXT("\\*"));
|
||||
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE findResult = FindFirstFile(pathToFiles, &findData);
|
||||
delete[] pathToFiles;
|
||||
|
||||
if (findResult == INVALID_HANDLE_VALUE)
|
||||
return StringArray();
|
||||
|
||||
StringArray files;
|
||||
do {
|
||||
if (andSubdirectories || !(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
String file = findData.cFileName;
|
||||
files.insert(files.end(), file);
|
||||
}
|
||||
} while (FindNextFile(findResult, &findData));
|
||||
|
||||
FindClose(findResult);
|
||||
|
||||
return files;
|
||||
}
|
||||
StringArray Directory::GetFilesInDirectory(const String& path, const bool& andSubdirectories) {
|
||||
LPCTSTR pathW = path.c_str();
|
||||
return GetFilesInDirectory(pathW, andSubdirectories);
|
||||
}
|
||||
|
||||
int Directory::GetFilesCount(const CString& path, const bool& recursive) {
|
||||
CString pathMask = path + _T("\\*");
|
||||
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE findResult = FindFirstFile(pathMask, &findData);
|
||||
|
||||
int filesCount = 0;
|
||||
do {
|
||||
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
if (!recursive)
|
||||
continue;
|
||||
if ((CString) findData.cFileName == _T("."))
|
||||
continue;
|
||||
if ((CString) findData.cFileName == _T(".."))
|
||||
continue;
|
||||
CString innerPath = path + _T('\\') + (CString) findData.cFileName;
|
||||
filesCount += GetFilesCount(innerPath, recursive);
|
||||
}
|
||||
else
|
||||
++filesCount;
|
||||
} while (FindNextFile(findResult, &findData));
|
||||
|
||||
FindClose(findResult);
|
||||
|
||||
return filesCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Settings.h"
|
||||
#include <windows.h>
|
||||
|
||||
#include <tchar.h>
|
||||
#include <atlbase.h>
|
||||
#include <atlconv.h>
|
||||
#include <atlstr.h>
|
||||
|
||||
#include <tchar.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
namespace FileSystem {
|
||||
class Directory {
|
||||
public:
|
||||
static LPCTSTR GetCurrentDirectory();
|
||||
static String GetCurrentDirectoryS();
|
||||
|
||||
static bool CreateDirectory(LPCTSTR path);
|
||||
static bool CreateDirectory(const String& path);
|
||||
static bool CreateDirectories(LPCTSTR path);
|
||||
|
||||
static StringArray GetFilesInDirectory(LPCTSTR path, const bool& andSubdirectories = false);
|
||||
static StringArray GetFilesInDirectory(const String& path, const bool& andSubdirectories = false);
|
||||
|
||||
static int GetFilesCount(const CString& path, const bool& recursive = false);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "File.h"
|
||||
|
||||
namespace FileSystem {
|
||||
bool File::Exists(LPCTSTR path) {
|
||||
WIN32_FIND_DATA findData;
|
||||
ZeroMemory(&findData, sizeof(findData));
|
||||
|
||||
HANDLE handle = ::FindFirstFile(path, &findData);
|
||||
|
||||
bool fileExists = true;
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
fileExists = false;
|
||||
FindClose(handle);
|
||||
|
||||
return fileExists;
|
||||
}
|
||||
bool File::Exists(const String& path) {
|
||||
return Exists(path.c_str());
|
||||
}
|
||||
|
||||
void File::Create(LPCTSTR path) {
|
||||
CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
}
|
||||
void File::Create(const String& path) {
|
||||
Create(path.c_str());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Settings.h"
|
||||
#include <windows.h>
|
||||
|
||||
namespace FileSystem {
|
||||
class File {
|
||||
public:
|
||||
static bool Exists(LPCTSTR path);
|
||||
static bool Exists(const String& path);
|
||||
|
||||
static void Create(LPCTSTR path);
|
||||
static void Create(const String& path);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Settings.h"
|
||||
#include "File.h"
|
||||
#include "Directory.h"
|
||||
|
||||
namespace FileSystem {
|
||||
class File;
|
||||
class Directory;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace FileSystem {
|
||||
#ifdef UNICODE
|
||||
typedef std::wstring String;
|
||||
#else
|
||||
typedef std::wstring String;
|
||||
#endif
|
||||
typedef std::vector<String> StringArray;
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="FileSystem"
|
||||
ProjectGUID="{17F96D53-A98B-4F0F-86CC-BA70834306E5}"
|
||||
RootNamespace="FileSystem"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
ManagedExtensions="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="0"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
ManagedExtensions="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="File and Directory"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\FileSystem\Directory.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\FileSystem\Directory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\FileSystem\File.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\FileSystem\File.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="..\..\FileSystem\FileSystem.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\FileSystem\Settings.h"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "stdafx.h"
|
||||
|
||||
using namespace System::Reflection;
|
||||
using namespace System::Runtime::CompilerServices;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[assembly:AssemblyTitleAttribute("FileSystemTest")];
|
||||
[assembly:AssemblyDescriptionAttribute("")];
|
||||
[assembly:AssemblyConfigurationAttribute("")];
|
||||
[assembly:AssemblyCompanyAttribute("")];
|
||||
[assembly:AssemblyProductAttribute("FileSystemTest")];
|
||||
[assembly:AssemblyCopyrightAttribute("Copyright (c) 2011")];
|
||||
[assembly:AssemblyTrademarkAttribute("")];
|
||||
[assembly:AssemblyCultureAttribute("")];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[assembly:AssemblyVersionAttribute("1.0.*")];
|
||||
[assembly:ComVisible(false)];
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "stdafx.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
|
||||
using FileSystem::String;
|
||||
using FileSystem::Directory;
|
||||
using FileSystem::StringArray;
|
||||
|
||||
namespace FileSystemTest {
|
||||
[TestClass]
|
||||
public ref class DirectoryTest {
|
||||
private:
|
||||
TestContext^ testContextInstance;
|
||||
|
||||
public:
|
||||
property Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ TestContext {
|
||||
Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ get() {
|
||||
return testContextInstance;
|
||||
}
|
||||
System::Void set(Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ value) {
|
||||
testContextInstance = value;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
[TestMethod]
|
||||
void CurrentDirectoryStringIsNotEmpty() {
|
||||
String path = Directory::GetCurrentDirectoryS();
|
||||
Assert::IsFalse(path.empty());
|
||||
};
|
||||
|
||||
[TestMethod]
|
||||
void CreateNewDirectoryInCurrent() {
|
||||
String currentDir = Directory::GetCurrentDirectoryS();
|
||||
String newDir = currentDir + TEXT("\\new_dir_1");
|
||||
Directory::CreateDirectory(newDir);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
void FilesListOfNewDirectoryIsEmpty() {
|
||||
String currentDir = Directory::GetCurrentDirectoryS();
|
||||
String newDir = currentDir + TEXT("\\new_dir_1");
|
||||
Directory::CreateDirectory(newDir);
|
||||
StringArray files = Directory::GetFilesInDirectory(newDir);
|
||||
Assert::IsTrue(files.empty());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
void FilesListOfDirectoryWithFewItemsIsNotEmpty() {
|
||||
String path = Directory::GetCurrentDirectoryS();
|
||||
StringArray files = Directory::GetFilesInDirectory(path);
|
||||
Assert::IsFalse(files.empty());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
void InSubdirectoryFilesAndFoldersMoreThanOnlyFiles() {
|
||||
String path = Directory::GetCurrentDirectoryS();
|
||||
StringArray files = Directory::GetFilesInDirectory(path);
|
||||
int filesAmount = (int) files.size();
|
||||
StringArray filesAndFolders = Directory::GetFilesInDirectory(path, true);
|
||||
int filesAndFoldersAmount = (int) filesAndFolders.size();
|
||||
Assert::IsTrue(filesAndFoldersAmount > filesAmount);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
void CountFilesInDirectory() {
|
||||
CString path = (CString) Directory::GetCurrentDirectoryS().c_str();
|
||||
Directory::CreateDirectories(path + _T("\\temp_ dir"));
|
||||
int count = Directory::GetFilesCount(path);
|
||||
Assert::IsTrue(count > 0);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="FileSystemTest"
|
||||
ProjectTypes="{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
|
||||
ProjectGUID="{8F99D931-CE38-4005-979B-E5784918778C}"
|
||||
RootNamespace="FileSystemTest"
|
||||
Keyword="ManagedCProj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
ManagedExtensions="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="$(SolutionDir)\.."
|
||||
PreprocessorDefinitions="WIN32;_DEBUG"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shell32.lib $(NOINHERIT)"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
AssemblyDebug="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist app.config copy app.config "$(OutDir)\app.config""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
ManagedExtensions="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="$(NoInherit)"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="if exist app.config copy app.config "$(OutDir)\app.config""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
<AssemblyReference
|
||||
RelativePath="System.dll"
|
||||
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
<AssemblyReference
|
||||
RelativePath="System.Data.dll"
|
||||
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
<AssemblyReference
|
||||
RelativePath="System.XML.dll"
|
||||
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
<AssemblyReference
|
||||
RelativePath="Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll"
|
||||
AssemblyName="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
|
||||
MinFrameworkVersion="131072"
|
||||
/>
|
||||
<ProjectReference
|
||||
ReferencedProjectIdentifier="{17F96D53-A98B-4F0F-86CC-BA70834306E5}"
|
||||
UseInBuild="false"
|
||||
UseDependenciesInBuild="false"
|
||||
RelativePathToProject=".\FileSystem\FileSystem.vcproj"
|
||||
/>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\AssemblyInfo.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\app.ico"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\app.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Tests"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\DirectoryTest.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,52 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon placed first or with lowest ID value becomes application icon
|
||||
|
||||
LANGUAGE 25, 1
|
||||
#pragma code_page(1252)
|
||||
1 ICON "app.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by app.rc
|
||||
@@ -0,0 +1,5 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// FileSystemTest.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
@@ -0,0 +1,9 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently,
|
||||
// but are changed infrequently
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atlstr.h>
|
||||
|
||||
#include "FileSystem/FileSystem.h"
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SystemUtility", "SystemUtility\SystemUtility.vcproj", "{641253E6-F994-4A36-9FA6-FDA44C76ECC4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileSystem", "FileSystem\FileSystem.vcproj", "{17F96D53-A98B-4F0F-86CC-BA70834306E5}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileSystemTest", "FileSystemTest\FileSystemTest.vcproj", "{8F99D931-CE38-4005-979B-E5784918778C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8A386656-3E08-4E78-B5A9-D07F787A928E}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
LocalTestRun.testrunconfig = LocalTestRun.testrunconfig
|
||||
SystemUtility.vsmdi = SystemUtility.vsmdi
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||
CategoryFile = SystemUtility.vsmdi
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{641253E6-F994-4A36-9FA6-FDA44C76ECC4}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{641253E6-F994-4A36-9FA6-FDA44C76ECC4}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{641253E6-F994-4A36-9FA6-FDA44C76ECC4}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{641253E6-F994-4A36-9FA6-FDA44C76ECC4}.Release|Win32.Build.0 = Release|Win32
|
||||
{17F96D53-A98B-4F0F-86CC-BA70834306E5}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{17F96D53-A98B-4F0F-86CC-BA70834306E5}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{17F96D53-A98B-4F0F-86CC-BA70834306E5}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{17F96D53-A98B-4F0F-86CC-BA70834306E5}.Release|Win32.Build.0 = Release|Win32
|
||||
{8F99D931-CE38-4005-979B-E5784918778C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{8F99D931-CE38-4005-979B-E5784918778C}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{8F99D931-CE38-4005-979B-E5784918778C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{8F99D931-CE38-4005-979B-E5784918778C}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,184 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="SystemUtility"
|
||||
ProjectGUID="{641253E6-F994-4A36-9FA6-FDA44C76ECC4}"
|
||||
RootNamespace="SystemUtility"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="X:\AVS\Sources\AVSVideoStudio3\Common"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\SystemUtility.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\Base.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\File.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\SystemUtility.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
166
ActiveX/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp
Normal file
166
ActiveX/Common/DocxFormat/Source/SystemUtility/SystemUtility.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "SystemUtility.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "FileSystem/FileSystem.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
CPath::CPath() : m_strFilename(L"")
|
||||
{
|
||||
}
|
||||
CPath::CPath(const CString& sName, bool bIsNorm) : m_strFilename(sName)
|
||||
{
|
||||
if (bIsNorm)
|
||||
Normalize();
|
||||
}
|
||||
CPath::CPath(LPCSTR& sName, bool bIsNorm) : m_strFilename(sName)
|
||||
{
|
||||
if (bIsNorm)
|
||||
Normalize();
|
||||
}
|
||||
CPath::CPath(LPCWSTR& sName, bool bIsNorm) : m_strFilename(sName)
|
||||
{
|
||||
if (bIsNorm)
|
||||
Normalize();
|
||||
}
|
||||
|
||||
CPath::CPath(const CPath& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
|
||||
|
||||
}
|
||||
|
||||
CPath& CPath::operator=(const CPath& oSrc)
|
||||
{
|
||||
m_strFilename = oSrc.m_strFilename;
|
||||
|
||||
|
||||
return *this;
|
||||
}
|
||||
CPath& CPath::operator=(const CString& oSrc)
|
||||
{
|
||||
m_strFilename = oSrc;
|
||||
Normalize();
|
||||
return *this;
|
||||
}
|
||||
|
||||
AVSINLINE CString CPath::GetExtention(bool bIsPoint) const
|
||||
{
|
||||
int nFind = m_strFilename.ReverseFind('.');
|
||||
if (-1 == nFind)
|
||||
return _T("");
|
||||
|
||||
if (!bIsPoint)
|
||||
++nFind;
|
||||
|
||||
return m_strFilename.Mid(nFind);
|
||||
}
|
||||
AVSINLINE CString CPath::GetDirectory(bool bIsSlash) const
|
||||
{
|
||||
int nPos = m_strFilename.ReverseFind('\\');
|
||||
if (-1 == nPos)
|
||||
{
|
||||
return m_strFilename;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bIsSlash)
|
||||
++nPos;
|
||||
return m_strFilename.Mid(0, nPos);
|
||||
}
|
||||
}
|
||||
AVSINLINE CString CPath::GetPath() const
|
||||
{
|
||||
return m_strFilename;
|
||||
}
|
||||
}
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
bool CSystemUtility::CreateFile(const CString& strFileName)
|
||||
{
|
||||
BSTR strPath = strFileName.AllocSysString();
|
||||
HANDLE hResult = ::CreateFile(strPath, GENERIC_READ, 0, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
SysFreeString(strPath);
|
||||
|
||||
if (hResult == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
if (!CloseHandle(hResult))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSystemUtility::IsFileExist(const CString& strFileName)
|
||||
{
|
||||
return FileSystem::File::Exists(strFileName);
|
||||
}
|
||||
bool CSystemUtility::IsFileExist(const CPath& oPath)
|
||||
{
|
||||
return IsFileExist(oPath.GetPath());
|
||||
}
|
||||
|
||||
CString CSystemUtility::GetDirectoryName(const CString& strFileName)
|
||||
{
|
||||
CPath oPath(strFileName);
|
||||
return oPath.GetDirectory();
|
||||
}
|
||||
|
||||
int CSystemUtility::GetFilesCount(const CString& strDirPath, const bool& bRecursive)
|
||||
{
|
||||
return FileSystem::Directory::GetFilesCount(strDirPath, bRecursive);
|
||||
}
|
||||
|
||||
CString CSystemUtility::GetFileExtention(const CString& strFileName)
|
||||
{
|
||||
CPath oPath(strFileName);
|
||||
return oPath.GetExtention();
|
||||
}
|
||||
|
||||
bool CSystemUtility::CreateDirectories(const CPath& oPath)
|
||||
{
|
||||
return FileSystem::Directory::CreateDirectories(oPath.m_strFilename);
|
||||
}
|
||||
|
||||
void CSystemUtility::ReplaceExtention(CString& strName, CString& str1, CString& str2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
186
ActiveX/Common/DocxFormat/Source/SystemUtility/SystemUtility.h
Normal file
186
ActiveX/Common/DocxFormat/Source/SystemUtility/SystemUtility.h
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../Base/Base.h"
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
class CPath
|
||||
{
|
||||
public:
|
||||
CString m_strFilename;
|
||||
|
||||
public:
|
||||
CPath();
|
||||
CPath(const CString& sName, bool bIsNorm = true);
|
||||
CPath(LPCSTR& sName, bool bIsNorm = true);
|
||||
CPath(LPCWSTR& sName, bool bIsNorm = true);
|
||||
|
||||
CPath(const CPath& oSrc);
|
||||
|
||||
CPath& operator=(const CPath& oSrc);
|
||||
CPath& operator=(const CString& oSrc);
|
||||
|
||||
friend CPath operator/(const CPath& path1, const CPath& path2)
|
||||
{
|
||||
CPath path(path1.m_strFilename + _T("//") + path2.m_strFilename);
|
||||
path.Normalize();
|
||||
|
||||
return path;
|
||||
}
|
||||
friend CPath operator/(const CPath& path1, const CString& path2)
|
||||
{
|
||||
CPath path(path1.m_strFilename + _T("//") + path2);
|
||||
path.Normalize();
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
friend CPath operator+(const CPath& path1, const CPath& path2)
|
||||
{
|
||||
CPath path(path1.m_strFilename + path2.m_strFilename);
|
||||
path.Normalize();
|
||||
return path;
|
||||
}
|
||||
friend CPath operator+(const CPath& path1, const CString& path2)
|
||||
{
|
||||
CPath path(path1.m_strFilename + path2);
|
||||
path.Normalize();
|
||||
return path;
|
||||
}
|
||||
friend CPath operator+(const CString& path1, const CPath& path2)
|
||||
{
|
||||
CPath path(path1 + path2.m_strFilename);
|
||||
path.Normalize();
|
||||
return path;
|
||||
}
|
||||
|
||||
AVSINLINE CString GetExtention(bool bIsPoint = true) const;
|
||||
AVSINLINE CString GetDirectory(bool bIsSlash = true) const;
|
||||
AVSINLINE CString GetPath() const;
|
||||
AVSINLINE CString GetFilename() const
|
||||
{
|
||||
int nPos = m_strFilename.ReverseFind('\\');
|
||||
if (-1 == nPos)
|
||||
{
|
||||
return m_strFilename;
|
||||
}
|
||||
else
|
||||
{
|
||||
int nLast = (int) m_strFilename.GetLength();
|
||||
return m_strFilename.Mid(nPos + 1, nLast);
|
||||
}
|
||||
}
|
||||
|
||||
AVSINLINE void Normalize()
|
||||
{
|
||||
if (0 == m_strFilename.GetLength())
|
||||
return;
|
||||
|
||||
TCHAR* pData = m_strFilename.GetBuffer();
|
||||
int nLen = m_strFilename.GetLength();
|
||||
|
||||
TCHAR* pDataNorm = new TCHAR[nLen + 1];
|
||||
int* pSlashPoints = new int[nLen + 1];
|
||||
|
||||
int nStart = 0;
|
||||
int nCurrent = 0;
|
||||
int nCurrentSlash = -1;
|
||||
int nCurrentW = 0;
|
||||
bool bIsUp = false;
|
||||
|
||||
while (nCurrent < nLen)
|
||||
{
|
||||
if (pData[nCurrent] == (TCHAR)'\\' || pData[nCurrent] == (TCHAR)'/')
|
||||
{
|
||||
if (nStart < nCurrent)
|
||||
{
|
||||
bIsUp = false;
|
||||
if ((nCurrent - nStart) == 2)
|
||||
{
|
||||
if (pData[nStart] == (TCHAR)'.' && pData[nStart + 1] == (TCHAR)'.')
|
||||
{
|
||||
if (nCurrentSlash > 0)
|
||||
{
|
||||
--nCurrentSlash;
|
||||
nCurrentW = pSlashPoints[nCurrentSlash];
|
||||
bIsUp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bIsUp)
|
||||
{
|
||||
pDataNorm[nCurrentW++] = (TCHAR)'\\';
|
||||
++nCurrentSlash;
|
||||
pSlashPoints[nCurrentSlash] = nCurrentW;
|
||||
}
|
||||
}
|
||||
nStart = nCurrent + 1;
|
||||
++nCurrent;
|
||||
continue;
|
||||
}
|
||||
pDataNorm[nCurrentW++] = pData[nCurrent];
|
||||
++nCurrent;
|
||||
}
|
||||
|
||||
pDataNorm[nCurrentW] = (TCHAR)'\0';
|
||||
|
||||
m_strFilename.ReleaseBuffer();
|
||||
m_strFilename = CString(pDataNorm, nCurrentW);
|
||||
|
||||
delete []pSlashPoints;
|
||||
delete []pDataNorm;
|
||||
|
||||
|
||||
}
|
||||
void SetName(CString sName, bool bNormalize)
|
||||
{
|
||||
m_strFilename = sName;
|
||||
if(bNormalize)
|
||||
Normalize();
|
||||
}
|
||||
};
|
||||
|
||||
class CSystemUtility
|
||||
{
|
||||
public:
|
||||
static bool CreateFile(const CString& strFileName);
|
||||
static bool IsFileExist(const CString& strFileName);
|
||||
static bool IsFileExist(const CPath& sPath);
|
||||
static CString GetDirectoryName(const CString& strFileName);
|
||||
static int GetFilesCount(const CString& strDirPath, const bool& bRecursive = false);
|
||||
static CString GetFileExtention(const CString& strFileName);
|
||||
static bool CreateDirectories(const CPath& oPath);
|
||||
static void ReplaceExtention(CString& strName, CString& str1, CString& str2);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user