FILEFIND.H
[目次 | 型・クラス・構造体 | マクロ]
1|/**************************************************************************
2|* 1. <<< ファイル列挙 (FileFind) >>>
3|***************************************************************************/
4|
5|#ifndef __FILEFIND_H
6|#define __FILEFIND_H
7|
8|/*----------------------------------------------------------------------
9|[Module Property]
10|name = FileFind
11|title = ファイルを列挙する
12|category = ファイル
13|src = filefind.c
14|depend = Types
15|priority =
16|accord =
17|----------------------------------------------------------------------*/
18|
19|#ifndef USES_PRIORITY_HEADER
20|/*[START_OF_PRIORITY_HEADER]*/
21|
22|#define USES_FILEFIND
23|typedef struct _FileFind FileFind;
24|
25|/*[END_OF_PRIORITY_HEADER]*/
26|#endif /* USES_PRIORITY_HEADER */
27|
28|
29|#ifdef _UNIX
30| #include <stdio.h>
31|#endif
32|#if defined(_MSC_VER) && !defined(FOR_WINCE)
33| #include <io.h>
34|#endif
35|
36|
37|/*-------------------------------------------------------------------------*/
38|/* 2. <<< Interface Area ------------------------------------------------ >>> */
39|/*-------------------------------------------------------------------------*/
40|
41|#ifdef __cplusplus
42|extern "C" {
43|#endif
44|
45|
46|/**************************************************************************
47|* 3. <<< ファイル列挙 [FileFind] >>>
48|***************************************************************************/
49|struct _FileFind {
50| #ifdef _UNIX
51| char FileName[256];
52| bool IsDir;
53| FILE* file;
54| #endif
55| #ifdef _MSC_VER
56| int handle; /* find 系関数のハンドル */
57| struct _finddata_t data; /* find 系関数が格納するデータ */
58| bool bFirst; /* findfirst した直後かどうか */
59| bool bCutParent; /* . と .. を取得しない */
60| #endif
61|};
62|
63|#ifndef _K_AND_R
64| void FileFind_init( FileFind*, const char* path );
65| void FileFind_init2( FileFind*, const char* path );
66| int FileFind_next( FileFind* );
67| char* FileFind_getFName( FileFind* );
68| bool FileFind_isDir( FileFind* );
69| time_t FileFind_getWriteTime( FileFind* );
70| void FileFind_finish( FileFind* );
71|#else
72| void FileFind_init( /*FileFind*, path*/ );
73| int FileFind_next( /*iter*/ );
74| void FileFind_finish( /*iter*/ );
75|#endif
76|
77|int FileFind_getN( const char* path, bool bPlusFolder, bool bPlusFile );
78|
79|
80|
81|#ifdef __cplusplus
82|}
83|#endif
84|
85|
86|/*-------------------------------------------------------------------------*/
87|/* 4. <<< Mapping Area -------------------------------------------------- >>> */
88|/*-------------------------------------------------------------------------*/
89|
90|
91|/**************************************************************************
92|* 5. <<< ファイル名を参照する [FileFind_getFName()] >>>
93|*【引数】
94|* ・char* 返り値; ファイル名、またはフォルダ名
95|*【補足】
96|*・参照したファイル名を変更しないでください。
97|***************************************************************************/
98|#ifdef _UNIX
99| #define FileFind_getFName( this ) ((this)->FileName)
100|#endif
101|#ifdef _MSC_VER
102| #define FileFind_getFName( this ) ((this)->data.name)
103|#endif
104|
105|
106|
107|/**************************************************************************
108|* 6. <<< カレントがディレクトリかどうか判定する [FileFind_isDir()] >>>
109|***************************************************************************/
110|#ifdef _UNIX
111| #define FileFind_isDir( this ) ((this)->IsDir)
112|#endif
113|#ifdef _MSC_VER
114| #define FileFind_isDir( this ) ((this)->data.attrib & _A_SUBDIR )
115|#endif
116|
117|
118|
119|/**************************************************************************
120|* 7. <<< カレント・ファイルの更新日時を返す [FileFind_getUpdate()] >>>
121|***************************************************************************/
122|#define FileFind_getUpdate( this ) \
123| ( (this)->data.time_write )
124|
125|
126|
127|#endif /* __FILEFIND_H */
128|
129|