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

own implementation filedownloader

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@61243 954022d7-b5bf-4e40-9824-e11837661b57
parent 53fd429a
......@@ -46,7 +46,6 @@ static bool caseInsensitiveStringCompare(const std::wstring& str1, const std::ws
return true;
}
/*
static std::wstring stringUtf16ToWString (const UTF16 *pStr, uint32_t nLength)
{
#ifdef _WIN32
......@@ -79,7 +78,6 @@ static std::wstring stringUtf16ToWString (const UTF16 *pStr, uint32_t nLength)
return wsEntryName;
#endif
}
*/
static std::string stringWstingToUtf8String (const std::wstring& aaSrc)
{
......
......@@ -7,7 +7,8 @@
typedef unsigned __int16 _UINT16;
typedef unsigned __int32 _UINT32;
typedef unsigned __int64 _UINT64;
#elif __linux__
#else
// если нет таких типов - надо подключать stdint
typedef int16_t _INT16;
typedef int32_t _INT32;
typedef int64_t _INT64;
......
......@@ -33,7 +33,7 @@ namespace FileSystem {
static int GetFilesCount(const CString& path, const bool& recursive = false);
static CString GetFolderPath(const CString& path);
static CString GetLongPathNameW(const CString& fileName);
static CString GetLongPathName_(const CString& fileName);
static CString GetTempPath();
static CString CreateTempFileWithUniqueName (const CString & strFolderPathRoot,CString Prefix);
static bool PathIsDirectory(const CString& pathName);
......
......@@ -220,17 +220,11 @@ namespace FileSystem {
return strFolderPath.substr(0,n1);
}
CString Directory::GetLongPathNameW(const CString& fileName)
CString Directory::GetLongPathName_(const CString& fileName)
{
return fileName;
//todo
}
CString Directory::GetTempPath()
{
CString tempPath = P_tmpdir;
return tempPath;
}
bool Directory::PathIsDirectory(const CString& pathName)
{
......
#pragma once
#ifndef FILEDOWNLOADER_OWN_IMPLEMENTATION
#ifdef _WIN32
#include "../../Common/BaseThread.h"
......@@ -498,3 +500,92 @@ protected :
};
#endif
#else // FILEDOWNLOADER_OWN_IMPLEMENTATION
#include "../DesktopEditor/graphics/BaseThread.h"
#include "../DesktopEditor/common/File.h"
class CFileDownloader : public NSThreads::CBaseThread
{
public :
CFileDownloader (CString sFileUrl, int bDelete = TRUE) : NSThreads::CBaseThread()
{
m_pFile = NULL;
m_sFilePath = _T("");
m_sFileUrl = sFileUrl;
m_bComplete = FALSE;
m_bDelete = bDelete;
}
~CFileDownloader ()
{
if ( m_pFile )
{
::fclose( m_pFile );
m_pFile = NULL;
}
if ( m_sFilePath.GetLength() > 0 && m_bDelete )
{
NSFile::CFileBinary::Remove(std::wstring(m_sFilePath.GetString()));
m_sFilePath = _T("");
}
}
CString GetFilePath()
{
return m_sFilePath;
}
int IsFileDownloaded()
{
return m_bComplete;
}
protected :
virtual DWORD ThreadProc ()
{
m_bComplete = FALSE;
HRESULT hrResultAll = DownloadFileAll(std::wstring(m_sFileUrl.GetString()), std::wstring(m_sFilePath.GetString()));
if (S_OK != hrResultAll)
{
m_bRunThread = FALSE;
return 0;
}
m_bRunThread = FALSE;
m_bComplete = TRUE;
return 0;
}
// OWN REALIZE!!!
HRESULT DownloadFileAll(std::wstring sFileURL, std::wstring strFileOutput);
public:
static bool IsNeedDownload(CString FilePath)
{
int n1 = FilePath.Find(_T("www."));
int n2 = FilePath.Find(_T("http://"));
int n3 = FilePath.Find(_T("ftp://"));
int n4 = FilePath.Find(_T("https://"));
if (((n1 >= 0) && (n1 < 10)) || ((n2 >= 0) && (n2 < 10)) || ((n3 >= 0) && (n3 < 10)) || ((n4 >= 0) && (n4 < 10)))
return true;
return false;
}
protected :
FILE *m_pFile; // Хэндл на временный файл
CString m_sFilePath; // Путь к сохраненному файлу на диске
CString m_sFileUrl; // Ссылка на скачивание файла
int m_bComplete; // Закачался файл или нет
int m_bDelete; // Удалять ли файл в деструкторе
};
#endif
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