123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- /*
- * category: [tool for file]
- * apply status: framework
- * edit status:
- * build status:
- * description:
- */
- #ifndef __FILEUTIL_H__
- #define __FILEUTIL_H__
- #pragma once
- #include "config.h"
- #include "path.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- TOOLKIT_API BOOL ExistsDirA(LPCSTR lpDirPath);
- TOOLKIT_API BOOL ExistsDirW(LPCWSTR lpDirPath);
- #if defined(UNICODE) || defined(_UNICODE)
- #define ExistsDir ExistsDirW
- #else
- #define ExistsDir ExistsDirA
- #endif
- TOOLKIT_API BOOL ExistsFileA(LPCSTR lpFilePath);
- TOOLKIT_API BOOL ExistsFileW(LPCWSTR lpFilePath);
- #if defined(UNICODE) || defined(_UNICODE)
- #define ExistsFile ExistsFileW
- #else
- #define ExistsFile ExistsFileA
- #endif
- TOOLKIT_API BOOL RemoveFileA(LPCSTR pszFile);
- TOOLKIT_API BOOL RemoveFileReadOnlyAttributeA(LPCSTR pszFile);
- TOOLKIT_API BOOL CopyDirA(LPCSTR pszSourceDir, LPCSTR pszDestDir);
- TOOLKIT_API BOOL CreateDirA(LPCSTR lpDirPath, BOOL bRecursive);
- TOOLKIT_API BOOL CreateDirW(LPCWSTR lpDirPath, BOOL bRecursive);
- #if defined(UNICODE) || defined(_UNICODE)
- #define CreateDir CreateDirW
- #else
- #define CreateDir CreateDirA
- #endif
- TOOLKIT_API BOOL CreateDirRecursiveA(LPCSTR lpDirPath);
- TOOLKIT_API BOOL CreateDirRecursiveW(LPCWSTR lpDirPath);
- #if defined(UNICODE) || defined(_UNICODE)
- #define CreateDirRecursive CreateDirRecursiveW
- #else
- #define CreateDirRecursive CreateDirRecursiveA
- #endif
- TOOLKIT_API BOOL ClearDirRecursiveA(LPCSTR lpDirPath);
- TOOLKIT_API BOOL ClearDirRecursiveW(LPCWSTR lpDirPath);
- #if defined(UNICODE) || defined(_UNICODE)
- #define ClearDirRecursive ClearDirRecursiveW
- #else
- #define ClearDirRecursive ClearDirRecursiveA
- #endif
- TOOLKIT_API BOOL RemoveDirRecursiveA(LPCSTR lpDirPath);
- TOOLKIT_API BOOL RemoveDirRecursiveW(LPCWSTR lpDirPath);
- #if defined(UNICODE) || defined(_UNICODE)
- #define RemoveDirRecursive RemoveDirRecursiveW
- #else
- #define RemoveDirRecursive RemoveDirRecursiveA
- #endif
- TOOLKIT_API BOOL CreateParentDirA(LPCSTR lpPath, BOOL bRecursive);
- TOOLKIT_API BOOL CreateParentDirW(LPCWSTR lpPath, BOOL bRecursive);
- #if defined(UNICODE) || defined(_UNICODE)
- #define CreateParentDir CreateParentDirW
- #else
- #define CreateParentDir CreateParentDirA
- #endif
- TOOLKIT_API HANDLE ExtCreateFileA(LPCSTR lpFileName,
- DWORD dwDesiredAccess,
- DWORD dwShareMode,
- LPSECURITY_ATTRIBUTES lpSecurityAttributes,
- DWORD dwCreationDisposition,
- DWORD dwFlagsAndAttributes,
- HANDLE hTemplateFile);
- TOOLKIT_API HANDLE ExtCreateFileW(LPCWSTR lpFileName,
- DWORD dwDesiredAccess,
- DWORD dwShareMode,
- LPSECURITY_ATTRIBUTES lpSecurityAttributes,
- DWORD dwCreationDisposition,
- DWORD dwFlagsAndAttributes,
- HANDLE hTemplateFile);
- #if defined(UNICODE) || defined(_UNICODE)
- #define ExtCreateFile ExtCreateFileW
- #else
- #define ExtCreateFile ExtCreateFileA
- #endif
- typedef struct array_header_t array_header_t;
- TOOLKIT_API array_header_t *fileutil_get_sub_files_a(const char *path);
- TOOLKIT_API array_header_t *fileutil_get_sub_dirs_a(const char *path);
- TOOLKIT_API array_header_t *fileutil_get_sub_files_w(const wchar_t *path);
- TOOLKIT_API array_header_t *fileutil_get_sub_dirs_w(const wchar_t *path);
- TOOLKIT_API array_header_t *fileutil_get_sub_files2_a(const char *path, int limitation);
- TOOLKIT_API array_header_t *fileutil_get_sub_dirs2_a(const char *path, int limitation);
- TOOLKIT_API array_header_t *fileutil_get_sub_files2_w(const wchar_t *path, int limitation);
- TOOLKIT_API array_header_t *fileutil_get_sub_dirs2_w(const wchar_t *path, int limitation);
- #if defined(UNICODE) || defined(_UNICODE)
- #define fileutil_get_sub_files fileutil_get_sub_files_w
- #define fileutil_get_sub_dirs fileutil_get_sub_dirs_w
- #else
- #define fileutil_get_sub_files fileutil_get_sub_files_a
- #define fileutil_get_sub_dirs fileutil_get_sub_dirs_a
- #endif
- /** suc:0, failed: -1*/
- TOOLKIT_API int fileutil_copy_file(const char* dest_file_path, const char* src_file_path);
- TOOLKIT_API void fileutil_delete_file(const char* filename);
- TOOLKIT_API FILE *fileutil_transaction_fopen(const char *filename, const char *mode);
- TOOLKIT_API int fileutil_transaction_fclose(const char *filename, FILE *fp);
- #ifndef _WIN32
- TOOLKIT_API void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext);
- #endif //NOT _WIN32
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif //__FILEUTIL_H__
|