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|int FileX_cmpTime( const char* pathA, const char* pathB );
101|void FileX_getTmpPath( const char* prefix, char* path );
102|void FileX_getTmpPath2( const char* prefix, const char* folder, char* path );
103|void FileX_getTmpPath3( const char* folder, const char* prefix, const char* ext, char* path );
104|
105|int FileX_isDiff( const char* fNameA, const char* fNameB );
106|#ifdef USES_STDPLUS
107|void FileX_copy( const char* to_path, const char* from_path );
108|void FileX_copy2( const char* to_path, const char* from_path,
109| FileX_CallBack callback, void* obj );
110|void FileX_move( const char* to_path, const char* from_path );
111|int FileX_copyPickup( const char* to_path, const char* from_path,
112| int startPos, int endPos );
113|int FileX_copyPickup2( const char* to_path, const char* from_path,
114| int startPos, int endPos, FileX_CallBack callback, void* obj );
115|void FileX_outPart( FILE* out, FILE* in, int in_start, int in_over );
116|
117|#endif
118|#ifdef USES_STRX
119|#ifdef USES_STDPLUS
120|#ifdef USES_FILEFIND
121|void FileX_copyFolder( const char* to_path, const char* from_path,
122| bool bSub );
123|#endif
124|#endif
125|#endif
126|#ifdef USES_NESTFIND
127|void FileX_removeFolder( const char* path );
128|#endif
129|void FileX_setReadOnly( const char* path, bool bReadOnly );
130|
131|void FileX_cat( const char* to_path, const char* from_path );
132|void FileX_include( FILE* to, const char* from_path, int mode );
133|#ifdef USES_STRX
134|#ifdef USES_BIGSTACK
135|void FileX_mkdir2( const char* path, int bFile );
136|#endif
137|#endif
138|void FileX_backup( const char* path );
139|void FileX_restoreIfSame( const char* path );
140|void FileX_toBackupPath( char* path );
141|void FileX_write( const char* path, const char* flag, void* data, int size );
142|int FileX_read0( const char* path, const char* flag, void* data, int size );
143|
144|extern bool FileX_bCopyFailed; /* → FileX_copy(), 書きこみに失敗したことがあるかどうか */
145|
146|/*************************************************************************
147|* 7. <<< [FileX_UniRead] UNICODE ファイルを Shift-JIS として読み込むフィルタ >>>
148|**************************************************************************/
149|#if defined(FOR_WIN32) || defined(FOR_DOS32)
150|char* FileX_UniRead_init( FileX_UniRead* m, const char* path );
151|void FileX_UniRead_finish( FileX_UniRead* m );
152|bool FileX_UniRead_isUniFile( FileX_UniRead* m );
153|
154|void FileX_copyUni2SJis( const char* toSjisPath, const char* fromUniPath );
155|bool FileX_isUnicodeFIle( const char* path );
156|
157|struct _FileX_UniRead {
158| char tmp_path[_MAX_PATH];
159|
160| ERRORS_INITCHK_VAR
161|};
162|#endif
163|
164|
165|/*************************************************************************
166|* 8. <<< [FileX_UniWrite] Shift-JIS 形式で書き込む UNICODE ファイルフィルタ >>>
167|**************************************************************************/
168|#if defined(FOR_WIN32) || defined(FOR_DOS32)
169|char* FileX_UniWrite_init( FileX_UniWrite* m, const char* path );
170|void FileX_UniWrite_finish( FileX_UniWrite* m );
171|void FileX_copySJis2Uni( const char* toUniPath, const char* fromSJisPath );
172|
173|struct _FileX_UniWrite {
174| char path[_MAX_PATH];
175| char tmp_path[_MAX_PATH];
176|
177| ERRORS_INITCHK_VAR
178|};
179|#endif
180|
181|/*************************************************************************
182|* 9. <<< [FileX_CurDir] カレントフォルダ・スタック >>>
183|**************************************************************************/
184|#ifdef USES_BIGSTACK
185|struct _FileX_CurDir {
186| char* curPath; /* これまでのカレントフォルダの絶対パス */
187|};
188|void FileX_CurDir_init( FileX_CurDir*, const char* path );
189|void FileX_CurDir_finish( FileX_CurDir* );
190|#endif
191|
192|#define FileX_fname_max 256
193|
194|
195|
196|
197|/*************************************************************************
198|* 10. <<< [FileX_FreeSpc] ディスクの空き容量 >>>
199|**************************************************************************/
200|struct _FileX_FreeSpc {
201| unsigned long sectorsPerCluster;
202| unsigned long bytesPerSector;
203| unsigned long numberOfFreeClusters;
204| unsigned long totalNumberOfClusters;
205|};
206|
207|void FileX_FreeSpc_init( FileX_FreeSpc* );
208|void FileX_FreeSpc_scan( FileX_FreeSpc*, const char* root_path );
209|int FileX_FreeSpc_getFreeSize( FileX_FreeSpc* );
210|int FileX_FreeSpc_getTotalSize( FileX_FreeSpc* );
211|int FileX_FreeSpc_getUseFileSize( FileX_FreeSpc*, const char* path );
212|int FileX_FreeSpc_culcNCluster( FileX_FreeSpc*, int size );
213|
214|#define FILEX_TO_LAST -1
215|#define FILEX_TO_FULL -2
216|
217|#ifdef FILEX_FREESIZE
218| extern FileX_FreeSpc FileX_freeSpcSym;
219|#endif
220|
221|#ifdef __cplusplus
222|}
223|#endif
224|
225|/*-------------------------------------------------------------------*/
226|/* 11. <<< Mapping Area -------------------------------------------- >>> */
227|/*-------------------------------------------------------------------*/
228|
229|
230|
231|/***********************************************************************
232| 12. <<< [FileX_UniRead_isUniFile] UNICODE ファイルかどうかを返す >>>
233|【補足】
234|・bool FileX_UniRead_isUniFile( FileX_UniRead* m );
235|************************************************************************/
236|#define FileX_UniRead_isUniFile( m ) \
237| ( (m)->m_tmp_path[0] != '\0' )
238|
239|
240|#endif /* __FILEX_H */
241|
242|