ZFFramework
Loading...
Searching...
No Matches
ZFIO_file.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFIO_file_h_
7#define _ZFI_ZFIO_file_h_
8
9#include "ZFIODef.h"
11
19
20// ============================================================
21// ZFInputForFile
32 , ZFMP_IN(const zfstring &, filePath)
33 ) {
34 ZFInput ret;
36 return ret;
37}
38
39// ============================================================
40// ZFOutputForFile
50 , ZFMP_IN(const zfstring &, filePath)
52 ) {
53 ZFOutput ret;
54 ZFOutputForPathInfoT(ret, ZFPathInfo(ZFPathType_file(), filePath), flags);
55 return ret;
56}
57
58// ============================================================
64 , ZFMP_IN(const zfstring &, path)
65 )
71 , ZFMP_IN(const zfstring &, path)
72 )
78 , ZFMP_IN(const zfstring &, path)
79 )
86 , ZFMP_IN_OUT(zfstring &, ret)
87 , ZFMP_IN(const zfstring &, path)
88 )
95 , ZFMP_IN(const zfstring &, path)
96 )
97
103 , ZFMP_IN(const zfstring &, path)
104 , ZFMP_IN_OPT(zfbool, autoCreateParent, zftrue)
106
114 , ZFMP_IN(const zfstring &, path)
115 , ZFMP_IN_OPT(zfbool, isRecursive, zftrue)
116 , ZFMP_IN_OPT(zfbool, isForce, zftrue)
123 , ZFMP_IN(const zfstring &, dstPath)
124 , ZFMP_IN(const zfstring &, srcPath)
125 , ZFMP_IN_OPT(zfbool, isForce, zftrue)
132 , ZFMP_IN(const zfstring &, path)
139 , ZFMP_IN(const zfstring &, path)
140 , ZFMP_IN(zftimet, time)
142
168 , ZFMP_IN(const zfstring &, path)
170
177
184
190 , ZFMP_IN(const zfstring &, filePath)
192 , ZFMP_IN_OPT(zfbool, autoCreateParent, zftrue)
198 , ZFMP_IN(void *, token)
200
218 , ZFMP_IN(void *, token)
219 , ZFMP_IN(void *, buf)
220 , ZFMP_IN(zfindex, maxByteSize)
222
239 , ZFMP_IN(void *, token)
240 , ZFMP_IN(const void *, src)
241 , ZFMP_IN_OPT(zfindex, maxByteSize, zfindexMax())
247 , ZFMP_IN(void *, token)
249
254 , ZFMP_IN(void *, token)
255 , ZFMP_IN(zfindex, byteSize)
256 , ZFMP_IN_OPT(ZFSeekPos, seekPos, ZFSeekPosBegin)
262 , ZFMP_IN(void *, token)
272 , ZFMP_IN(void *, token)
274
275// ============================================================
276zfclass ZFLIB_ZFCore _ZFP_I_ZFIOImpl_file : zfextend ZFIOImpl {
277 ZFOBJECT_DECLARE(_ZFP_I_ZFIOImpl_file, ZFIOImpl)
278protected:
279 virtual zfstring pathConvert(ZF_IN const zfstring &pathData) {
280 return pathData;
281 }
282public:
284 virtual zfstring pathType(void) {return ZFPathType_file();}
285
287 virtual zfbool ioIsExist(ZF_IN const zfstring &pathData) {return ZFFileIsExist(pathConvert(pathData));}
289 virtual zfbool ioIsDir(ZF_IN const zfstring &pathData) {return ZFFileIsDir(pathConvert(pathData));}
291 virtual zfbool ioToFileName(
293 , ZF_IN const zfstring &pathData
294 ) {return ioToFileNameDefault(ret, pathData);}
296 virtual zfbool ioToChild(
298 , ZF_IN const zfstring &pathData
299 , ZF_IN const zfstring &childName
300 ) {return ioToChildDefault(ret, pathData, childName);}
302 virtual zfbool ioToParent(
304 , ZF_IN const zfstring &pathData
305 ) {return ioToParentDefault(ret, pathData);}
307 virtual zfbool ioPathCreate(
308 ZF_IN const zfstring &pathData
309 , ZF_IN_OPT zfbool autoCreateParent = zftrue
310 ) {return ZFFilePathCreate(pathConvert(pathData), autoCreateParent);}
312 virtual zfbool ioRemove(
313 ZF_IN const zfstring &pathData
314 , ZF_IN_OPT zfbool isRecursive = zftrue
315 , ZF_IN_OPT zfbool isForce = zftrue
316 ) {return ZFFileRemove(pathConvert(pathData), isRecursive, isForce);}
318 virtual zfbool ioMove(
319 ZF_IN const zfstring &pathDataTo
320 , ZF_IN const zfstring &pathDataFrom
321 , ZF_IN_OPT zfbool isForce = zftrue
322 ) {return ZFFileMove(pathConvert(pathDataTo), pathConvert(pathDataFrom), isForce);}
324 virtual zftimet ioModTime(ZF_IN const zfstring &pathData) {
325 return ZFFileModTime(pathConvert(pathData));
326 }
328 virtual zfbool ioModTime(ZF_IN const zfstring &pathData, ZF_IN zftimet time) {
329 return ZFFileModTime(pathConvert(pathData), time);
330 }
332 virtual zfbool ioFindFirst(
334 , ZF_IN const zfstring &pathData
335 ) {return ZFFileFindFirst(fd, pathConvert(pathData));}
337 virtual zfbool ioFindNext(ZF_IN_OUT ZFIOFindData &fd) {return ZFFileFindNext(fd);}
339 virtual void ioFindClose(ZF_IN_OUT ZFIOFindData &fd) {ZFFileFindClose(fd);}
341 virtual zfautoT<ZFIOToken> ioOpen(
342 ZF_IN const zfstring &pathData
344 , ZF_IN_OPT zfbool autoCreateParent = zftrue
345 );
346};
347
349#endif // #ifndef _ZFI_ZFIO_file_h_
350
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:191
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:195
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:207
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
_zft_zftimet zftimet
time unit, ensured at least 64 bit, ensured signed
Definition ZFCoreTypeDef_CoreType.h:203
#define zfindexMax()
(zfindex)-1, indicate a max index value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:159
ZFSeekPos
seek position similar to SEEK_SET of FILE operation
Definition ZFCoreTypeDef_OtherType.h:47
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
zfbool ZFFileClose(void *token)
close and save the file if need, return false if save failed
zftimet ZFFileModTime(const zfstring &path)
return last modified time, or zftimetInvalid if error or not available
zfbool ZFFilePathCreate(const zfstring &path, zfbool autoCreateParent=(_ZFT_t_zftrue))
make directory
zfbool ZFFileIsDir(const zfstring &path)
return true if path is a directory
zfbool ZFFileIsSymlink(const zfstring &path)
return true if path is a symbolic link
zfbool ZFFileIsExist(const zfstring &path)
return true if path is exist
zfbool ZFFileFindNext(ZFIOFindData &fd)
void ZFFileFindClose(ZFIOFindData &fd)
const zfstring & ZFPathType_file()
see ZFPathInfo
zfindex ZFFileWrite(void *token, const void *src, zfindex maxByteSize=(((zfindex) -1)))
write file, see ZFFileRead
void ZFFileFlush(void *token)
flush write buffer
zfindex ZFFileRead(void *token, void *buf, zfindex maxByteSize)
read file
zfindex ZFFileSize(void *token)
util method to get file's total size (not left size)
zfbool ZFFileSeek(void *token, zfindex byteSize, ZFSeekPos seekPos=(ZFSeekPosBegin))
similar to fseek, return false if seek out of range
ZFInput ZFInputForFile(const zfstring &filePath)
util to create a file input callback
Definition ZFIO_file.h:33
void * ZFFileOpen(const zfstring &filePath, ZFIOOpenOptionFlags flags, zfbool autoCreateParent=(_ZFT_t_zftrue))
open a file for read or write
zfbool ZFFileMove(const zfstring &dstPath, const zfstring &srcPath, zfbool isForce=(_ZFT_t_zftrue))
move a file or directory from srcPath to dstPath
zfbool ZFFileRemove(const zfstring &path, zfbool isRecursive=(_ZFT_t_zftrue), zfbool isForce=(_ZFT_t_zftrue))
delete a file or directory from srcPath to dstPath
ZFOutput ZFOutputForFile(const zfstring &filePath, ZFIOOpenOptionFlags flags=(v_ZFIOOpenOption::e_Write))
util to create a file output callback
Definition ZFIO_file.h:52
zfindex ZFFileTell(void *token)
get current file's position or zfindexMax() if error
zfbool ZFFileReadSymlinkT(zfstring &ret, const zfstring &path)
read symbolic link's original path, do nothing and return false if not symlink or failed
zfbool ZFFileFindFirst(ZFIOFindData &fd, const zfstring &path)
find file or directory, similar to FindFirstFile under Windows
zfstring ZFFileReadSymlink(const zfstring &path)
read symbolic link's original path, return path passed from param if not symlink or failed
abstract IO
#define ZFIO_DECLARE(ZFLIB_, pathType)
see ZFIOImplForPathType
Definition ZFIODef_fwd.h:597
zfbool ZFInputForPathInfoT(ZFCallback &ret, const ZFPathInfo &pathInfo)
see ZFInputForPathInfo
zfbool ZFOutputForPathInfoT(ZFCallback &ret, const ZFPathInfo &pathInfo, ZFIOOpenOptionFlags flags=(v_ZFIOOpenOption::e_Write))
see ZFOutputForPathInfo
#define ZFMP_IN_OUT(ParamType, paramName)
see ZFMP_IN
Definition ZFMethod.h:117
#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:108
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_FUNC_DECLARE_2(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:763
#define ZFMETHOD_FUNC_INLINE_DECLARE_2(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:835
#define ZFMETHOD_FUNC_INLINE_DECLARE_1(ZFLIB_, ReturnType, MethodName, ZFMP_0)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:692
#define ZFMETHOD_FUNC_DECLARE_3(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:910
#define ZFMETHOD_FUNC_DECLARE_1(ZFLIB_, ReturnType, MethodName, ZFMP_0)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:624
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:123
data used by ZFIO when finding files
Definition ZFIODef_fwd.h:71
see ZFIOImplForPathType
Definition ZFIODef_fwd.h:298
see v_ZFIOOpenOption, ZFIOOpenOptionFlagsToString, ZFIOOpenOptionFlagsFromString
Definition ZFIODef_fwd.h:49
general input callback
Definition ZFIOCallback_input.h:36
general output callback
Definition ZFIOCallback_output.h:37
path related info storage for impl, actual meaning of the info depends on impl
Definition ZFPathInfo.h:34
@ e_Write
Write(1 << 1)
Definition ZFIODef_fwd.h:43
type restrict version of zfauto
Definition zfautoFwd.h:108