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)
51 ) {
52 ZFOutput ret;
54 return ret;
55}
56
57// ============================================================
63 , ZFMP_IN(const zfstring &, path)
64 )
70 , ZFMP_IN(const zfstring &, path)
71 )
72
78 , ZFMP_IN(const zfstring &, path)
79 , ZFMP_IN_OPT(zfbool, autoCreateParent, zftrue)
80 )
81
89 , ZFMP_IN(const zfstring &, path)
90 , ZFMP_IN_OPT(zfbool, isRecursive, zftrue)
91 , ZFMP_IN_OPT(zfbool, isForce, zftrue)
92 )
98 , ZFMP_IN(const zfstring &, srcPath)
99 , ZFMP_IN(const zfstring &, dstPath)
100 , ZFMP_IN_OPT(zfbool, isForce, zftrue)
102
128 , ZFMP_IN(const zfstring &, path)
130
137
144
150 , ZFMP_IN(const zfstring &, filePath)
152 , ZFMP_IN_OPT(zfbool, autoCreateParent, zftrue)
158 , ZFMP_IN(void *, token)
160
178 , ZFMP_IN(void *, token)
179 , ZFMP_IN(void *, buf)
180 , ZFMP_IN(zfindex, maxByteSize)
182
199 , ZFMP_IN(void *, token)
200 , ZFMP_IN(const void *, src)
201 , ZFMP_IN_OPT(zfindex, maxByteSize, zfindexMax())
203
208 , ZFMP_IN(void *, token)
209 , ZFMP_IN(zfindex, byteSize)
210 , ZFMP_IN_OPT(ZFSeekPos, seekPos, ZFSeekPosBegin)
216 , ZFMP_IN(void *, token)
226 , ZFMP_IN(void *, token)
228
229// ============================================================
230zfclass ZFLIB_ZFCore _ZFP_I_ZFIOImpl_file : zfextend ZFIOImpl {
231 ZFOBJECT_DECLARE(_ZFP_I_ZFIOImpl_file, ZFIOImpl)
232protected:
233 virtual zfstring pathConvert(ZF_IN const zfstring &pathData) {
234 return pathData;
235 }
236public:
238 virtual zfstring pathType(void) {return ZFPathType_file();}
239
241 virtual zfbool ioIsExist(ZF_IN const zfstring &pathData) {return ZFFileIsExist(pathConvert(pathData));}
243 virtual zfbool ioIsDir(ZF_IN const zfstring &pathData) {return ZFFileIsDir(pathConvert(pathData));}
245 virtual zfbool ioToFileName(
247 , ZF_IN const zfstring &pathData
248 ) {return ioToFileNameDefault(ret, pathData);}
250 virtual zfbool ioToChild(
252 , ZF_IN const zfstring &pathData
253 , ZF_IN const zfstring &childName
254 ) {return ioToChildDefault(ret, pathData, childName);}
256 virtual zfbool ioToParent(
258 , ZF_IN const zfstring &pathData
259 ) {return ioToParentDefault(ret, pathData);}
261 virtual zfbool ioPathCreate(
262 ZF_IN const zfstring &pathData
263 , ZF_IN_OPT zfbool autoCreateParent = zftrue
264 ) {return ZFFilePathCreate(pathConvert(pathData), autoCreateParent);}
266 virtual zfbool ioRemove(
267 ZF_IN const zfstring &pathData
268 , ZF_IN_OPT zfbool isRecursive = zftrue
269 , ZF_IN_OPT zfbool isForce = zftrue
270 ) {return ZFFileRemove(pathConvert(pathData), isRecursive, isForce);}
272 virtual zfbool ioMove(
273 ZF_IN const zfstring &pathDataFrom
274 , ZF_IN const zfstring &pathDataTo
275 , ZF_IN_OPT zfbool isForce = zftrue
276 ) {return ZFFileMove(pathConvert(pathDataFrom), pathConvert(pathDataTo), isForce);}
278 virtual zfbool ioFindFirst(
280 , ZF_IN const zfstring &pathData
281 ) {return ZFFileFindFirst(fd, pathConvert(pathData));}
283 virtual zfbool ioFindNext(ZF_IN_OUT ZFIOFindData &fd) {return ZFFileFindNext(fd);}
285 virtual void ioFindClose(ZF_IN_OUT ZFIOFindData &fd) {ZFFileFindClose(fd);}
287 virtual zfautoT<ZFIOToken> ioOpen(
288 ZF_IN const zfstring &pathData
290 , ZF_IN_OPT zfbool autoCreateParent = zftrue
291 );
292};
293
295#endif // #ifndef _ZFI_ZFIO_file_h_
296
#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:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
_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
#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
zfbool ZFFileMove(const zfstring &srcPath, const zfstring &dstPath, zfbool isForce=(_ZFT_t_zftrue))
move a file or directory from srcPath to dstPath
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)
ZFOutput ZFOutputForFile(const zfstring &filePath)
util to create a file output callback
Definition ZFIO_file.h:51
const zfstring & ZFPathType_file()
see ZFPathInfo
zfindex ZFFileWrite(void *token, const void *src, zfindex maxByteSize=(((zfindex) -1)))
write file, see ZFFileRead
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 ZFFileRemove(const zfstring &path, zfbool isRecursive=(_ZFT_t_zftrue), zfbool isForce=(_ZFT_t_zftrue))
delete a file or directory from srcPath to dstPath
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:515
zfbool ZFInputForPathInfoT(ZFCallback &ret, const ZFPathInfo &pathInfo)
see ZFInputForPathInfo
zfbool ZFOutputForPathInfoT(ZFCallback &ret, const ZFPathInfo &pathInfo)
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_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:284
see v_ZFIOOpenOption, ZFIOOpenOptionFlagsToString, ZFIOOpenOptionFlagsFromString
Definition ZFIODef_fwd.h:49
general input callback
Definition ZFIOCallback_input.h:35
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
type restrict version of zfauto
Definition zfautoFwd.h:113