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

быстрое копирование файлов

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@67124 954022d7-b5bf-4e40-9824-e11837661b57
parent 12dcf40f
......@@ -795,10 +795,35 @@ namespace NSFile
static bool Copy(const std::wstring& strSrc, const std::wstring& strDst)
{
if (strSrc == strDst)
return true;
return true;
std::ifstream src;
std::ofstream dst;
int nLenBuffer = 1024 * 1024; // 10
CFileBinary oFile;
if (oFile.OpenFile(strSrc))
{
int nFileSize = (int)oFile.GetFileSize();
if (nFileSize < nLenBuffer)
nLenBuffer = nFileSize;
}
char* pBuffer_in = NULL;
char* pBuffer_out = NULL;
if (nLenBuffer > 0)
{
pBuffer_in = new char[nLenBuffer];
pBuffer_out = new char[nLenBuffer];
src.rdbuf()->pubsetbuf(pBuffer_in, nLenBuffer);
dst.rdbuf()->pubsetbuf(pBuffer_out, nLenBuffer);
}
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
std::wifstream src(strSrc.c_str(), std::ios::binary);
std::wofstream dst(strDst.c_str(), std::ios::binary);
src.open(strSrc, std::ios::binary);
dst.open(strDst, std::ios::binary);
#else
BYTE* pUtf8Src = NULL;
LONG lLenSrc = 0;
......@@ -807,21 +832,25 @@ namespace NSFile
LONG lLenDst = 0;
CUtf8Converter::GetUtf8StringFromUnicode(strDst.c_str(), strDst.length(), pUtf8Dst, lLenDst, false);
std::ifstream src((char*)pUtf8Src, std::ios::binary);
std::ofstream dst((char*)pUtf8Dst, std::ios::binary);
src.open(pUtf8Src, std::ios::binary);
dst.open(pUtf8Dst, std::ios::binary);
delete [] pUtf8Src;
delete [] pUtf8Dst;
#endif
bool bRet = false;
if (src.is_open() && dst.is_open())
{
dst << src.rdbuf();
src.close();
dst.close();
return true;
bRet = true;
}
else
return false;
RELEASEARRAYOBJECTS(pBuffer_in);
RELEASEARRAYOBJECTS(pBuffer_out);
return bRet;
}
static bool Remove(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