メインページ | アルファベット順一覧 | 構成 | ファイル一覧 | 構成メンバ | ファイルメンバ | 関連ページ

# dkcSJISFileSystem.h

説明を見る。

    00001
    00010 #ifndef DKUTIL_C_SJIS_FILESYSTEM_H
    00011 #define DKUTIL_C_SJIS_FILESYSTEM_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 DKC_EXTERN char * WINAPI dkcGetFileExtension( const char *PathName );
    00031
    00032 DKC_EXTERN int WINAPI dkcIsShiftJIS( const char *str, int nPos );
    00033
    00034 /* Generic */
    00036 DKC_EXTERN BOOL WINAPI dkcIsEffectivePath(const char *path,size_t size);
    00037
    00039 DKC_EXTERN BOOL WINAPI dkcIsRelativityPath(const char *path);
    00041 DKC_EXTERN BOOL WINAPI dkcIsAbsolutelyPath(const char *path);
    00051 DKC_EXTERN int WINAPI dkcCurrentDirectoryConcatenate(char *dest,size_t dsize,const char *src);
    00059 DKC_EXTERN int WINAPI dkcDirectoryConcatenate(char *dest,size_t dlen,size_t dsize,const char *src);
    00060
    00062 DKC_EXTERN BOOL WINAPI dkcIsTailPathSep(const char *src,size_t dlen);
    00072 DKC_EXTERN BOOL WINAPI dkcPushBackPathSep(char *dest,size_t dlen,size_t size);
    00073
    00075 DKC_EXTERN int WINAPI dkcToAbsolutelyPath(char *dest,size_t dsize,const char *src,size_t ssize);
    00076
    00090 typedef struct dkc_PathString{
    00091     DKC_STRING *mString;
    00093     size_t mIterateCount;
    00094 }DKC_PATHSTRING;
    00095
    00096 //PATHSTRINGの割り当て、解放
    00103 DKC_EXTERN DKC_PATHSTRING * WINAPI dkcAllocPathString(const char *path);
    00104
    00105 DKC_EXTERN int WINAPI dkcFreePathString(DKC_PATHSTRING **);
    00106
    00107 //パスのデータを得る。
    00108
    00109 DKC_EXTERN size_t WINAPI dkcPathStringSize(const DKC_PATHSTRING *);
    00110
    00111 DKC_EXTERN const char *WINAPI dkcPathStringPointer(const DKC_PATHSTRING *);
    00112
    00113
    00114 //パスを区切る。
    00115
    00116 DKC_EXTERN int WINAPI dkcPathStringDevideBegin(DKC_PATHSTRING *,char *buff,size_t size);
    00118 DKC_EXTERN int WINAPI dkcPathStringDevideNext(DKC_PATHSTRING *,char *buff,size_t size);
    00119
    00120 DKC_EXTERN void WINAPI dkcPathStringDevideEnd(DKC_PATHSTRING *);
    00121
    00122
    00123
    00124
    00126 DKC_EXTERN int WINAPI dkcPathStringCopy(DKC_PATHSTRING *,const char *buff,size_t size);
    00128 DKC_EXTERN int WINAPI dkcPathStringConcatenate(DKC_PATHSTRING *,const char *buff,size_t size);
    00129
    00130 DKC_EXTERN int WINAPI dkcPathStringNormalizeConcatenateLogic(
    00131     DKC_PATHSTRING *ptr,const char *buff,size_t size);
    00132 /*
    00133 DKC_EXTERN int WINAPI dkcPathStringElementInsert(DKC_PATHSTRING *,const char *buff,size_t size);
    00134
    00135 DKC_EXTERN int WINAPI dkcPathStringElementReplace(DKC_PATHSTRING *,const char *buff,size_t size);
    00136 */
    00137
    00138 DKC_EXTERN int WINAPI dkcPathStringGetDrive(DKC_PATHSTRING *,char *buff,size_t size);
    00139
    00140 DKC_EXTERN int WINAPI dkcPathStringGetFileExtension(DKC_PATHSTRING *,char *buff,size_t size);
    00141
    00142 DKC_EXTERN int WINAPI dkcPathStringGetFileName(DKC_PATHSTRING *,char *buff,size_t size);
    00147 DKC_EXTERN int WINAPI dkcPathStringGetDirectory(DKC_PATHSTRING *,char *buff,size_t size);
    00148
    00149
    00150 //**********************************************************
    00151 //関数の後ろにLogicという名前がついているものは
    00152 //内部を理解していない場合は使わな方が無難です。
    00153
    00155 DKC_EXTERN int WINAPI dkcPathStringDevideBegin_Logic(DKC_PATHSTRING *,size_t *count,char *buff,size_t size);
    00157 DKC_EXTERN int WINAPI dkcPathStringDevideNext_Logic(DKC_PATHSTRING *,size_t *count,char *buff,size_t size);
    00159 DKC_EXTERN void WINAPI dkcPathStringDevideEnd_Logic(size_t *count);
    00160
    00162 DKC_EXTERN int WINAPI dkcPathStringElementInsert_Logic(DKC_PATHSTRING *,size_t count,
    00163                                                                                                 const char *src,size_t len);
    00164
    00165 DKC_EXTERN int WINAPI dkcPathStringElementErase_Logic(DKC_PATHSTRING *,size_t count);
    00166
    00168 DKC_EXTERN int WINAPI dkcPathStringElementReplace_Logic(DKC_PATHSTRING *,size_t count,
    00169                                                                                                  const char *,size_t len);
    00170
    00171
    00179 DKC_EXTERN BOOL WINAPI dkcSetCurrentDirectory(const char *filename);
    00180
    00182 DKC_EXTERN BOOL WINAPI dkcGetCurrentDirectory(char *buff,size_t size);
    00183
    00188 DKC_EXTERN int WINAPI dkcCreateDirectory(const char *pPath);
    00194 DKC_EXTERN BOOL WINAPI dkcFileCopy(const char *dest,const char *src,BOOL bReWrite);
    00195
    00196
    00197
    00198 typedef struct dkc_FileCopyExCallbackData{
    00199     size_t filesize;
    00200     size_t count;
    00201 }DKC_FILECOPY_CALLBACK_STRUCT;
    00214 DKC_EXTERN BOOL WINAPI dkcFileCopyEx(const char *dest,const char *src,
    00215                                                                         size_t inner_buffer_size,
    00216                                                                         BOOL bReWrite,BOOL bThreadLock,
    00217                                                                         DKC_STD_CALLBACK pcallback,void *parg);
    00218
    00220 DKC_EXTERN BOOL WINAPI dkcFileRemove(const char *filename);
    00225 DKC_EXTERN BOOL WINAPI dkcFileRename(const char *oldname,const char *newname);
    00226
    00230 DKC_EXTERN BOOL WINAPI dkcFileExist(const char *filename);
    00234 DKC_EXTERN ULONG WINAPI dkcFileSize(const char *filename);
    00238 DKC_EXTERN BOOL WINAPI dkcFileSize64(const char *filename,DWORD *high,DWORD *low);
    00239
    00245 DKC_EXTERN BOOL WINAPI dkcCreateZeroByteFile(const char *filename,BOOL rewrite);
    00251 DKC_EXTERN int WINAPI dkcFileBinaryCompare(const char *filename1,const char *filename2);
    00252
    00261 DKC_EXTERN int WINAPI dkcMemoryToFile(const char *filename,const void *buff,size_t size,UINT flag);
    00262
    00270 DKC_EXTERN int WINAPI dkcFileToMemory(const char *filename,void *buff,size_t size);
    00271
    00272 /* 64bitファイルシステムができるまでお預け
    00273 DKC_EXTERN int WINAPI dkcMemoryToTextFile(const char *filename,const void *buff,size_t size);
    00274
    00275 DKC_EXTERN size_t WINAPI dkcTextFileToMemorySize(const char *filename);
    00276
    00277 DKC_EXTERN int WINAPI dkcTextFileToMemory(const char *filename,void *buff,size_t size);
    00278 */
    00279
    00283 typedef struct dkc_FileFinder{
    00285     DKC_PATHSTRING *mDir;
    00287     DKC_STRING *mTarget;
    00289     BOOL mbSubDir;
    00291     int mState;
    00293     DKC_STACK *mStack;
    00294 #   ifdef WIN32
    00295
    00296     HANDLE mHandle;
    00297     WIN32_FIND_DATAA mFindData;
    00298 #   else //linux or unix...
    00299     struct dirent *mDirent;
    00300     DIR *mHandle;
    00301 #   endif
    00302 }DKC_FILE_FINDER;
    00303
    00304 typedef struct dkc_FindFile{
    00305 #   ifdef WIN32
    00306
    00307     HANDLE mHandle;
    00308     WIN32_FIND_DATAA mFindData;
    00309 #   else //linux or unix...
    00310     struct dirent *mDirent;
    00311     DIR *mHandle;
    00312 #endif
    00313 }DKC_FINDFILE;
    00314
    00315 DKC_EXTERN DKC_FINDFILE *WINAPI dkcAllocFindFile();
    00316
    00317 DKC_EXTERN int WINAPI dkcFreeFindFile(DKC_FINDFILE **);
    00318
    00320 DKC_EXTERN int WINAPI dkcFindFirstFile(DKC_FINDFILE *ptr,const char *target);
    00322 DKC_EXTERN int WINAPI dkcFindNextFile(DKC_FINDFILE *ptr);
    00324 DKC_EXTERN int WINAPI dkcFindClose(DKC_FINDFILE *ptr);
    00325
    00326 DKC_EXTERN int WINAPI dkcFindFileGetFileName(DKC_FINDFILE *ptr,
    00327                                                                                          char *buff,size_t buffsize);
    00328
    00329 DKC_EXTERN BOOL WINAPI dkcFindFileIsFolder(DKC_FINDFILE *ptr);
    00330
    00331 DKC_EXTERN BOOL WINAPI dkcFindFileIsDot(DKC_FINDFILE *ptr);
    00332
    00333 DKC_EXTERN BOOL WINAPI dkcFindFileIsNormalFile(DKC_FINDFILE *ptr);
    00334
    00335 DKC_EXTERN BOOL WINAPI dkcFindFileIsReadOnly(DKC_FINDFILE *ptr);
    00336
    00337 DKC_EXTERN void WINAPI dkcFindFileSize(DKC_FINDFILE *ptr,ULONG *,ULONG *);
    00338
    00339
    00340
    00341
    00342 #if 0
    00343 enum edkcFileFinder{
    00345     edkcFileFinderEmpty = 0,
    00347     edkcFileFinderSearching,
    00349     edkcFileFinderFinish,
    00350 };
    00351
    00352
    00359 DKC_EXTERN DKC_FILE_FINDER * WINAPI dkcAllocFileFinder(
    00360             const char *target,const char *dir,BOOL bSubDir
    00361             );
    00362
    00363 DKC_EXTERN int WINAPI dkcFreeFileFinder(DKC_FILE_FINDER **);
    00364
    00365
    00373 DKC_EXTERN int WINAPI dkcFileFinderNext(
    00374     DKC_FILE_FINDER *ptr,DKC_PATHSTRING *path,BOOL *bCopySucceeded
    00375 );
    00376
    00377
    00378
    00383 DKC_EXTERN int WINAPI dkcFileFinderReferenceFileName(DKC_FILE_FINDER *ptr,DKC_PATHSTRING *path);
    00384
    00385 #ifdef __cplusplus
    00386 namespace dkutil{
    00387
    00388
    00397 template<class STL_T>
    00398 inline bool file_listup(const char *target,const char *dir,bool bSubDir,
    00399                                                 STL_T &c)
    00400 {
    00401     //定義
    00402     //typedef STL_T::iterator iterator;
    00403
    00404     bool result = false;
    00405     BOOL bCopySucceeded = FALSE;
    00406     DKC_PATHSTRING *pPath = NULL;
    00407     DKC_FILE_FINDER *pFinder = NULL;
    00408
    00409     //初期化
    00410     pPath = dkcAllocPathString(dir);
    00411     if(NULL==pPath){    return false;}
    00412     pFinder = dkcAllocFileFinder(target,dir,(BOOL)bSubDir);
    00413     if(NULL==pFinder){ goto Error;}
    00414
    00415     //std::string str;
    00416     //処理
    00417     for(;;){
    00418         int r = dkcFileFinderNext(pFinder,pPath,&bCopySucceeded);
    00419         if(edk_EndProcess == r){
    00420             break;
    00421         }else if(DKUTIL_FAILED(r)){
    00422             goto Error;
    00423         }
    00424         if(TRUE==bCopySucceeded){//コピーできている。
    00425             c.push_back(dkcPathStringPointer(pPath));
    00426         }
    00427     }
    00428
    00429     result = true;
    00430
    00431 Error://エラー∩後始末
    00432     dkcFreePathString(&pPath);
    00433     dkcFreeFileFinder(&pFinder);
    00434     return result;
    00435 }
    00436
    00437
    00438 }
    00439 #endif //end of __cplusplus
    00440
    00441
    00442 #endif //end of if 0
    00443
    00444
    00445
    00446 #endif //end of include once