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 )
73
79 , ZFMP_IN(const zfstring &, path)
80 , ZFMP_IN_OPT(zfbool, autoCreateParent, zftrue)
81 )
82
90 , ZFMP_IN(const zfstring &, path)
91 , ZFMP_IN_OPT(zfbool, isRecursive, zftrue)
92 , ZFMP_IN_OPT(zfbool, isForce, zftrue)
93 )
99 , ZFMP_IN(const zfstring &, dstPath)
100 , ZFMP_IN(const zfstring &, srcPath)
101 , ZFMP_IN_OPT(zfbool, isForce, zftrue)
108 , ZFMP_IN(const zfstring &, path)
115 , ZFMP_IN(const zfstring &, path)
116 , ZFMP_IN(zftimet, time)
118
144 , ZFMP_IN(const zfstring &, path)
146
153
160
166 , ZFMP_IN(const zfstring &, filePath)
168 , ZFMP_IN_OPT(zfbool, autoCreateParent, zftrue)
174 , ZFMP_IN(void *, token)
176
194 , ZFMP_IN(void *, token)
195 , ZFMP_IN(void *, buf)
196 , ZFMP_IN(zfindex, maxByteSize)
198
215 , ZFMP_IN(void *, token)
216 , ZFMP_IN(const void *, src)
217 , ZFMP_IN_OPT(zfindex, maxByteSize, zfindexMax())
223 , ZFMP_IN(void *, token)
225
230 , ZFMP_IN(void *, token)
231 , ZFMP_IN(zfindex, byteSize)
232 , ZFMP_IN_OPT(ZFSeekPos, seekPos, ZFSeekPosBegin)
238 , ZFMP_IN(void *, token)
248 , ZFMP_IN(void *, token)
250
251// ============================================================
252zfclass ZFLIB_ZFCore _ZFP_I_ZFIOImpl_file : zfextend ZFIOImpl {
253 ZFOBJECT_DECLARE(_ZFP_I_ZFIOImpl_file, ZFIOImpl)
254protected:
255 virtual zfstring pathConvert(ZF_IN const zfstring &pathData) {
256 return pathData;
257 }
258public:
260 virtual zfstring pathType(void) {return ZFPathType_file();}
261
263 virtual zfbool ioIsExist(ZF_IN const zfstring &pathData) {return ZFFileIsExist(pathConvert(pathData));}
265 virtual zfbool ioIsDir(ZF_IN const zfstring &pathData) {return ZFFileIsDir(pathConvert(pathData));}
267 virtual zfbool ioToFileName(
269 , ZF_IN const zfstring &pathData
270 ) {return ioToFileNameDefault(ret, pathData);}
272 virtual zfbool ioToChild(
274 , ZF_IN const zfstring &pathData
275 , ZF_IN const zfstring &childName
276 ) {return ioToChildDefault(ret, pathData, childName);}
278 virtual zfbool ioToParent(
280 , ZF_IN const zfstring &pathData
281 ) {return ioToParentDefault(ret, pathData);}
283 virtual zfbool ioPathCreate(
284 ZF_IN const zfstring &pathData
285 , ZF_IN_OPT zfbool autoCreateParent = zftrue
286 ) {return ZFFilePathCreate(pathConvert(pathData), autoCreateParent);}
288 virtual zfbool ioRemove(
289 ZF_IN const zfstring &pathData
290 , ZF_IN_OPT zfbool isRecursive = zftrue
291 , ZF_IN_OPT zfbool isForce = zftrue
292 ) {return ZFFileRemove(pathConvert(pathData), isRecursive, isForce);}
294 virtual zfbool ioMove(
295 ZF_IN const zfstring &pathDataTo
296 , ZF_IN const zfstring &pathDataFrom
297 , ZF_IN_OPT zfbool isForce = zftrue
298 ) {return ZFFileMove(pathConvert(pathDataTo), pathConvert(pathDataFrom), isForce);}
300 virtual zftimet ioModTime(ZF_IN const zfstring &pathData) {
301 return ZFFileModTime(pathConvert(pathData));
302 }
304 virtual zfbool ioModTime(ZF_IN const zfstring &pathData, ZF_IN zftimet time) {
305 return ZFFileModTime(pathConvert(pathData), time);
306 }
308 virtual zfbool ioFindFirst(
310 , ZF_IN const zfstring &pathData
311 ) {return ZFFileFindFirst(fd, pathConvert(pathData));}
313 virtual zfbool ioFindNext(ZF_IN_OUT ZFIOFindData &fd) {return ZFFileFindNext(fd);}
315 virtual void ioFindClose(ZF_IN_OUT ZFIOFindData &fd) {ZFFileFindClose(fd);}
317 virtual zfautoT<ZFIOToken> ioOpen(
318 ZF_IN const zfstring &pathData
320 , ZF_IN_OPT zfbool autoCreateParent = zftrue
321 );
322};
323
325#endif // #ifndef _ZFI_ZFIO_file_h_
326
#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:184
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:188
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:200
_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 file specified by path is a directory
zfbool ZFFileIsExist(const zfstring &path)
return true if file specified by 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 ZFFileFindFirst(ZFIOFindData &fd, const zfstring &path)
find file or directory, similar to FindFirstFile under Windows
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:126
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