Commit ee367b86 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

CreateTempFileWithUniqueName. взял реализацию с бранча DoctToDocx

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@61238 954022d7-b5bf-4e40-9824-e11837661b57
parent adde7e0a
......@@ -45,6 +45,15 @@ namespace FileSystem
strFolder += strFolderName;
return CreateDirectory(strFolder);
}
CString Directory::CreateTempFileWithUniqueName (const CString & strFolderPathRoot, CString Prefix)
{
TCHAR pBuffer [MAX_PATH+1];
memset (pBuffer, 0, sizeof (TCHAR) * (MAX_PATH+1));
/*unRet = */GetTempFileName( strFolderPathRoot.GetString(), Prefix.GetString(), 0,pBuffer);
return CString(pBuffer);
}
bool Directory::CreateDirectories(LPCTSTR path)
{
int codeResult = ERROR_SUCCESS;
......
......@@ -35,6 +35,7 @@ namespace FileSystem {
static CString GetFolderPath(const CString& path);
static CString GetLongPathNameW(const CString& fileName);
static CString GetTempPath();
static CString CreateTempFileWithUniqueName (const CString & strFolderPathRoot,CString Prefix);
static bool PathIsDirectory(const CString& pathName);
};
}
......@@ -64,7 +64,20 @@ namespace FileSystem {
return stringUtf8ToWString (sDir);
}
CString Directory::GetTempPath()
{
char *folder = getenv ("TEMP");
if (NULL == folder)
folder = getenv ("TMP");
if (NULL == folder)
folder = getenv ("TMPDIR");
if (NULL == folder)
folder = "/tmp";
return stringUtf8ToWString(folder);
}
bool Directory::CreateDirectory (LPCTSTR path)
{
bool directoryCreated = false;
......@@ -82,6 +95,25 @@ namespace FileSystem {
{
return Directory::CreateDirectory(path.c_str());
}
CString Directory::CreateTempFileWithUniqueName (const CString & strFolderPathRoot,CString Prefix)
{
char pcRes[MAX_PATH];
if (NULL == pcRes) return _T("");
Prefix = strFolderPathRoot + FILE_SEPARATOR_STR + Prefix + _T("_XXXXXX");
std::wstring w_str = Prefix.GetBuffer();
std::string a_str = stringWstingToUtf8String(w_str);
memcpy(pcRes, a_str.c_str(), a_str.length());
pcRes[a_str.length()] = '\0';
int res = mkstemp( pcRes);
std::string sRes = pcRes;
return stringUtf8ToWString (sRes);
}
bool Directory::CreateDirectory (String strFolderPathRoot, String strFolderName)
{
String strFolder = strFolderPathRoot;
......
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