diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index c0431ae7..41c190aa 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -299,16 +299,6 @@ std::string AppConfig::GetProtocolFormat(const std::string &protocolName) } //-------------api -QString GetDirectoryName(QString path) -{ - int lstdex = path.lastIndexOf('/'); - if (lstdex != -1) - { - return path.left(lstdex); - } - return path; -} - QString GetIconPath() { QString style = AppConfig::Instance()._frameOptions.style; diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index 88a168df..bf300a97 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -35,8 +35,6 @@ #define APP_NAME "DSView" //--------------------api--- - -QString GetDirectoryName(QString path); QString GetIconPath(); QString GetAppDataDir(); QString GetResourceDir(); diff --git a/DSView/pv/dialogs/protocolexp.cpp b/DSView/pv/dialogs/protocolexp.cpp index 9546c0ff..739467ad 100755 --- a/DSView/pv/dialogs/protocolexp.cpp +++ b/DSView/pv/dialogs/protocolexp.cpp @@ -39,6 +39,7 @@ #include "../config/appconfig.h" #include "../dsvdef.h" #include "../utility/encoding.h" +#include "../utility/path.h" using namespace boost; using namespace std; @@ -140,7 +141,7 @@ void ProtocolExp::accept() if(f.suffix().compare(ext)) file_name+=tr(".")+ext; - QString fname = GetDirectoryName(file_name); + QString fname = path::GetDirectoryName(file_name); if (fname != app._userHistory.openDir) { app._userHistory.protocolExportPath = fname; diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 54ce31c2..91063650 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -94,6 +94,7 @@ #include "dsvdef.h" #include "appcontrol.h" #include "utility/encoding.h" +#include "utility/path.h" #define BASE_SESSION_VERSION 2 @@ -439,20 +440,19 @@ void MainWindow::update_device_list() //load specified file name from application startup param if (_bFirstLoad){ _bFirstLoad = false; - - if (AppControl::Instance()->_open_file_name != ""){ - QString opf(QString::fromUtf8(AppControl::Instance()->_open_file_name.c_str())); - QFile fpath; + + QString ldFileName(AppControl::Instance()->_open_file_name.c_str()); - if (fpath.exists(opf)){ - qDebug()<<"auto load file:"< -#endif - namespace pv::path { std::string ConvertPath(QString fileName) { -#ifdef _WIN32 - QTextCodec *code = QTextCodec::codecForName("GB2312"); - if (code != NULL) - { - return code->fromUnicode(fileName).data(); - } -#endif return fileName.toUtf8().toStdString(); } + + QString GetDirectoryName(QString path) + { + int lstdex = path.lastIndexOf('/'); + if (lstdex != -1) + { + return path.left(lstdex); + } + return path; + } } \ No newline at end of file diff --git a/DSView/pv/utility/path.h b/DSView/pv/utility/path.h index 2f5729ec..4d42a6d9 100644 --- a/DSView/pv/utility/path.h +++ b/DSView/pv/utility/path.h @@ -28,6 +28,8 @@ namespace pv::path { std::string ConvertPath(QString fileName); + + QString GetDirectoryName(QString path); } #endif \ No newline at end of file diff --git a/common/minizip/ioapi.c b/common/minizip/ioapi.c index 7f5c191b..3c5c1dbf 100644 --- a/common/minizip/ioapi.c +++ b/common/minizip/ioapi.c @@ -28,6 +28,10 @@ #include "ioapi.h" +#ifdef _WIN32 +#include +#endif + voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) { if (pfilefunc->zfile_func64.zopen64_file != NULL) @@ -112,6 +116,34 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) { +#ifdef _WIN32 + FILE* file = NULL; + const wchar_t* mode_fopen = NULL; + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) + mode_fopen = L"rb"; + else + if (mode & ZLIB_FILEFUNC_MODE_EXISTING) + mode_fopen = L"r+b"; + else + if (mode & ZLIB_FILEFUNC_MODE_CREATE) + mode_fopen = L"wb"; + + int wcSize = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, NULL, 0); + if (wcSize == 0) { + return NULL; + } + wchar_t *wcName = (wchar_t *)malloc(sizeof(wchar_t) * wcSize + 8); + if (wcName == NULL) { + return NULL; + } + MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, wcName, wcSize); + + if ((filename!=NULL) && (mode_fopen != NULL)) + file = _wfopen((const wchar_t*)wcName, mode_fopen); + free(wcName); + + return file; +#else FILE* file = NULL; const char* mode_fopen = NULL; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) @@ -126,6 +158,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, if ((filename!=NULL) && (mode_fopen != NULL)) file = FOPEN_FUNC((const char*)filename, mode_fopen); return file; +#endif }