Main Page | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# dkcSJISFileSystem.h

Go to the documentation of this file.

    00001
    00010 #ifndef dkutil_c_SJISFileSystem__h
    00011 #define dkutil_c_SJISFileSystem__h
    00012
    00013 #include "dkcOSIndependent.h"
    00014 #include "dkcMemoryStream.h"
    00015 #include "dkcString.h"
    00016 #include "dkcStack.h"
    00017
    00018 #ifdef WIN32
    00019
    00020 #else
    00021
    00022
    00023 # include "dirent.h"
    00024 # include "unistd.h"
    00025 # include "fcntl.h"
    00026 # include "utime.h"
    00027
    00028 #endif
    00029
    00030
    00031 /* Generic */
    00033 DKC_EXTERN BOOL WINAPI dkcIsEffectivePath(const char *path,size_t size);
    00034
    00036 DKC_EXTERN BOOL WINAPI dkcIsRelativityPath(const char *path);
    00038 DKC_EXTERN BOOL WINAPI dkcIsAbsolutelyPath(const char *path);
    00048 DKC_EXTERN int WINAPI dkcCurrentDirectoryConcatenate(char *dest,size_t dsize,const char *src);
    00056 DKC_EXTERN int WINAPI dkcDirectoryConcatenate(char *dest,size_t dlen,size_t dsize,const char *src);
    00057
    00059 DKC_EXTERN BOOL WINAPI dkcIsTailPathSep(const char *src,size_t dlen);
    00069 DKC_EXTERN BOOL WINAPI dkcPushBackPathSep(char *dest,size_t dlen,size_t size);
    00070
    00072 DKC_EXTERN int WINAPI dkcToAbsolutelyPath(char *dest,size_t dsize,const char *src,size_t ssize);
    00073
    00086 typedef struct dkc_PathString{
    00087         DKC_STRING *mString;
    00089         size_t mIterateCount;
    00090 }DKC_PATHSTRING;
    00091
    00092 //PATHSTRINGの割り当て、解放
    00099 DKC_EXTERN DKC_PATHSTRING * WINAPI dkcAllocPathString(const char *path);
    00100
    00101 DKC_EXTERN int WINAPI dkcFreePathString(DKC_PATHSTRING **);
    00102
    00103 //パスのデータを得る。
    00104
    00105 DKC_EXTERN size_t WINAPI dkcPathStringSize(const DKC_PATHSTRING *);
    00106
    00107 DKC_EXTERN const char *WINAPI dkcPathStringPointer(const DKC_PATHSTRING *);
    00108
    00109
    00110 //パスを区切る。
    00111
    00112 DKC_EXTERN int WINAPI dkcPathStringDevideBegin(DKC_PATHSTRING *,char *buff,size_t size);
    00114 DKC_EXTERN int WINAPI dkcPathStringDevideNext(DKC_PATHSTRING *,char *buff,size_t size);
    00115
    00116 DKC_EXTERN void WINAPI dkcPathStringDevideEnd(DKC_PATHSTRING *);
    00117
    00118
    00119
    00120
    00122 DKC_EXTERN int WINAPI dkcPathStringCopy(DKC_PATHSTRING *,const char *buff,size_t size);
    00124 DKC_EXTERN int WINAPI dkcPathStringConcatenate(DKC_PATHSTRING *,const char *buff,size_t size);
    00125
    00126 /*
    00127 DKC_EXTERN int WINAPI dkcPathStringElementInsert(DKC_PATHSTRING *,const char *buff,size_t size);
    00128
    00129 DKC_EXTERN int WINAPI dkcPathStringElementReplace(DKC_PATHSTRING *,const char *buff,size_t size);
    00130 */
    00131
    00132 DKC_EXTERN int WINAPI dkcPathStringGetDrive(DKC_PATHSTRING *,char *buff,size_t size);
    00133
    00134 DKC_EXTERN int WINAPI dkcPathStringGetFileExtension(DKC_PATHSTRING *,char *buff,size_t size);
    00135
    00136 DKC_EXTERN int WINAPI dkcPathStringGetFileName(DKC_PATHSTRING *,char *buff,size_t size);
    00141 DKC_EXTERN int WINAPI dkcPathStringGetDirectory(DKC_PATHSTRING *,char *buff,size_t size);
    00142
    00143
    00144 //**********************************************************
    00145 //関数の後ろにLogicという名前がついているものは
    00146 //内部を理解していない場合は使わないで下さい。
    00147
    00149 DKC_EXTERN int WINAPI dkcPathStringDevideBegin_Logic(DKC_PATHSTRING *,size_t *count,char *buff,size_t size);
    00151 DKC_EXTERN int WINAPI dkcPathStringDevideNext_Logic(DKC_PATHSTRING *,size_t *count,char *buff,size_t size);
    00153 DKC_EXTERN void WINAPI dkcPathStringDevideEnd_Logic(size_t *count);
    00154
    00156 DKC_EXTERN int WINAPI dkcPathStringElementInsert_Logic(DKC_PATHSTRING *,size_t count,
    00157                                                                                                                                                                                                 const char *src,size_t len);
    00158
    00159 DKC_EXTERN int WINAPI dkcPathStringElementErase_Logic(DKC_PATHSTRING *,size_t count);
    00160
    00162 DKC_EXTERN int WINAPI dkcPathStringElementReplace_Logic(DKC_PATHSTRING *,size_t count,
    00163                                                                                                                                                                                                  const char *,size_t len);
    00164
    00165
    00173 DKC_EXTERN BOOL WINAPI dkcSetCurrentDirectory(const char *filename);
    00174
    00176 DKC_EXTERN BOOL WINAPI dkcGetCurrentDirectory(char *buff,size_t size);
    00177
    00182 DKC_EXTERN int WINAPI dkcCreateDirectory(const char *pPath);
    00188 DKC_EXTERN BOOL WINAPI dkcFileCopy(const char *dest,const char *src);
    00198 DKC_EXTERN BOOL WINAPI dkcFileCopyEx(const char *dest,const char *src,
    00199                                                                                                                                                 size_t inner_buffer_size,BOOL bThreadLock);
    00201 DKC_EXTERN BOOL WINAPI dkcFileRemove(const char *filename);
    00206 DKC_EXTERN BOOL WINAPI dkcFileRename(const char *oldname,const char *newname);
    00207
    00211 DKC_EXTERN BOOL WINAPI dkcFileExist(const char *filename);
    00215 DKC_EXTERN UINT WINAPI dkcFileSize(const char *filename);
    00216
    00220 typedef struct dkc_FileFinder{
    00222         DKC_PATHSTRING *mDir;
    00224         DKC_STRING *mTarget;
    00226         BOOL mbSubDir;
    00228         int mState;
    00230         DKC_STACK *mStack;
    00231 #       ifdef WIN32
    00232
    00233         HANDLE mHandle;
    00234         WIN32_FIND_DATAA mFindData;
    00235 #       else //linux or unix...
    00236         struct dirent *mDirent;
    00237         DIR *mHandle;
    00238 #       endif
    00239 }DKC_FILE_FINDER;
    00240
    00241 typedef struct dkc_FindFile{
    00242 #       ifdef WIN32
    00243
    00244         HANDLE mHandle;
    00245         WIN32_FIND_DATAA mFindData;
    00246 #       else //linux or unix...
    00247         struct dirent *mDirent;
    00248         DIR *mHandle;
    00249 #endif
    00250 }DKC_FINDFILE;
    00251
    00252 DKC_EXTERN DKC_FINDFILE *WINAPI dkcAllocFindFile();
    00253
    00254 DKC_EXTERN int WINAPI dkcFreeFindFile(DKC_FINDFILE **);
    00255
    00257 DKC_EXTERN int WINAPI dkcFindFirstFile(DKC_FINDFILE *ptr,const char *target);
    00259 DKC_EXTERN int WINAPI dkcFindNextFile(DKC_FINDFILE *ptr);
    00261 DKC_EXTERN int WINAPI dkcFindClose(DKC_FINDFILE *ptr);
    00262
    00263 DKC_EXTERN int WINAPI dkcFindFileGetFileName(DKC_FINDFILE *ptr,
    00264                                                                                                                                                                                  char *buff,size_t buffsize);
    00265
    00266 DKC_EXTERN BOOL WINAPI dkcFindFileIsFolder(DKC_FINDFILE *ptr);
    00267
    00268 DKC_EXTERN BOOL WINAPI dkcFindFileIsDot(DKC_FINDFILE *ptr);
    00269
    00270 DKC_EXTERN BOOL WINAPI dkcFindFileIsNormalFile(DKC_FINDFILE *ptr);
    00271
    00272 DKC_EXTERN BOOL WINAPI dkcFindFileIsReadOnly(DKC_FINDFILE *ptr);
    00273
    00274 DKC_EXTERN void WINAPI dkcFindFileSize(DKC_FINDFILE *ptr,ULONG *,ULONG *);
    00275
    00276 enum edkcFileFinder{
    00278         edkcFileFinderEmpty = 0,
    00280         edkcFileFinderSearching,
    00282         edkcFileFinderFinish,
    00283 };
    00284
    00285 #if 0
    00286
    00292 DKC_EXTERN DKC_FILE_FINDER * WINAPI dkcAllocFileFinder(
    00293                         const char *target,const char *dir,BOOL bSubDir
    00294                         );
    00295
    00296 DKC_EXTERN int WINAPI dkcFreeFileFinder(DKC_FILE_FINDER **);
    00297
    00298
    00306 DKC_EXTERN int WINAPI dkcFileFinderNext(
    00307         DKC_FILE_FINDER *ptr,DKC_PATHSTRING *path,BOOL *bCopySucceeded
    00308 );
    00309
    00310
    00311
    00316 DKC_EXTERN int WINAPI dkcFileFinderReferenceFileName(DKC_FILE_FINDER *ptr,DKC_PATHSTRING *path);
    00317
    00318 #ifdef __cplusplus
    00319 namespace dkutil{
    00320
    00321
    00330 template<class STL_T>
    00331 inline bool file_listup(const char *target,const char *dir,bool bSubDir,
    00332                                                                                                 STL_T &c)
    00333 {
    00334         //定義
    00335         //typedef STL_T::iterator iterator;
    00336
    00337         bool result = false;
    00338         BOOL bCopySucceeded = FALSE;
    00339         DKC_PATHSTRING *pPath = NULL;
    00340         DKC_FILE_FINDER *pFinder = NULL;
    00341
    00342         //初期化
    00343         pPath = dkcAllocPathString(dir);
    00344         if(NULL==pPath){        return false;}
    00345         pFinder = dkcAllocFileFinder(target,dir,(BOOL)bSubDir);
    00346         if(NULL==pFinder){ goto Error;}
    00347
    00348         //std::string str;
    00349         //処理
    00350         for(;;){
    00351                 int r = dkcFileFinderNext(pFinder,pPath,&bCopySucceeded);
    00352                 if(edk_EndProcess == r){
    00353                         break;
    00354                 }else if(DKUTIL_FAILED(r)){
    00355                         goto Error;
    00356                 }
    00357                 if(TRUE==bCopySucceeded){//コピーできている。
    00358                         c.push_back(dkcPathStringPointer(pPath));
    00359                 }
    00360         }
    00361
    00362         result = true;
    00363
    00364 Error://エラー∩後始末
    00365         dkcFreePathString(&pPath);
    00366         dkcFreeFileFinder(&pFinder);
    00367         return result;
    00368 }
    00369
    00370
    00371 }
    00372 #endif //end of __cplusplus
    00373
    00374
    00375 #endif //end of if 0
    00376
    00377 #endif //end of include once