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 ...@@ -101,6 +101,7 @@ namespace OOX
} }
} }
#if defined(_WIN32) || defined (_WIN64)
AVSINLINE void Normalize() AVSINLINE void Normalize()
{ {
if (0 == m_strFilename.GetLength()) if (0 == m_strFilename.GetLength())
...@@ -117,10 +118,7 @@ namespace OOX ...@@ -117,10 +118,7 @@ namespace OOX
int nCurrentSlash = -1; int nCurrentSlash = -1;
int nCurrentW = 0; int nCurrentW = 0;
bool bIsUp = false; bool bIsUp = false;
#if !defined(_WIN32) && !defined (_WIN64)
if (pData[nCurrent] == (TCHAR)'/')
pDataNorm[nCurrentW++] = (TCHAR) FILE_SEPARATOR_CHAR;
#endif
while (nCurrent < nLen) while (nCurrent < nLen)
{ {
if (pData[nCurrent] == (TCHAR) '\\' || pData[nCurrent] == (TCHAR)'/') if (pData[nCurrent] == (TCHAR) '\\' || pData[nCurrent] == (TCHAR)'/')
...@@ -161,47 +159,87 @@ namespace OOX ...@@ -161,47 +159,87 @@ namespace OOX
m_strFilename = CString(pDataNorm, nCurrentW); m_strFilename = CString(pDataNorm, nCurrentW);
delete []pSlashPoints; delete []pSlashPoints;
delete []pDataNorm; delete []pDataNorm;
}
/* void CheckIsRoot()
m_strFilename.Replace(_T("\\\\"), _T("\\")); {
m_strFilename.Replace(TCHAR('/'), TCHAR('\\')); 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; int nStart = 0;
CString resToken; int nCurrent = 0;
int curPos= 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 (nCurrent < nLen)
while (resToken != _T(""))
{ {
if (_T("..") == resToken) if (pData[nCurrent] == (TCHAR)'/')
{ {
size_t nCount = arNames.GetCount(); if (nStart < nCurrent)
if (0 < nCount) {
arNames.RemoveAt(nCount - 1); bIsUp = false;
else if ((nCurrent - nStart) == 2)
arNames.push_back(resToken); {
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 pDataNorm[nCurrentW++] = pData[nCurrent];
arNames.push_back(resToken); ++nCurrent;
resToken = m_strFilename.Tokenize(_T("\\"), curPos);
} }
size_t nCount = arNames.GetCount(); pDataNorm[nCurrentW] = (TCHAR)'\0';
m_strFilename = _T("");
for (size_t i = 0; i < nCount; ++i) m_strFilename.ReleaseBuffer();
{ m_strFilename = CString(pDataNorm, nCurrentW);
m_strFilename += arNames[i];
if (i != (nCount - 1))
m_strFilename += _T("\\");
}
if (bEndSlash) delete []pSlashPoints;
m_strFilename += _T("\\"); 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) void SetName(CString sName, bool bNormalize)
{ {
m_strFilename = sName; m_strFilename = sName;
...@@ -209,13 +247,7 @@ namespace OOX ...@@ -209,13 +247,7 @@ namespace OOX
if(bNormalize) if(bNormalize)
Normalize(); Normalize();
} }
void CheckIsRoot()
{
if(m_strFilename.GetLength() > 0 && ('/' == m_strFilename[0] || '\\' == m_strFilename[0]))
m_bIsRoot = true;
else
m_bIsRoot = false;
}
bool GetIsRoot() bool GetIsRoot()
{ {
return m_bIsRoot; 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