filex.h

C:\home\SVGCats_src\src\filex.h

[目次 | 型・クラス・構造体 | マクロ]

目次

型・クラス・構造体一覧

マクロ一覧


   1|/**************************************************************************
   2|*  1. <<< ファイルの拡張 (FileX) >>> 
   3|***************************************************************************/
   4|
   5|#ifndef __FILEX_H
   6|#define __FILEX_H
   7|
   8|#if !defined(FOR_STDLIB) && !defined(USES_STDLIBS)
   9|#error  need Standard Library
  10|#endif
  11|#include  <stdio.h>
  12|#ifndef  FOR_WINCE
  13| #include  <time.h>
  14| #include  <io.h>
  15|#endif
  16|
  17|
  18|
  19| 
  20|/*************************************************************************
  21|*  2. <<< モジュール設定・優先ヘッダ >>> 
  22|**************************************************************************/
  23|#ifndef USES_PRIORITY_HEADER
  24|/*[START_OF_PRIORITY_HEADER]*/
  25|
  26|#ifndef  USES_FILEX
  27|#define  USES_FILEX
  28|
  29|
  30|/* ディスク容量不足のシミュレーション、#define しなければシミュレートしない */
  31|/* FileX_FreeSpc_scan 関数を参照 */
  32|/*#define  FILEX_FREESIZE*/
  33|
  34|typedef  struct _FileX_UniRead  FileX_UniRead;
  35|typedef  struct _FileX_UniWrite FileX_UniWrite;
  36|typedef  struct _FileX_CurDir   FileX_CurDir;
  37|typedef  struct _FileX_FreeSpc  FileX_FreeSpc;
  38|
  39|
  40|/*  3. <<< [FileX_CallBack] コピー中の進捗状況表示のためのコールバック関数の型 >>> */
  41|/*typedef  void  (*FileX_CopyBack)( void*, int now, int all );*/
  42|#ifdef __cplusplus
  43|extern "C" {
  44|#endif
  45|typedef  void  (*FileX_CallBack)( void*, int now, int all );
  46|#ifdef __cplusplus
  47|}
  48|#endif
  49|
  50|
  51|#define  STDLIBS_INCLUDE_LIMITS_H
  52|
  53|
  54|#endif  /* USES_FILEX */
  55|
  56|
  57|/*[END_OF_PRIORITY_HEADER]*/
  58|#endif /* USES_PRIORITY_HEADER */
  59| 
  60|/*************************************************************************
  61|*  4. <<< エラーコード >>> 
  62|**************************************************************************/
  63|#define  FileX_Err_EOF  (361)              /* [Compone_GID:Errors_Code] */
  64|#define  FileX_Err_CannotWriteOpen  (362)  /* [Compone_GID:Errors_Code] */
  65|#define  FileX_Err_CannotReadOpen   (363)  /* [Compone_GID:Errors_Code] */
  66|#define  FileX_Err_NotFindCopySrc   (364)  /* [Compone_GID:Errors_Code] */
  67|#define  FileX_Err_CannotWrite      (365)  /* [Compone_GID:Errors_Code] */
  68|#define  FileX_Err_CannotMkdir      (366)  /* [Compone_GID:Errors_Code] */
  69|#define  FileX_Err_AccessDenied     (367)  /* [Compone_GID:Errors_Code] */
  70|#define  FileX_Err_NotUnicodeFile   (368)  /* [Compone_GID:Errors_Code] */
  71| 
  72|/*-------------------------------------------------------------------*/
  73|/* 5. <<< Interface Area ------------------------------------------ >>> */ 
  74|/*-------------------------------------------------------------------*/
  75|
  76|#ifdef __cplusplus
  77|extern "C" {
  78|#endif
  79|
  80| 
  81|/*************************************************************************
  82|*  6. <<< [FileX] ファイル >>> 
  83|**************************************************************************/
  84|FILE* FileX_open( const char* path, const char* mode );
  85|char* FileX_getOpenedFName( FILE* fp );
  86|void  FileX_getCSV( FILE* file, char* data, int data_maxLen );
  87|void  FileX_skipCSV( FILE* file );
  88|void  FileX_putCSV( FILE* file, char* data );
  89|
  90|bool  FileX_isExist( const char* path );
  91|bool  FileX_isDir( const char* path );
  92|int   FileX_getOneExistWild( const char* wild_path, char* first_path );
  93|void  FileX_getUpdate( const char* path, time_t* date );
  94|void  FileX_setUpdate( const char* path, time_t* date );
  95|int   FileX_getSize( const char* path );
  96|int   FileX_getSftSum( const char* path, int maxFileSize );
  97|#if  defined(USES_FILEFIND) && defined(USES_STRX)
  98|void  FileX_getPathes( const char* folder, StrX_Mem* files );
  99|#endif
 100|bool  FileX_repairExt( char* path );
 101|
 102|int   FileX_cmpTime( const char* pathA, const char* pathB );
 103|void  FileX_getTmpPath( const char* prefix, char* path );
 104|void  FileX_getTmpPath2( const char* prefix, const char* folder, char* path );
 105|void  FileX_getTmpPath3( const char* folder, const char* prefix, const char* ext, char* path );
 106|
 107|int   FileX_isDiff( const char* fNameA, const char* fNameB );
 108|#ifdef  USES_STDPLUS
 109|void  FileX_copy( const char* to_path, const char* from_path );
 110|void  FileX_copy2( const char* to_path, const char* from_path,
 111|  FileX_CallBack callback, void* obj );
 112|void  FileX_move( const char* to_path, const char* from_path );
 113|int   FileX_copyPickup( const char* to_path, const char* from_path,
 114|  int startPos, int endPos );
 115|int   FileX_copyPickup2( const char* to_path, const char* from_path,
 116|  int startPos, int endPos, FileX_CallBack callback, void* obj );
 117|void  FileX_outPart( FILE* out, FILE* in, int in_start, int in_over );
 118|
 119|#endif
 120|#ifdef  USES_STRX
 121|#ifdef  USES_STDPLUS
 122|#ifdef  USES_FILEFIND
 123|void  FileX_copyFolder( const char* to_path, const char* from_path,
 124|  bool bSub );
 125|#endif
 126|#endif
 127|#endif
 128|#ifdef  USES_NESTFIND
 129|void  FileX_removeFolder( const char* path );
 130|#endif
 131|void  FileX_removeWild( const char* wildPath );
 132|void  FileX_setReadOnly( const char* path, bool bReadOnly );
 133|
 134|void  FileX_cat( const char* to_path, const char* from_path );
 135|void  FileX_include( FILE* to, const char* from_path, int mode );
 136|
 137|void  FileX_putBase64( FILE* f, const char* srcPath, const char* retCh );
 138|void  FileX_scanBase64( FILE* f, long pos, const char* outPath );
 139|
 140|#ifdef USES_STRX
 141|#ifdef USES_BIGSTACK
 142|void  FileX_mkdir2( const char* path, int bFile );
 143|#endif
 144|#endif
 145|void  FileX_backup( const char* path );
 146|void  FileX_toBackupPath( char* path );
 147|void  FileX_write( const char* path, const char* flag, void* data, int size );
 148|int   FileX_read0( const char* path, const char* flag, void* data, int size );
 149|
 150|extern bool  FileX_bCopyFailed;  /* → FileX_copy(), 書きこみに失敗したことがあるかどうか */
 151| 
 152|/*************************************************************************
 153|*  7. <<< [FileX_UniRead] UNICODE ファイルを Shift-JIS として読み込むフィルタ >>> 
 154|**************************************************************************/
 155|#if  defined(FOR_WIN32) || defined(FOR_DOS32)
 156|char*  FileX_UniRead_init( FileX_UniRead* m, const char* path );
 157|void   FileX_UniRead_finish( FileX_UniRead* m );
 158|bool   FileX_UniRead_isUniFile( FileX_UniRead* m );
 159|
 160|void   FileX_copyUni2SJis( const char* toSjisPath, const char* fromUniPath );
 161|bool   FileX_isUnicodeFIle( const char* path );
 162|
 163|struct _FileX_UniRead {
 164|  char  tmp_path[_MAX_PATH];
 165|
 166|  ERRORS_INITCHK_VAR
 167|};
 168|#endif
 169|
 170| 
 171|/*************************************************************************
 172|*  8. <<< [FileX_UniWrite] Shift-JIS 形式で書き込む UNICODE ファイルフィルタ >>> 
 173|**************************************************************************/
 174|#if  defined(FOR_WIN32) || defined(FOR_DOS32)
 175|char*  FileX_UniWrite_init( FileX_UniWrite* m, const char* path );
 176|void   FileX_UniWrite_finish( FileX_UniWrite* m );
 177|void   FileX_copySJis2Uni( const char* toUniPath, const char* fromSJisPath );
 178|
 179|struct _FileX_UniWrite {
 180|  char  path[_MAX_PATH];
 181|  char  tmp_path[_MAX_PATH];
 182|
 183|  ERRORS_INITCHK_VAR
 184|};
 185|#endif
 186| 
 187|/*************************************************************************
 188|*  9. <<< [FileX_CurDir] カレントフォルダ・スタック >>> 
 189|**************************************************************************/
 190|#ifdef USES_BIGSTACK
 191|struct _FileX_CurDir {
 192|  char*  curPath;  /* これまでのカレントフォルダの絶対パス */
 193|};
 194|void  FileX_CurDir_init( FileX_CurDir*, const char* path );
 195|void  FileX_CurDir_finish( FileX_CurDir* );
 196|#endif
 197|
 198|#define FileX_fname_max  256
 199|
 200|
 201|
 202| 
 203|/*************************************************************************
 204|*  10. <<< [FileX_FreeSpc] ディスクの空き容量 >>> 
 205|**************************************************************************/
 206|struct _FileX_FreeSpc {
 207|  unsigned long  sectorsPerCluster;
 208|  unsigned long  bytesPerSector;
 209|  unsigned long  numberOfFreeClusters;
 210|  unsigned long  totalNumberOfClusters;
 211|};
 212|
 213|void  FileX_FreeSpc_init( FileX_FreeSpc* );
 214|void  FileX_FreeSpc_scan( FileX_FreeSpc*, const char* root_path );
 215|int   FileX_FreeSpc_getFreeSize( FileX_FreeSpc* );
 216|int   FileX_FreeSpc_getTotalSize( FileX_FreeSpc* );
 217|int   FileX_FreeSpc_getUseFileSize( FileX_FreeSpc*, const char* path );
 218|int   FileX_FreeSpc_culcNCluster( FileX_FreeSpc*, int size );
 219|
 220|#define  FILEX_TO_LAST    -1
 221|#define  FILEX_TO_FULL    -2
 222|
 223|#ifdef  FILEX_FREESIZE
 224|  extern  FileX_FreeSpc  FileX_freeSpcSym;
 225|#endif
 226| 
 227|#ifdef __cplusplus
 228|}
 229|#endif
 230|
 231|/*-------------------------------------------------------------------*/
 232|/* 11. <<< Mapping Area -------------------------------------------- >>> */ 
 233|/*-------------------------------------------------------------------*/
 234|
 235|
 236| 
 237|/***********************************************************************
 238|  12. <<< [FileX_UniRead_isUniFile] UNICODE ファイルかどうかを返す >>> 
 239|【補足】
 240|・bool   FileX_UniRead_isUniFile( FileX_UniRead* m );
 241|************************************************************************/
 242|#define  FileX_UniRead_isUniFile( m ) \
 243|  ( (m)->m_tmp_path[0] != '\0' )
 244|
 245| 
 246|#endif /* __FILEX_H */ 
 247| 
 248|