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

# 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 const 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);
    00231
    00232 DKC_EXTERN BOOL WINAPI dkcFileAndFolderExist(const char *filename);
    00233
    00234 DKC_EXTERN BOOL WINAPI dkcFolderExist(const char *filename);
    00238 DKC_EXTERN ULONG WINAPI dkcFileSize(const char *filename);
    00242 DKC_EXTERN BOOL WINAPI dkcFileSize64(const char *filename,DWORD *high,DWORD *low);
    00243
    00244 DKC_INLINE BOOL dkcFileSize64V(const char *filename,uint64 *pv){
    00245     DWORD high,low;
    00246     if(FALSE==dkcFileSize64(filename,&high,&low)){
    00247         return FALSE;
    00248     }
    00249     dkcTwoDWORDToULONGLONG(pv,high,low);
    00250     return TRUE;
    00251 }
    00252
    00258 DKC_EXTERN BOOL WINAPI dkcCreateZeroByteFile(const char *filename,BOOL rewrite);
    00264 DKC_EXTERN int WINAPI dkcFileBinaryCompare(const char *filename1,const char *filename2);
    00265
    00274 DKC_EXTERN int WINAPI dkcMemoryToFile(const char *filename,const void *buff,size_t size,UINT flag);
    00275
    00283 DKC_EXTERN int WINAPI dkcFileToMemory(const char *filename,void *buff,size_t size);
    00284
    00285 /* 64bitファイルシステムができるまでお預け
    00286 DKC_EXTERN int WINAPI dkcMemoryToTextFile(const char *filename,const void *buff,size_t size);
    00287
    00288 DKC_EXTERN size_t WINAPI dkcTextFileToMemorySize(const char *filename);
    00289
    00290 DKC_EXTERN int WINAPI dkcTextFileToMemory(const char *filename,void *buff,size_t size);
    00291 */
    00292
    00296 typedef struct dkc_FileFinder{
    00298     DKC_PATHSTRING *mDir;
    00300     DKC_STRING *mTarget;
    00302     BOOL mbSubDir;
    00304     int mState;
    00306     DKC_STACK *mStack;
    00307 #   ifdef WIN32
    00308
    00309     HANDLE mHandle;
    00310     WIN32_FIND_DATAA mFindData;
    00311 #   else //linux or unix...
    00312     struct dirent *mDirent;
    00313     DIR *mHandle;
    00314 #   endif
    00315 }DKC_FILE_FINDER;
    00316
    00317 typedef struct dkc_FindFile{
    00318 #   ifdef WIN32
    00319
    00320     HANDLE mHandle;
    00321     WIN32_FIND_DATAA mFindData;
    00322 #   else //linux or unix...
    00323     struct dirent *mDirent;
    00324     DIR *mHandle;
    00325 #endif
    00326 }DKC_FINDFILE;
    00327
    00328 DKC_EXTERN DKC_FINDFILE *WINAPI dkcAllocFindFile();
    00329
    00330 DKC_EXTERN int WINAPI dkcFreeFindFile(DKC_FINDFILE **);
    00331
    00333 DKC_EXTERN int WINAPI dkcFindFirstFile(DKC_FINDFILE *ptr,const char *target);
    00335 DKC_EXTERN int WINAPI dkcFindNextFile(DKC_FINDFILE *ptr);
    00337 DKC_EXTERN int WINAPI dkcFindClose(DKC_FINDFILE *ptr);
    00338
    00339 DKC_EXTERN int WINAPI dkcFindFileGetFileName(DKC_FINDFILE *ptr,
    00340                                                                                          char *buff,size_t buffsize);
    00341
    00342 DKC_EXTERN BOOL WINAPI dkcFindFileIsFolder(DKC_FINDFILE *ptr);
    00343
    00344 DKC_EXTERN BOOL WINAPI dkcFindFileIsDot(DKC_FINDFILE *ptr);
    00345
    00346 DKC_EXTERN BOOL WINAPI dkcFindFileIsNormalFile(DKC_FINDFILE *ptr);
    00347
    00348 DKC_EXTERN BOOL WINAPI dkcFindFileIsReadOnly(DKC_FINDFILE *ptr);
    00349
    00350 DKC_EXTERN void WINAPI dkcFindFileSize(DKC_FINDFILE *ptr,ULONG *,ULONG *);
    00351
    00352
    00353
    00354
    00355 #if 0
    00356 enum edkcFileFinder{
    00358     edkcFileFinderEmpty = 0,
    00360     edkcFileFinderSearching,
    00362     edkcFileFinderFinish,
    00363 };
    00364
    00365
    00372 DKC_EXTERN DKC_FILE_FINDER * WINAPI dkcAllocFileFinder(
    00373             const char *target,const char *dir,BOOL bSubDir
    00374             );
    00375
    00376 DKC_EXTERN int WINAPI dkcFreeFileFinder(DKC_FILE_FINDER **);
    00377
    00378
    00386 DKC_EXTERN int WINAPI dkcFileFinderNext(
    00387     DKC_FILE_FINDER *ptr,DKC_PATHSTRING *path,BOOL *bCopySucceeded
    00388 );
    00389
    00390
    00391
    00396 DKC_EXTERN int WINAPI dkcFileFinderReferenceFileName(DKC_FILE_FINDER *ptr,DKC_PATHSTRING *path);
    00397
    00398 #ifdef __cplusplus
    00399 namespace dkutil{
    00400
    00401
    00410 template<class STL_T>
    00411 inline bool file_listup(const char *target,const char *dir,bool bSubDir,
    00412                                                 STL_T &c)
    00413 {
    00414     //定義
    00415     //typedef STL_T::iterator iterator;
    00416
    00417     bool result = false;
    00418     BOOL bCopySucceeded = FALSE;
    00419     DKC_PATHSTRING *pPath = NULL;
    00420     DKC_FILE_FINDER *pFinder = NULL;
    00421
    00422     //初期化
    00423     pPath = dkcAllocPathString(dir);
    00424     if(NULL==pPath){    return false;}
    00425     pFinder = dkcAllocFileFinder(target,dir,(BOOL)bSubDir);
    00426     if(NULL==pFinder){ goto Error;}
    00427
    00428     //std::string str;
    00429     //処理
    00430     for(;;){
    00431         int r = dkcFileFinderNext(pFinder,pPath,&bCopySucceeded);
    00432         if(edk_EndProcess == r){
    00433             break;
    00434         }else if(DKUTIL_FAILED(r)){
    00435             goto Error;
    00436         }
    00437         if(TRUE==bCopySucceeded){//コピーできている。
    00438             c.push_back(dkcPathStringPointer(pPath));
    00439         }
    00440     }
    00441
    00442     result = true;
    00443
    00444 Error://エラー∩後始末
    00445     dkcFreePathString(&pPath);
    00446     dkcFreeFileFinder(&pFinder);
    00447     return result;
    00448 }
    00449
    00450
    00451 }
    00452 #endif //end of __cplusplus
    00453
    00454
    00455 #endif //end of if 0
    00456
    00457
    00458
    00459 #endif //end of include once