diff options
author | George Hazan <ghazan@miranda.im> | 2018-06-20 19:38:11 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-06-20 19:38:11 +0300 |
commit | 3b33d7fd43c99e7408392f43b7c02f10673b2923 (patch) | |
tree | df90f9dc7df9a262a0899a2e69aecaf14d02b3c6 /plugins | |
parent | 1444743f2a88a2e9971d44b93f9bba98bfd2a5c9 (diff) |
even less crazy ANSI <-> Unicode conversions
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Db_autobackups/src/backup.cpp | 11 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/stdafx.h | 6 | ||||
-rw-r--r-- | plugins/Db_autobackups/src/zip.cpp | 4 |
3 files changed, 10 insertions, 11 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index e502929937..fac10f5629 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -78,7 +78,7 @@ wchar_t* DoubleSlash(wchar_t *sorce) return ret;
}
-bool MakeZip_Dir(LPCSTR szDir, LPCTSTR szDest, LPCSTR /* szDbName */, HWND progress_dialog)
+bool MakeZip_Dir(LPCWSTR szDir, LPCWSTR szDest, LPCWSTR /* szDbName */, HWND progress_dialog)
{
HWND hProgBar = GetDlgItem(progress_dialog, IDC_PROGRESS);
size_t count = 0;
@@ -87,8 +87,8 @@ bool MakeZip_Dir(LPCSTR szDir, LPCTSTR szDest, LPCSTR /* szDbName */, HWND progr for (auto it = fs::recursive_directory_iterator(fs::path(szDir)); it != fs::recursive_directory_iterator(); ++it) {
const auto& file = it->path();
if (!fs::is_directory(file) && file.string().find(fs::path((char*)_T2A(szDest)).string().c_str()) == std::string::npos) {
- const std::string &filepath = file.string();
- const std::string rpath = filepath.substr(filepath.find(szDir) + mir_strlen(szDir) + 1);
+ const std::wstring &filepath = file.wstring();
+ const std::wstring rpath = filepath.substr(filepath.find(szDir) + mir_wstrlen(szDir) + 1);
lstFiles.insert(new ZipFile(filepath, rpath));
count++;
@@ -109,10 +109,9 @@ bool MakeZip(wchar_t *tszSource, wchar_t *tszDest, wchar_t *dbname, HWND progres {
HWND hProgBar = GetDlgItem(progress_dialog, IDC_PROGRESS);
- ptrA szSourceName(mir_u2a(dbname));
ptrW tszDestPath(DoubleSlash(tszDest));
OBJLIST<ZipFile> lstFiles(15);
- lstFiles.insert(new ZipFile((char*)_T2A(tszSource), (char*)szSourceName));
+ lstFiles.insert(new ZipFile(tszSource, dbname));
CreateZipFile(tszDest, lstFiles, [&](size_t)->bool { SendMessage(hProgBar, PBM_SETPOS, (WPARAM)(100), 0); return true; });
@@ -222,7 +221,7 @@ int Backup(wchar_t *backup_filename) BOOL res = 0;
if (bZip) {
res = options.backup_profile
- ? MakeZip_Dir(_T2A(profile_path), dest_file, _T2A(dbname), progress_dialog)
+ ? MakeZip_Dir(profile_path, dest_file, dbname, progress_dialog)
: MakeZip(source_file, dest_file, dbname, progress_dialog);
}
else res = CopyFile(source_file, dest_file, 0);
diff --git a/plugins/Db_autobackups/src/stdafx.h b/plugins/Db_autobackups/src/stdafx.h index c680d2b673..e6d992c8ca 100644 --- a/plugins/Db_autobackups/src/stdafx.h +++ b/plugins/Db_autobackups/src/stdafx.h @@ -50,9 +50,9 @@ void BackupStart(wchar_t *backup_filename); struct ZipFile
{
- std::string sPath;
- std::string sZipPath;
- __forceinline ZipFile(const std::string &path, const std::string &zpath) : sPath(path), sZipPath(zpath) {}
+ std::wstring sPath;
+ std::wstring sZipPath;
+ __forceinline ZipFile(const std::wstring &path, const std::wstring &zpath) : sPath(path), sZipPath(zpath) {}
};
int CreateZipFile(const wchar_t *szDestPath, OBJLIST<ZipFile> &lstFiles, const std::function<bool(size_t)> &fnCallback);
diff --git a/plugins/Db_autobackups/src/zip.cpp b/plugins/Db_autobackups/src/zip.cpp index 96d74e7493..b360272855 100644 --- a/plugins/Db_autobackups/src/zip.cpp +++ b/plugins/Db_autobackups/src/zip.cpp @@ -12,9 +12,9 @@ int CreateZipFile(const wchar_t *szDestPath, OBJLIST<ZipFile> &lstFiles, const s for (int i = 0; i < lstFiles.getCount(); i++) {
ZipFile &zf = lstFiles[i];
- HANDLE hSrcFile = CreateFileA(zf.sPath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
+ HANDLE hSrcFile = CreateFileW(zf.sPath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hSrcFile != INVALID_HANDLE_VALUE) {
- int iOpenRes = zipOpenNewFileInZip(hZip, zf.sZipPath.c_str(), &fi, nullptr, 0, nullptr, 0, "", Z_DEFLATED, Z_BEST_COMPRESSION);
+ int iOpenRes = zipOpenNewFileInZip(hZip, _T2A(zf.sZipPath.c_str()), &fi, nullptr, 0, nullptr, 0, "", Z_DEFLATED, Z_BEST_COMPRESSION);
if (iOpenRes == ZIP_OK) {
DWORD dwRead;
|