diff --git a/DesktopEditor/common/Directory.h b/DesktopEditor/common/Directory.h index 6d3cf9e897..8afb5d6e57 100644 --- a/DesktopEditor/common/Directory.h +++ b/DesktopEditor/common/Directory.h @@ -80,7 +80,7 @@ namespace NSDirectory KERNEL_DECL bool PathIsDirectory(const std::wstring& pathName); #ifdef _IOS - namespace IOS + namespace NSIOS { KERNEL_DECL void GetFiles2(std::wstring strDirectory, std::vector& oArray, bool bIsRecursion = false); } diff --git a/DesktopEditor/common/File.cpp b/DesktopEditor/common/File.cpp index c4cd7bb778..398f89bc7b 100644 --- a/DesktopEditor/common/File.cpp +++ b/DesktopEditor/common/File.cpp @@ -45,10 +45,6 @@ #include #endif -#ifdef _IOS -const char* fileSystemRepresentation(const std::wstring& sFileName); -#endif - #ifdef _MAC #include #endif @@ -959,64 +955,15 @@ namespace NSFile return (unsigned long)m_lFilePosition; } -#ifdef _IOS - - bool CFileBinary::OpenFile(const std::wstring& sFileName, bool bRewrite) - { - m_pFile = fopen(fileSystemRepresentation(sFileName), bRewrite ? "rb+" : "rb"); - - if (NULL == m_pFile) { -#if DEBUG - // printf ("NSFile::OpenFile - error open file : %s\n",strerror(errno)); -#endif - return false; - } - - fseek(m_pFile, 0, SEEK_END); - m_lFileSize = ftell(m_pFile); - fseek(m_pFile, 0, SEEK_SET); - - m_lFilePosition = 0; - - if (0 < sFileName.length()) - { - if (((wchar_t)'/') == sFileName.c_str()[sFileName.length() - 1]) - m_lFileSize = 0x7FFFFFFF; - } - - unsigned int err = 0x7FFFFFFF; - unsigned int cur = (unsigned int)m_lFileSize; - if (err == cur) - { - CloseFile(); - return false; - } - - return true; - } - - bool CFileBinary::CreateFileW(const std::wstring& sFileName) - { - m_pFile = fopen(fileSystemRepresentation(sFileName), "wb"); - - if (NULL == m_pFile) { -#if DEBUG - // printf ("NSFile::CreateFileW - error create file : %s\n",strerror(errno)); -#endif - return false; - } - - m_lFilePosition = 0; - return true; - } - -#else - bool CFileBinary::OpenFile(const std::wstring& sFileName, bool bRewrite) { #if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64) if ( NULL == (m_pFile = _wfsopen( sFileName.c_str(), bRewrite ? L"rb+" : L"rb", _SH_DENYNO))) return false; +#else +#ifdef _IOS + std::string sFilePath = NSIOS::GetFileSystemRepresentation(sFileName); + m_pFile = fopen((char*)sFilePath.c_str(), bRewrite ? "rb+" : "rb"); #else BYTE* pUtf8 = NULL; LONG lLen = 0; @@ -1027,9 +974,10 @@ namespace NSFile return false; m_pFile = fopen((char*)pUtf8, bRewrite ? "rb+" : "rb"); - delete [] pUtf8; #endif +#endif + if (NULL == m_pFile) return false; @@ -1061,12 +1009,17 @@ namespace NSFile #if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64) if ( 0 != _wfopen_s(&m_pFile, sFileName.c_str(), L"wb")) return false; +#else +#ifdef _IOS + std::string sFilePath = NSIOS::GetFileSystemRepresentation(sFileName); + m_pFile = fopen((char*)sFilePath.c_str(), "wb"); #else BYTE* pUtf8 = NULL; LONG lLen = 0; CUtf8Converter::GetUtf8StringFromUnicode(sFileName.c_str(), sFileName.length(), pUtf8, lLen, false); m_pFile = fopen((char*)pUtf8, "wb"); delete [] pUtf8; +#endif #endif if (NULL == m_pFile) return false; @@ -1075,8 +1028,6 @@ namespace NSFile return true; } -#endif - bool CFileBinary::CreateFile(const std::wstring& sFileName) { return CreateFileW(sFileName); diff --git a/DesktopEditor/common/File.h b/DesktopEditor/common/File.h index a051a9208c..230f38d010 100644 --- a/DesktopEditor/common/File.h +++ b/DesktopEditor/common/File.h @@ -203,7 +203,7 @@ namespace NSFile }; #ifdef _IOS - namespace IOS + namespace NSIOS { KERNEL_DECL std::string GetFileSystemRepresentation(const std::wstring& path); } diff --git a/DesktopEditor/common/File_ios.mm b/DesktopEditor/common/File_ios.mm index e7183e8aee..5e8ed6d6fd 100644 --- a/DesktopEditor/common/File_ios.mm +++ b/DesktopEditor/common/File_ios.mm @@ -42,24 +42,24 @@ namespace NSFile { - namespace IOS + namespace NSIOS { std::string GetFileSystemRepresentation(const std::wstring& path) { if (path.empty()) return ""; - NSString *path = [[NSString alloc] initWithBytes:(char*)path.data() length:path.size() * sizeof(wchar_t) + NSString* _path = [[NSString alloc] initWithBytes:(char*)path.data() length:path.size() * sizeof(wchar_t) encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingUTF32LE)]; - return std::string((const char*)[path fileSystemRepresentation]); + return std::string((const char*)[_path fileSystemRepresentation]); } } } namespace NSDirectory { - namespace IOS + namespace NSIOS { void GetFiles2(std::wstring strDirectory, std::vector& oArray, bool bIsRecursion) { diff --git a/DesktopEditor/fontengine/ApplicationFonts.cpp b/DesktopEditor/fontengine/ApplicationFonts.cpp index 3c22d7db82..2ba13e7ce2 100644 --- a/DesktopEditor/fontengine/ApplicationFonts.cpp +++ b/DesktopEditor/fontengine/ApplicationFonts.cpp @@ -1798,7 +1798,7 @@ std::vector CApplicationFonts::GetSetupFontFiles() #endif #ifdef _IOS - std::vector _array = NSDirectory::GetFiles2(L"/System/Library/Fonts", oArray, true); + std::vector _array = NSDirectory::GetFiles(L"/System/Library/Fonts", true); if (_array.empty()) NSDirectory::GetFiles2(L"/Library/Fonts", _array, true); return _array; diff --git a/DesktopEditor/fontengine/ApplicationFonts.h b/DesktopEditor/fontengine/ApplicationFonts.h index 072f45d2ab..25e70cdf2a 100644 --- a/DesktopEditor/fontengine/ApplicationFonts.h +++ b/DesktopEditor/fontengine/ApplicationFonts.h @@ -351,10 +351,6 @@ public: #if defined(_WIN32) || defined (_WIN64) void InitFromReg(); #endif - -#ifdef _IOS - std::vector GetSetupFontFiles_ios(); -#endif NSFonts::IFontManager* GenerateFontManager(); diff --git a/DesktopEditor/graphics/pro/Fonts.h b/DesktopEditor/graphics/pro/Fonts.h index 60f975f402..91ef2d014c 100644 --- a/DesktopEditor/graphics/pro/Fonts.h +++ b/DesktopEditor/graphics/pro/Fonts.h @@ -764,10 +764,6 @@ namespace NSFonts virtual void InitFromReg() = 0; #endif - #ifdef _IOS - virtual std::vector GetSetupFontFiles_ios() = 0; - #endif - virtual IFontManager* GenerateFontManager() = 0; virtual std::wstring GetFontBySymbol(int symbol) = 0; diff --git a/OfficeUtils/src/ZipUtilsCP.cpp b/OfficeUtils/src/ZipUtilsCP.cpp index 9554ed3481..2092cc754b 100644 --- a/OfficeUtils/src/ZipUtilsCP.cpp +++ b/OfficeUtils/src/ZipUtilsCP.cpp @@ -131,7 +131,7 @@ namespace ZLibZipUtils zipFile zf = zipOpen2_64(filename, APPEND_STATUS_CREATE, NULL, &ffunc); #else #ifdef _IOS - std::string filePath = NSFile::IOS::GetFileSystemRepresentation(filename); + std::string filePath = NSFile::NSIOS::GetFileSystemRepresentation(filename); zipFile zf = filePath.empty() ? NULL : zipOpen(filePath.c_str(), APPEND_STATUS_CREATE); #else BYTE* pUtf8 = NULL; @@ -151,8 +151,8 @@ namespace ZLibZipUtils unzFile uf = unzOpen2_64(filename, &ffunc); #else #ifdef _IOS - std::string filePath = NSFile::IOS::GetFileSystemRepresentation(filename); - unzFile zf = filePath.empty() ? NULL : unzOpen(filePath.c_str()); + std::string filePath = NSFile::NSIOS::GetFileSystemRepresentation(filename); + unzFile uf = filePath.empty() ? NULL : unzOpen(filePath.c_str()); #else BYTE* pUtf8 = NULL; LONG lLen = 0;