Commit 2cbf60ce authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

везде кроме win32 & win64 символ "\" в именах файлах считается обычным символом

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@67478 954022d7-b5bf-4e40-9824-e11837661b57
parent 6f58c483
......@@ -101,6 +101,7 @@ namespace OOX
}
}
#if defined(_WIN32) || defined (_WIN64)
AVSINLINE void Normalize()
{
if (0 == m_strFilename.GetLength())
......@@ -117,10 +118,7 @@ namespace OOX
int nCurrentSlash = -1;
int nCurrentW = 0;
bool bIsUp = false;
#if !defined(_WIN32) && !defined (_WIN64)
if (pData[nCurrent] == (TCHAR)'/')
pDataNorm[nCurrentW++] = (TCHAR) FILE_SEPARATOR_CHAR;
#endif
while (nCurrent < nLen)
{
if (pData[nCurrent] == (TCHAR) '\\' || pData[nCurrent] == (TCHAR)'/')
......@@ -161,47 +159,87 @@ namespace OOX
m_strFilename = CString(pDataNorm, nCurrentW);
delete []pSlashPoints;
delete []pDataNorm;
/*
m_strFilename.Replace(_T("\\\\"), _T("\\"));
m_strFilename.Replace(TCHAR('/'), TCHAR('\\'));
delete []pDataNorm;
}
void CheckIsRoot()
{
if(m_strFilename.GetLength() > 0 && ('/' == m_strFilename[0] || '\\' == m_strFilename[0]))
m_bIsRoot = true;
else
m_bIsRoot = false;
}
#else
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];
std::vector<CString> arNames;
CString resToken;
int curPos= 0;
int nStart = 0;
int nCurrent = 0;
int nCurrentSlash = -1;
int nCurrentW = 0;
bool bIsUp = false;
bool bEndSlash = (m_strFilename.GetAt(m_strFilename.GetLength() - 1) == (TCHAR)'\\');
if (pData[nCurrent] == (TCHAR)'/')
pDataNorm[nCurrentW++] = (TCHAR) FILE_SEPARATOR_CHAR;
resToken = m_strFilename.Tokenize(_T("\\"), curPos);
while (resToken != _T(""))
while (nCurrent < nLen)
{
if (_T("..") == resToken)
if (pData[nCurrent] == (TCHAR)'/')
{
size_t nCount = arNames.GetCount();
if (0 < nCount)
arNames.RemoveAt(nCount - 1);
else
arNames.push_back(resToken);
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) FILE_SEPARATOR_CHAR;
++nCurrentSlash;
pSlashPoints[nCurrentSlash] = nCurrentW;
}
}
nStart = nCurrent + 1;
++nCurrent;
continue;
}
else
arNames.push_back(resToken);
resToken = m_strFilename.Tokenize(_T("\\"), curPos);
pDataNorm[nCurrentW++] = pData[nCurrent];
++nCurrent;
}
size_t nCount = arNames.GetCount();
m_strFilename = _T("");
for (size_t i = 0; i < nCount; ++i)
{
m_strFilename += arNames[i];
if (i != (nCount - 1))
m_strFilename += _T("\\");
}
pDataNorm[nCurrentW] = (TCHAR)'\0';
m_strFilename.ReleaseBuffer();
m_strFilename = CString(pDataNorm, nCurrentW);
if (bEndSlash)
m_strFilename += _T("\\");
*/
delete []pSlashPoints;
delete []pDataNorm;
}
void CheckIsRoot()
{
if(m_strFilename.GetLength() > 0 && ( '/' == m_strFilename[0] ))
m_bIsRoot = true;
else
m_bIsRoot = false;
}
#endif
void SetName(CString sName, bool bNormalize)
{
m_strFilename = sName;
......@@ -209,13 +247,7 @@ namespace OOX
if(bNormalize)
Normalize();
}
void CheckIsRoot()
{
if(m_strFilename.GetLength() > 0 && ('/' == m_strFilename[0] || '\\' == m_strFilename[0]))
m_bIsRoot = true;
else
m_bIsRoot = false;
}
bool GetIsRoot()
{
return m_bIsRoot;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment