Commit 90931b7a authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

.....

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62941 954022d7-b5bf-4e40-9824-e11837661b57
parent e88e98a6
...@@ -68,6 +68,15 @@ namespace FileSystem ...@@ -68,6 +68,15 @@ namespace FileSystem
return CString(pBuffer); return CString(pBuffer);
} }
std::wstring Directory::CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix)
{
TCHAR pBuffer [MAX_PATH+1];
memset (pBuffer, 0, sizeof (TCHAR) * (MAX_PATH+1));
/*unRet = */GetTempFileName( strFolderPathRoot.c_str(), Prefix.c_str(), 0,pBuffer);
return std::wstring(pBuffer);
}
CString Directory::GetLongPathName_(const CString& fileName) CString Directory::GetLongPathName_(const CString& fileName)
{ {
long length = GetLongPathNameW(fileName, NULL, 0); long length = GetLongPathNameW(fileName, NULL, 0);
...@@ -136,7 +145,33 @@ namespace FileSystem ...@@ -136,7 +145,33 @@ namespace FileSystem
} }
return pcTemplate; return pcTemplate;
} }
std::wstring Directory::CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot)
{
UUID uuid;
RPC_WSTR str_uuid;
UuidCreate (&uuid);
UuidToString (&uuid, &str_uuid);
std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (TCHAR *) str_uuid;
RpcStringFree (&str_uuid);
int attemps = 10;
while (!CreateDirectory(pcTemplate))
{
UuidCreate (&uuid);
UuidToString (&uuid, &str_uuid);
pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (TCHAR *) str_uuid;
RpcStringFree (&str_uuid);
attemps--;
if (0 == attemps)
{
pcTemplate = _T("");
}
}
return pcTemplate;
}
bool Directory::CreateDirectories(LPCTSTR path) bool Directory::CreateDirectories(LPCTSTR path)
{ {
DWORD dwAttrib = ::GetFileAttributesW(path); DWORD dwAttrib = ::GetFileAttributesW(path);
...@@ -248,33 +283,6 @@ namespace FileSystem ...@@ -248,33 +283,6 @@ namespace FileSystem
{ {
NSDirectory::DeleteDirectory(strDirectory, deleteRoot); NSDirectory::DeleteDirectory(strDirectory, deleteRoot);
} }
std::wstring Directory::CreateDirectoryWithUniqueName (std::wstring & strFolderPathRoot)
{
UUID uuid;
RPC_WSTR str_uuid;
UuidCreate (&uuid);
UuidToString (&uuid, &str_uuid);
std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (TCHAR *) str_uuid;
RpcStringFree (&str_uuid);
int attemps = 10;
while (!CreateDirectory(pcTemplate.c_str()))
{
UuidCreate (&uuid);
UuidToString (&uuid, &str_uuid);
pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (TCHAR *) str_uuid;
RpcStringFree (&str_uuid);
attemps--;
if (0 == attemps)
{
pcTemplate = _T("");
}
}
return pcTemplate;
}
#endif #endif
bool Directory::IsExist(const std::wstring& strFileName) bool Directory::IsExist(const std::wstring& strFileName)
{ {
......
...@@ -26,6 +26,7 @@ namespace FileSystem { ...@@ -26,6 +26,7 @@ namespace FileSystem {
static bool CreateDirectory(const String& path); static bool CreateDirectory(const String& path);
static bool CreateDirectory(String strFolderPathRoot, String strFolderName); static bool CreateDirectory(String strFolderPathRoot, String strFolderName);
static CString CreateDirectoryWithUniqueName (CString & strFolderPathRoot); static CString CreateDirectoryWithUniqueName (CString & strFolderPathRoot);
static std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot);
static bool CreateDirectories(LPCTSTR path); static bool CreateDirectories(LPCTSTR path);
static void DeleteDirectory(const CString& path, bool deleteRoot = true); static void DeleteDirectory(const CString& path, bool deleteRoot = true);
...@@ -38,15 +39,14 @@ namespace FileSystem { ...@@ -38,15 +39,14 @@ namespace FileSystem {
static CString GetFolderPath(const CString& path); static CString GetFolderPath(const CString& path);
static CString GetLongPathName_(const CString& fileName); static CString GetLongPathName_(const CString& fileName);
static CString GetTempPath(); static CString GetTempPath();
static CString CreateTempFileWithUniqueName (const CString & strFolderPathRoot,CString Prefix); static CString CreateTempFileWithUniqueName (const CString & strFolderPathRoot, CString Prefix);
static std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix);
static bool PathIsDirectory(const CString& pathName); static bool PathIsDirectory(const CString& pathName);
#if defined (_WIN32) || defined(_WIN64) #if defined (_WIN32) || defined(_WIN64)
static std::wstring GetFolderPath(const std::wstring & strFolderPath); static std::wstring GetFolderPath(const std::wstring & strFolderPath);
static void DeleteDirectory(std::wstring& path, bool deleteRoot = true); static void DeleteDirectory(std::wstring& path, bool deleteRoot = true);
#endif #endif
static std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot);
static bool IsExist(const std::wstring& strFileName); static bool IsExist(const std::wstring& strFileName);
}; };
} }
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