diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/include/fxcrt/fx_stream.h | 13 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_platforms.cpp | 47 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_posix.cpp | 49 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_windows.cpp | 38 |
4 files changed, 1 insertions, 146 deletions
diff --git a/core/include/fxcrt/fx_stream.h b/core/include/fxcrt/fx_stream.h index a5bec7f51b..f98e44b846 100644 --- a/core/include/fxcrt/fx_stream.h +++ b/core/include/fxcrt/fx_stream.h @@ -44,18 +44,7 @@ FX_WCHAR FX_GetFolderSeparator(); #define FX_FILEMODE_Write 0 #define FX_FILEMODE_ReadOnly 1 #define FX_FILEMODE_Truncate 2 -FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName); -FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName); -FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName); -FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName); -FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, - const CFX_ByteStringC& fileNameDst); -FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, - const CFX_WideStringC& fileNameDst); -FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, - const CFX_ByteStringC& fileNameDst); -FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, - const CFX_WideStringC& fileNameDst); + class IFX_StreamWrite { public: virtual ~IFX_StreamWrite() {} diff --git a/core/src/fxcrt/fxcrt_platforms.cpp b/core/src/fxcrt/fxcrt_platforms.cpp index 190605cb60..4c123d3984 100644 --- a/core/src/fxcrt/fxcrt_platforms.cpp +++ b/core/src/fxcrt/fxcrt_platforms.cpp @@ -129,51 +129,4 @@ FX_BOOL CFXCRT_FileAccess_CRT::Flush() { FX_BOOL CFXCRT_FileAccess_CRT::Truncate(FX_FILESIZE szFile) { return FALSE; } -FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName) { - return access(fileName.GetCStr(), F_OK) > -1; -} -FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName) { - return FX_File_Exist(FX_UTF8Encode(fileName)); -} -FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName) { - return remove(fileName.GetCStr()) > -1; -} -FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName) { - return FX_File_Delete(FX_UTF8Encode(fileName)); -} -FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, - const CFX_ByteStringC& fileNameDst) { - CFXCRT_FileAccess_CRT src, dst; - if (!src.Open(fileNameSrc, FX_FILEMODE_ReadOnly)) { - return FALSE; - } - FX_FILESIZE size = src.GetSize(); - if (!size) { - return FALSE; - } - if (!dst.Open(fileNameDst, FX_FILEMODE_Truncate)) { - return FALSE; - } - FX_FILESIZE num = 0; - uint8_t* pBuffer = FX_Alloc(uint8_t, 32768); - while (num = src.Read(pBuffer, 32768)) { - if (dst.Write(pBuffer, num) != num) { - break; - } - } - FX_Free(pBuffer); - return TRUE; -} -FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, - const CFX_WideStringC& fileNameDst) { - return FX_File_Copy(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); -} -FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, - const CFX_ByteStringC& fileNameDst) { - return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); -} -FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, - const CFX_WideStringC& fileNameDst) { - return FX_File_Move(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); -} #endif diff --git a/core/src/fxcrt/fxcrt_posix.cpp b/core/src/fxcrt/fxcrt_posix.cpp index d7df15eb32..f6710eb49b 100644 --- a/core/src/fxcrt/fxcrt_posix.cpp +++ b/core/src/fxcrt/fxcrt_posix.cpp @@ -127,53 +127,4 @@ FX_BOOL CFXCRT_FileAccess_Posix::Truncate(FX_FILESIZE szFile) { } return !ftruncate(m_nFD, szFile); } -FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName) { - return access(fileName.GetCStr(), F_OK) > -1; -} -FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName) { - return FX_File_Exist(FX_UTF8Encode(fileName)); -} -FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName) { - return remove(fileName.GetCStr()) > -1; -} -FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName) { - return FX_File_Delete(FX_UTF8Encode(fileName)); -} -FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, - const CFX_ByteStringC& fileNameDst) { - CFXCRT_FileAccess_Posix src, dst; - if (!src.Open(fileNameSrc, FX_FILEMODE_ReadOnly)) { - return FALSE; - } - FX_FILESIZE size = src.GetSize(); - if (!size) { - return FALSE; - } - if (!dst.Open(fileNameDst, FX_FILEMODE_Truncate)) { - return FALSE; - } - size_t num = 0; - uint8_t* pBuffer = FX_Alloc(uint8_t, 32768); - num = src.Read(pBuffer, 32768); - while (num) { - if (dst.Write(pBuffer, num) != num) { - break; - } - num = src.Read(pBuffer, 32768); - } - FX_Free(pBuffer); - return TRUE; -} -FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, - const CFX_WideStringC& fileNameDst) { - return FX_File_Copy(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); -} -FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, - const CFX_ByteStringC& fileNameDst) { - return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); -} -FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, - const CFX_WideStringC& fileNameDst) { - return FX_File_Move(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); -} #endif diff --git a/core/src/fxcrt/fxcrt_windows.cpp b/core/src/fxcrt/fxcrt_windows.cpp index aff6a58aea..6f379a127c 100644 --- a/core/src/fxcrt/fxcrt_windows.cpp +++ b/core/src/fxcrt/fxcrt_windows.cpp @@ -9,20 +9,6 @@ #include "core/include/fxcrt/fx_string.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName) { - FX_DWORD dwAttri = ::GetFileAttributesA(fileName.GetCStr()); - if (dwAttri == -1) { - return FALSE; - } - return (dwAttri & FILE_ATTRIBUTE_DIRECTORY) == 0; -} -FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName) { - FX_DWORD dwAttri = ::GetFileAttributesW((LPCWSTR)fileName.GetPtr()); - if (dwAttri == -1) { - return FALSE; - } - return (dwAttri & FILE_ATTRIBUTE_DIRECTORY) == 0; -} IFXCRT_FileAccess* FXCRT_FileAccess_Create() { return new CFXCRT_FileAccess_Win64; } @@ -183,28 +169,4 @@ FX_BOOL CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) { } return ::SetEndOfFile(m_hFile); } -FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName) { - return ::DeleteFileA(fileName.GetCStr()); -} -FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName) { - return ::DeleteFileW((LPCWSTR)fileName.GetPtr()); -} -FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, - const CFX_ByteStringC& fileNameDst) { - return ::CopyFileA(fileNameSrc.GetCStr(), fileNameDst.GetCStr(), FALSE); -} -FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, - const CFX_WideStringC& fileNameDst) { - return ::CopyFileW((LPCWSTR)fileNameSrc.GetPtr(), - (LPCWSTR)fileNameDst.GetPtr(), FALSE); -} -FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, - const CFX_ByteStringC& fileNameDst) { - return ::MoveFileA(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); -} -FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, - const CFX_WideStringC& fileNameDst) { - return ::MoveFileW((LPCWSTR)fileNameSrc.GetPtr(), - (LPCWSTR)fileNameDst.GetPtr()); -} #endif |