Refactoring

This commit is contained in:
Oleg Korshul
2023-07-25 13:30:08 +03:00
parent 94fd1d94bd
commit c72e44f44e
11 changed files with 440 additions and 530 deletions

View File

@ -31,25 +31,25 @@
*/ */
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
#include "windows.h" #include "windows.h"
#include "windef.h" #include "windef.h"
#include <shlobj.h> #include <shlobj.h>
#include <Rpc.h> #include <Rpc.h>
#elif __linux__ #elif __linux__
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <dirent.h> #include <dirent.h>
#elif MAC #elif MAC
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <dirent.h> #include <dirent.h>
#elif _IOS #elif _IOS
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <dirent.h> #include <dirent.h>
#endif #endif
#include <string.h> #include <string.h>
@ -58,187 +58,187 @@
namespace NSDirectory namespace NSDirectory
{ {
#if !defined(_WIN32) && !defined (_WIN64) #if !defined(_WIN32) && !defined (_WIN64)
static bool is_directory_exist(char* dir) static bool is_directory_exist(char* dir)
{ {
struct stat st; struct stat st;
bool bRes = (0 == stat(dir, &st)) && S_ISDIR(st.st_mode); bool bRes = (0 == stat(dir, &st)) && S_ISDIR(st.st_mode);
return bRes; return bRes;
} }
static bool _mkdir (const char *dir) static bool _mkdir (const char *dir)
{ {
char tmp[MAX_PATH]; char tmp[MAX_PATH];
char *p = NULL; char *p = NULL;
size_t len; size_t len;
bool res = true; bool res = true;
snprintf(tmp, sizeof(tmp),"%s",dir); snprintf(tmp, sizeof(tmp),"%s",dir);
len = strlen(tmp); len = strlen(tmp);
if(tmp[len - 1] == '/') if(tmp[len - 1] == '/')
tmp[len - 1] = 0; tmp[len - 1] = 0;
for(p = tmp + 1; *p; p++) for(p = tmp + 1; *p; p++)
if(*p == '/') { if(*p == '/') {
*p = 0; *p = 0;
res = is_directory_exist(tmp); res = is_directory_exist(tmp);
if (!res) if (!res)
res = (0 == mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)); res = (0 == mkdir(tmp, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH));
*p = '/'; *p = '/';
if (!res) if (!res)
break; break;
} }
if (res) if (res)
res = (0 == mkdir(tmp, S_IRWXU)); res = (0 == mkdir(tmp, S_IRWXU));
return res; return res;
} }
#endif #endif
void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion) void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion)
{ {
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
WIN32_FIND_DATAW oFD; WIN32_FIND_DATAW oFD;
std::wstring sSpec = strDirectory + L"\\*.*"; std::wstring sSpec = strDirectory + L"\\*.*";
HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD ); HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD );
if( INVALID_HANDLE_VALUE == hRes ) if( INVALID_HANDLE_VALUE == hRes )
return; return;
do do
{ {
sSpec = oFD.cFileName; sSpec = oFD.cFileName;
if (sSpec != L"." && sSpec != L"..") if (sSpec != L"." && sSpec != L"..")
{ {
sSpec = strDirectory + L"\\" + sSpec; sSpec = strDirectory + L"\\" + sSpec;
if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{ {
oArray.push_back(sSpec); oArray.push_back(sSpec);
} }
else if (bIsRecursion) else if (bIsRecursion)
{ {
GetFiles2(sSpec, oArray, bIsRecursion); GetFiles2(sSpec, oArray, bIsRecursion);
} }
} }
} while( FindNextFileW( hRes, &oFD ) ); } while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes ); FindClose( hRes );
#endif #endif
#ifdef __linux__ #ifdef __linux__
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL) if((dp = opendir((char*)pUtf8)) != NULL)
{ {
while ((dirp = readdir(dp)) != NULL) while ((dirp = readdir(dp)) != NULL)
{ {
int nType = 0; int nType = 0;
if(DT_REG == dirp->d_type) if(DT_REG == dirp->d_type)
nType = 2; nType = 2;
else if (DT_DIR == dirp->d_type) else if (DT_DIR == dirp->d_type)
nType = 1; nType = 1;
else if (DT_UNKNOWN == dirp->d_type) else if (DT_UNKNOWN == dirp->d_type)
{ {
// XFS problem // XFS problem
struct stat buff; struct stat buff;
std::string sTmp = std::string((char*)pUtf8) + "/" + std::string(dirp->d_name); std::string sTmp = std::string((char*)pUtf8) + "/" + std::string(dirp->d_name);
stat(sTmp.c_str(), &buff); stat(sTmp.c_str(), &buff);
if (S_ISREG(buff.st_mode)) if (S_ISREG(buff.st_mode))
nType = 2; nType = 2;
else if (S_ISDIR(buff.st_mode)) else if (S_ISDIR(buff.st_mode))
nType = 1; nType = 1;
} }
if (2 == nType) if (2 == nType)
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName); oArray.push_back(strDirectory + L"/" + sName);
} }
if (bIsRecursion && (1 == nType)) if (bIsRecursion && (1 == nType))
{ {
if(dirp->d_name[0] != '.') if(dirp->d_name[0] != '.')
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
GetFiles2(strDirectory + L"/" + sName, oArray, bIsRecursion); GetFiles2(strDirectory + L"/" + sName, oArray, bIsRecursion);
} }
} }
} }
closedir(dp); closedir(dp);
} }
delete [] pUtf8; delete [] pUtf8;
#endif #endif
#if defined(MAC) || defined (_IOS) #if defined(MAC) || defined (_IOS)
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL) if((dp = opendir((char*)pUtf8)) != NULL)
{ {
while ((dirp = readdir(dp)) != NULL) while ((dirp = readdir(dp)) != NULL)
{ {
if(DT_REG == dirp->d_type) if(DT_REG == dirp->d_type)
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName); oArray.push_back(strDirectory + L"/" + sName);
} }
if (bIsRecursion && DT_DIR == dirp->d_type)
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
GetFiles2(strDirectory + L"/" + sName, oArray, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
return;
#endif
}
std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion) if (bIsRecursion && DT_DIR == dirp->d_type)
{
if(dirp->d_name[0] != '.')
{
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
GetFiles2(strDirectory + L"/" + sName, oArray, bIsRecursion);
}
}
}
closedir(dp);
}
delete [] pUtf8;
return;
#endif
}
std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion)
{ {
std::vector<std::wstring> oArray; std::vector<std::wstring> oArray;
if (!strDirectory.empty()) if (!strDirectory.empty())
{ {
GetFiles2(strDirectory, oArray, bIsRecursion); GetFiles2(strDirectory, oArray, bIsRecursion);
} }
return oArray; return oArray;
} }
std::vector<std::wstring> GetDirectories(std::wstring strDirectory) std::vector<std::wstring> GetDirectories(std::wstring strDirectory)
{ {
std::vector<std::wstring> oArray; std::vector<std::wstring> oArray;
if (strDirectory.empty()) return oArray; if (strDirectory.empty()) return oArray;
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
WIN32_FIND_DATAW oFD; WIN32_FIND_DATAW oFD;
std::wstring sSpec = strDirectory + L"\\*"; std::wstring sSpec = strDirectory + L"\\*";
HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD ); HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD );
if( INVALID_HANDLE_VALUE == hRes ) if( INVALID_HANDLE_VALUE == hRes )
return oArray; return oArray;
do do
{ {
sSpec = oFD.cFileName; sSpec = oFD.cFileName;
if (sSpec != L"." && sSpec != L"..") if (sSpec != L"." && sSpec != L"..")
{ {
sSpec = strDirectory + L"\\" + sSpec; sSpec = strDirectory + L"\\" + sSpec;
if( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) if( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{ {
oArray.push_back(sSpec); oArray.push_back(sSpec);
} }
} }
} while( FindNextFileW( hRes, &oFD ) ); } while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes ); FindClose( hRes );
#elif __linux__ #elif __linux__
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL) if((dp = opendir((char*)pUtf8)) != NULL)
@ -270,54 +270,54 @@ namespace NSDirectory
} }
delete [] pUtf8; delete [] pUtf8;
#elif MAC #elif MAC
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL) if((dp = opendir((char*)pUtf8)) != NULL)
{ {
while ((dirp = readdir(dp)) != NULL) while ((dirp = readdir(dp)) != NULL)
{ {
if(DT_DIR == dirp->d_type) if(DT_DIR == dirp->d_type)
{ {
if(dirp->d_name[0] != '.') if(dirp->d_name[0] != '.')
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
oArray.push_back(strDirectory + L"/" + sName); oArray.push_back(strDirectory + L"/" + sName);
} }
} }
} }
closedir(dp); closedir(dp);
} }
delete [] pUtf8; delete [] pUtf8;
#endif #endif
return oArray; return oArray;
} }
bool Exists(const std::wstring& strDirectory) bool Exists(const std::wstring& strDirectory)
{ {
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str()); DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str());
return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
#elif __linux__ #elif __linux__
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
bool bRes = is_directory_exist((char*)pUtf8); bool bRes = is_directory_exist((char*)pUtf8);
delete [] pUtf8; delete [] pUtf8;
return bRes; return bRes;
#elif MAC #elif MAC
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st; struct stat st;
bool bRes = is_directory_exist((char*)pUtf8); bool bRes = is_directory_exist((char*)pUtf8);
delete [] pUtf8; delete [] pUtf8;
return bRes; return bRes;
#endif #endif
return false; return false;
} }
bool CreateDirectory(const std::wstring& strDirectory) bool CreateDirectory(const std::wstring& strDirectory)
{ {
if (Exists(strDirectory) == true) return true; if (Exists(strDirectory) == true) return true;
@ -326,7 +326,7 @@ namespace NSDirectory
#else #else
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
struct stat st; struct stat st;
int nRes = 0; int nRes = 0;
if (stat((char*)pUtf8, &st) == -1) { if (stat((char*)pUtf8, &st) == -1) {
@ -336,7 +336,7 @@ namespace NSDirectory
return 0 == nRes; return 0 == nRes;
#endif #endif
} }
bool CreateDirectories(const std::wstring& strDirectory) bool CreateDirectories(const std::wstring& strDirectory)
{ {
if (Exists(strDirectory) == true) return true; if (Exists(strDirectory) == true) return true;
@ -367,119 +367,119 @@ namespace NSDirectory
#endif #endif
return false; return false;
} }
bool CopyDirectory(const std::wstring& strSrc, const std::wstring& strDst, bool bIsRecursion) bool CopyDirectory(const std::wstring& strSrc, const std::wstring& strDst, bool bIsRecursion)
{ {
if (!NSDirectory::Exists(strDst)) if (!NSDirectory::Exists(strDst))
NSDirectory::CreateDirectory(strDst); NSDirectory::CreateDirectory(strDst);
#ifdef WIN32 #ifdef WIN32
WIN32_FIND_DATAW oFD; WIN32_FIND_DATAW oFD;
std::wstring sSpec = strSrc + L"\\*.*"; std::wstring sSpec = strSrc + L"\\*.*";
HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD ); HANDLE hRes = FindFirstFileW( sSpec.c_str(), &oFD );
if( INVALID_HANDLE_VALUE == hRes ) if( INVALID_HANDLE_VALUE == hRes )
return false; return false;
do do
{ {
sSpec = oFD.cFileName; sSpec = oFD.cFileName;
if (sSpec != L"." && sSpec != L"..") if (sSpec != L"." && sSpec != L"..")
{ {
if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) if( !( oFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{ {
NSFile::CFileBinary::Copy(strSrc + L"/" + sSpec, strDst + L"/" + sSpec); NSFile::CFileBinary::Copy(strSrc + L"/" + sSpec, strDst + L"/" + sSpec);
} }
else if (bIsRecursion) else if (bIsRecursion)
{ {
CopyDirectory(strSrc + L"/" + sSpec, strDst + L"/" + sSpec, bIsRecursion); CopyDirectory(strSrc + L"/" + sSpec, strDst + L"/" + sSpec, bIsRecursion);
} }
} }
} while( FindNextFileW( hRes, &oFD ) ); } while( FindNextFileW( hRes, &oFD ) );
FindClose( hRes ); FindClose( hRes );
return true; return true;
#endif #endif
#ifdef __linux__ #ifdef __linux__
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strSrc.c_str(), strSrc.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strSrc.c_str(), strSrc.length(), pUtf8, lLen, false);
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL) if((dp = opendir((char*)pUtf8)) != NULL)
{ {
while ((dirp = readdir(dp)) != NULL) while ((dirp = readdir(dp)) != NULL)
{ {
int nType = 0; int nType = 0;
if(DT_REG == dirp->d_type) if(DT_REG == dirp->d_type)
nType = 2; nType = 2;
else if (DT_DIR == dirp->d_type) else if (DT_DIR == dirp->d_type)
nType = 1; nType = 1;
else if (DT_UNKNOWN == dirp->d_type) else if (DT_UNKNOWN == dirp->d_type)
{ {
// XFS problem // XFS problem
struct stat buff; struct stat buff;
std::string sTmp = std::string((char*)pUtf8) + "/" + std::string(dirp->d_name); std::string sTmp = std::string((char*)pUtf8) + "/" + std::string(dirp->d_name);
stat(sTmp.c_str(), &buff); stat(sTmp.c_str(), &buff);
if (S_ISREG(buff.st_mode)) if (S_ISREG(buff.st_mode))
nType = 2; nType = 2;
else if (S_ISDIR(buff.st_mode)) else if (S_ISDIR(buff.st_mode))
nType = 1; nType = 1;
} }
if (2 == nType) if (2 == nType)
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
NSFile::CFileBinary::Copy(strSrc + L"/" + sName, strDst + L"/" + sName); NSFile::CFileBinary::Copy(strSrc + L"/" + sName, strDst + L"/" + sName);
} }
if (bIsRecursion && (1 == nType)) if (bIsRecursion && (1 == nType))
{ {
if(dirp->d_name[0] != '.') if(dirp->d_name[0] != '.')
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
CopyDirectory(strSrc + L"/" + sName, strDst + L"/" + sName, bIsRecursion); CopyDirectory(strSrc + L"/" + sName, strDst + L"/" + sName, bIsRecursion);
} }
} }
} }
closedir(dp); closedir(dp);
} }
delete [] pUtf8; delete [] pUtf8;
return true; return true;
#endif #endif
#if defined(MAC) || defined (_IOS) #if defined(MAC) || defined (_IOS)
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strSrc.c_str(), strSrc.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strSrc.c_str(), strSrc.length(), pUtf8, lLen, false);
DIR *dp; DIR *dp;
struct dirent *dirp; struct dirent *dirp;
if((dp = opendir((char*)pUtf8)) != NULL) if((dp = opendir((char*)pUtf8)) != NULL)
{ {
while ((dirp = readdir(dp)) != NULL) while ((dirp = readdir(dp)) != NULL)
{ {
if(DT_REG == dirp->d_type) if(DT_REG == dirp->d_type)
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
NSFile::CFileBinary::Copy(strSrc + L"/" + sName, strDst + L"/" + sName); NSFile::CFileBinary::Copy(strSrc + L"/" + sName, strDst + L"/" + sName);
} }
if (bIsRecursion && DT_DIR == dirp->d_type) if (bIsRecursion && DT_DIR == dirp->d_type)
{ {
if(dirp->d_name[0] != '.') if(dirp->d_name[0] != '.')
{ {
std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name)); std::wstring sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)dirp->d_name, strlen(dirp->d_name));
CopyDirectory(strSrc + L"/" + sName, strDst + L"/" + sName, bIsRecursion); CopyDirectory(strSrc + L"/" + sName, strDst + L"/" + sName, bIsRecursion);
} }
} }
} }
closedir(dp); closedir(dp);
} }
delete [] pUtf8; delete [] pUtf8;
return true; return true;
#endif #endif
return false; return false;
} }
void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot) void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot)
{ {
if (strDirectory.empty()) return; if (strDirectory.empty()) return;
@ -498,22 +498,22 @@ namespace NSDirectory
#elif __linux__ #elif __linux__
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
rmdir((char*)pUtf8); rmdir((char*)pUtf8);
delete [] pUtf8; delete [] pUtf8;
if (deleteRoot = false)CreateDirectory(strDirectory); if (deleteRoot = false)CreateDirectory(strDirectory);
#elif MAC #elif MAC
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(strDirectory.c_str(), strDirectory.length(), pUtf8, lLen, false);
rmdir((char*)pUtf8); rmdir((char*)pUtf8);
delete [] pUtf8; delete [] pUtf8;
if (deleteRoot = false)CreateDirectory(strDirectory); if (deleteRoot = false)CreateDirectory(strDirectory);
#endif #endif
} }
std::wstring GetFolderPath(const std::wstring& wsFolderPath) std::wstring GetFolderPath(const std::wstring& wsFolderPath)
{ {
int n1 = (int)wsFolderPath.rfind('\\'); int n1 = (int)wsFolderPath.rfind('\\');
if (n1 < 0) if (n1 < 0)
@ -527,64 +527,64 @@ namespace NSDirectory
} }
return wsFolderPath.substr(0, n1); return wsFolderPath.substr(0, n1);
} }
std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix) std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix)
{ {
return NSFile::CFileBinary::CreateTempFileWithUniqueName(strFolderPathRoot, Prefix); return NSFile::CFileBinary::CreateTempFileWithUniqueName(strFolderPathRoot, Prefix);
} }
std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot) std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot)
{ {
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
UUID uuid; UUID uuid;
RPC_WSTR str_uuid; RPC_WSTR str_uuid;
UuidCreate (&uuid); UuidCreate (&uuid);
UuidToStringW (&uuid, &str_uuid); UuidToStringW (&uuid, &str_uuid);
std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR; std::wstring pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (wchar_t *) str_uuid; pcTemplate += (wchar_t *) str_uuid;
RpcStringFreeW (&str_uuid); RpcStringFreeW (&str_uuid);
int attemps = 10; int attemps = 10;
while (!CreateDirectory(pcTemplate)) while (!CreateDirectory(pcTemplate))
{ {
UuidCreate (&uuid); UuidCreate (&uuid);
UuidToStringW (&uuid, &str_uuid); UuidToStringW (&uuid, &str_uuid);
pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR; pcTemplate = strFolderPathRoot + FILE_SEPARATOR_STR;
pcTemplate += (wchar_t *) str_uuid; pcTemplate += (wchar_t *) str_uuid;
RpcStringFreeW (&str_uuid); RpcStringFreeW (&str_uuid);
attemps--; attemps--;
if (0 == attemps) if (0 == attemps)
{ {
pcTemplate = L""; pcTemplate = L"";
break; break;
} }
} }
return pcTemplate; return pcTemplate;
#else #else
std::string pcTemplate = U_TO_UTF8(strFolderPathRoot) + "/ascXXXXXX"; std::string pcTemplate = U_TO_UTF8(strFolderPathRoot) + "/ascXXXXXX";
char *pcRes = mkdtemp(const_cast <char *> (pcTemplate.c_str())); char *pcRes = mkdtemp(const_cast <char *> (pcTemplate.c_str()));
if (NULL == pcRes) if (NULL == pcRes)
return L""; return L"";
std::string sRes = pcRes; std::string sRes = pcRes;
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sRes.c_str(), (LONG)sRes.length()); return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sRes.c_str(), (LONG)sRes.length());
#endif #endif
} }
std::wstring GetTempPath() std::wstring GetTempPath()
{ {
return NSFile::CFileBinary::GetTempPath(); return NSFile::CFileBinary::GetTempPath();
} }
int GetFilesCount(const std::wstring& path, const bool& recursive) int GetFilesCount(const std::wstring& path, const bool& recursive)
{ {
std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(path, recursive); std::vector<std::wstring> arrFiles = NSDirectory::GetFiles(path, recursive);
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
return (int)arrFiles.size(); return (int)arrFiles.size();
#endif #endif
return (int)arrFiles.size() + 1; return (int)arrFiles.size() + 1;
// ??? // ???
} }
bool PathIsDirectory(const std::wstring& pathName) bool PathIsDirectory(const std::wstring& pathName)
{ {
return Exists(pathName); return Exists(pathName);
} }
} }

View File

@ -46,41 +46,45 @@
#include "File.h" #include "File.h"
#ifndef FILE_SEPARATOR #ifndef FILE_SEPARATOR
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
#define FILE_SEPARATOR #define FILE_SEPARATOR
#define FILE_SEPARATOR_CHAR '\\' #define FILE_SEPARATOR_CHAR '\\'
#define FILE_SEPARATOR_STR L"\\" #define FILE_SEPARATOR_STR L"\\"
#define FILE_SEPARATOR_STRA "\\" #define FILE_SEPARATOR_STRA "\\"
#else #else
#define FILE_SEPARATOR #define FILE_SEPARATOR
#define FILE_SEPARATOR_CHAR '/' #define FILE_SEPARATOR_CHAR '/'
#define FILE_SEPARATOR_STR L"/" #define FILE_SEPARATOR_STR L"/"
#define FILE_SEPARATOR_STRA "/" #define FILE_SEPARATOR_STRA "/"
#endif #endif
#endif #endif
#include "../../Common/kernel_config.h" #include "../../Common/kernel_config.h"
namespace NSDirectory namespace NSDirectory
{ {
KERNEL_DECL std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion = false);
KERNEL_DECL void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion = false);
KERNEL_DECL std::vector<std::wstring> GetDirectories(std::wstring strDirectory);
KERNEL_DECL bool Exists(const std::wstring& strDirectory);
KERNEL_DECL bool CreateDirectory(const std::wstring& strDirectory);
KERNEL_DECL bool CreateDirectories(const std::wstring& strDirectory);
KERNEL_DECL bool CopyDirectory(const std::wstring& strSrc, const std::wstring& strDst, bool bIsRecursion = true);
KERNEL_DECL void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot = true);
KERNEL_DECL std::wstring GetFolderPath(const std::wstring& wsFolderPath);
KERNEL_DECL std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix);
KERNEL_DECL std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot);
KERNEL_DECL std::wstring GetTempPath();
KERNEL_DECL int GetFilesCount(const std::wstring& path, const bool& recursive);
KERNEL_DECL bool PathIsDirectory(const std::wstring& pathName);
#ifdef _IOS #ifdef _IOS
KERNEL_DECL void GetFiles2_ios(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion); namespace IOS
{
KERNEL_DECL void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion = false);
}
#endif #endif
KERNEL_DECL void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion = false);
KERNEL_DECL std::vector<std::wstring> GetFiles(std::wstring strDirectory, bool bIsRecursion = false);
KERNEL_DECL std::vector<std::wstring> GetDirectories(std::wstring strDirectory);
KERNEL_DECL bool Exists(const std::wstring& strDirectory);
KERNEL_DECL bool CreateDirectory(const std::wstring& strDirectory);
KERNEL_DECL bool CreateDirectories(const std::wstring& strDirectory);
KERNEL_DECL bool CopyDirectory(const std::wstring& strSrc, const std::wstring& strDst, bool bIsRecursion = true);
KERNEL_DECL void DeleteDirectory(const std::wstring& strDirectory, bool deleteRoot = true);
KERNEL_DECL std::wstring GetFolderPath(const std::wstring& wsFolderPath);
KERNEL_DECL std::wstring CreateTempFileWithUniqueName (const std::wstring & strFolderPathRoot, std::wstring Prefix);
KERNEL_DECL std::wstring CreateDirectoryWithUniqueName (const std::wstring & strFolderPathRoot);
KERNEL_DECL std::wstring GetTempPath();
KERNEL_DECL int GetFilesCount(const std::wstring& path, const bool& recursive);
KERNEL_DECL bool PathIsDirectory(const std::wstring& pathName);
} }
#endif //_BUILD_DIRECTORY_CROSSPLATFORM_H_ #endif //_BUILD_DIRECTORY_CROSSPLATFORM_H_

View File

@ -201,6 +201,13 @@ namespace NSFile
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE); static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst); static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
}; };
#ifdef _IOS
namespace IOS
{
KERNEL_DECL std::string GetFileSystemRepresentation(const std::wstring& path);
}
#endif
} }
namespace NSFile namespace NSFile

View File

@ -31,21 +31,49 @@
*/ */
#ifdef __OBJC__ #ifdef __OBJC__
#import <CoreFoundation/CoreFoundation.h> #import <CoreFoundation/CoreFoundation.h>
#else #else
#include <objc/objc.h> #include <objc/objc.h>
#endif #endif
#include "./File.h" #include "./File.h"
#include <vector>
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
const char* fileSystemRepresentation(const std::wstring& sFileName) namespace NSFile
{ {
if (sFileName.empty()) namespace IOS
return NULL; {
NSString *path = [[NSString alloc] initWithBytes:(char*)sFileName.data() std::string GetFileSystemRepresentation(const std::wstring& path)
length:sFileName.size()* sizeof(wchar_t) {
encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingUTF32LE)]; if (path.empty())
return "";
return (const char*)[path fileSystemRepresentation]; NSString *path = [[NSString alloc] initWithBytes:(char*)path.data() length:path.size() * sizeof(wchar_t)
encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingUTF32LE)];
return std::string((const char*)[path fileSystemRepresentation]);
}
}
}
namespace NSDirectory
{
namespace IOS
{
void GetFiles2(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion)
{
NSStringEncoding pEncode = CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE );
NSString* directoryPath = [[NSString alloc] initWithBytes : (char*)strDirectory.data()
length : strDirectory.size() * sizeof(wchar_t) encoding : pEncode];
NSArray* directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:NULL];
for (int count = 0; count < (int)[directoryContent count]; count++)
{
NSData* pSData = [[directoryContent objectAtIndex:count] dataUsingEncoding : pEncode];
oArray.emplace_back(std::wstring((wchar_t*)[pSData bytes], [pSData length] / sizeof (wchar_t)));
}
}
}
} }

View File

@ -1794,8 +1794,10 @@ std::vector<std::wstring> CApplicationFonts::GetSetupFontFiles()
#endif #endif
#ifdef _IOS #ifdef _IOS
// own realization (objective c code) std::vector<std::wstring> _array = NSDirectory::GetFiles2(L"/System/Library/Fonts", oArray, true);
return GetSetupFontFiles_ios(); if (_array.empty())
NSDirectory::GetFiles2(L"/Library/Fonts", _array, true);
return _array;
#endif #endif
#ifdef __ANDROID__ #ifdef __ANDROID__

View File

@ -1,75 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "ApplicationFonts.h"
#include "../common/Directory.h"
#ifdef BOOL
#undef BOOL
#endif
#import <UIKit/UIKit.h>
std::vector<std::wstring> CApplicationFonts::GetSetupFontFiles_ios()
{
std::vector<std::wstring> oArray;
NSDirectory::GetFiles2(L"/System/Library/Fonts", oArray, true);
if (oArray.size() == 0)
{
NSDirectory::GetFiles2(L"/Library/Fonts", oArray, true);
}
return oArray;
}
namespace NSDirectory
{
void GetFiles2_ios(std::wstring strDirectory, std::vector<std::wstring>& oArray, bool bIsRecursion)
{
NSString* directoryPath = [ [ NSString alloc ]
initWithBytes : (char*)strDirectory.data()
length : strDirectory.size() * sizeof(wchar_t)
encoding : CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE ) ];
int count;
NSArray* directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:NULL];
for (count = 0; count < (int)[directoryContent count]; count++)
{
NSStringEncoding pEncode = CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE );
NSData* pSData = [[ directoryContent objectAtIndex:count] dataUsingEncoding : pEncode ];
std::wstring sTmp( (wchar_t*) [ pSData bytes ], [ pSData length] / sizeof ( wchar_t ) );
oArray.push_back(sTmp);
}
}
}

View File

@ -39,10 +39,6 @@ enable_support_shaper {
# ------------------------------------------------- # -------------------------------------------------
core_ios { core_ios {
OBJECTIVE_SOURCES += \
$$FONT_ENGINE_PATH/ApplicationFonts_ios.mm \
LIBS += -framework Foundation LIBS += -framework Foundation
} }

View File

@ -64,6 +64,3 @@ HEADERS += \
$$PWD/src/zlib-1.2.11/contrib/minizip/zip.h \ $$PWD/src/zlib-1.2.11/contrib/minizip/zip.h \
$$PWD/src/zlib-1.2.11/contrib/minizip/ioapibuf.h $$PWD/src/zlib-1.2.11/contrib/minizip/ioapibuf.h
core_ios {
OBJECTIVE_SOURCES += $$PWD/src/ZipUtilsCP_ios.mm
}

View File

@ -123,19 +123,23 @@ namespace ZLibZipUtils
return m_unzFile; return m_unzFile;
} }
#ifndef _IOS
zipFile zipOpenHelp(const wchar_t* filename) zipFile zipOpenHelp(const wchar_t* filename)
{ {
#if defined(_WIN32) || defined (_WIN64) #if defined(_WIN32) || defined (_WIN64)
zlib_filefunc64_def ffunc; zlib_filefunc64_def ffunc;
fill_win32_filefunc64W(&ffunc); fill_win32_filefunc64W(&ffunc);
zipFile zf = zipOpen2_64(filename, APPEND_STATUS_CREATE, NULL, &ffunc); zipFile zf = zipOpen2_64(filename, APPEND_STATUS_CREATE, NULL, &ffunc);
#else
#ifdef _IOS
std::string filePath = NSFile::IOS::GetFileSystemRepresentation(filename);
zipFile zf = filePath.empty() ? NULL : zipOpen(filePath.c_str(), APPEND_STATUS_CREATE);
#else #else
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(filename, wcslen(filename), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(filename, wcslen(filename), pUtf8, lLen, false);
zipFile zf = zipOpen( (char*)pUtf8, APPEND_STATUS_CREATE ); zipFile zf = zipOpen( (char*)pUtf8, APPEND_STATUS_CREATE );
delete [] pUtf8; delete [] pUtf8;
#endif
#endif #endif
return zf; return zf;
} }
@ -145,16 +149,21 @@ namespace ZLibZipUtils
zlib_filefunc64_def ffunc; zlib_filefunc64_def ffunc;
fill_win32_filefunc64W(&ffunc); fill_win32_filefunc64W(&ffunc);
unzFile uf = unzOpen2_64(filename, &ffunc); 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());
#else #else
BYTE* pUtf8 = NULL; BYTE* pUtf8 = NULL;
LONG lLen = 0; LONG lLen = 0;
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(filename, wcslen(filename), pUtf8, lLen, false); NSFile::CUtf8Converter::GetUtf8StringFromUnicode(filename, wcslen(filename), pUtf8, lLen, false);
unzFile uf = unzOpen( (char*)pUtf8 ); unzFile uf = unzOpen( (char*)pUtf8 );
delete [] pUtf8; delete [] pUtf8;
#endif
#endif #endif
return uf; return uf;
} }
#endif
static std::wstring ascii_to_unicode(const char *src) static std::wstring ascii_to_unicode(const char *src)
{ {
// TODO: check codepage of system (for "bad" archive) // TODO: check codepage of system (for "bad" archive)

View File

@ -57,7 +57,6 @@ using namespace std;
namespace ZLibZipUtils namespace ZLibZipUtils
{ {
zipFile zipOpenHelp(const wchar_t* filename); zipFile zipOpenHelp(const wchar_t* filename);
unzFile unzOpenHelp(const wchar_t* filename); unzFile unzOpenHelp(const wchar_t* filename);

View File

@ -1,57 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "ZipUtilsCP.h"
#import <Foundation/Foundation.h>
namespace ZLibZipUtils
{
zipFile zipOpenHelp(const wchar_t* filename)
{
NSString *path =[[NSString alloc] initWithBytes:filename
length:wcslen(filename)*sizeof(*filename)
encoding:NSUTF32LittleEndianStringEncoding];
if (path && path.length > 0) {
return zipOpen( (const char*)[path fileSystemRepresentation], APPEND_STATUS_CREATE );
}
return NULL;
}
unzFile unzOpenHelp(const wchar_t* filename)
{
NSString *path =[[NSString alloc] initWithBytes:filename
length:wcslen(filename)*sizeof(*filename)
encoding:NSUTF32LittleEndianStringEncoding];
if (path && path.length > 0) {
return unzOpen ((const char*)[path fileSystemRepresentation]);
}
return NULL;
}
}