Nestfind.h
[目次 | 型・クラス・構造体 | マクロ]
1|/**************************************************************************
2|* 1. <<< サブ・フォルダファイル列挙 (NestFind) >>>
3|***************************************************************************/
4|
5|#ifndef __NESTFIND_H
6|#define __NESTFIND_H
7|
8|
9|#ifndef USES_PRIORITY_HEADER
10|/*[START_OF_PRIORITY_HEADER]*/
11|
12|#ifndef USES_NESTFIND
13|#define USES_NESTFIND
14|typedef struct _NestFind NestFind;
15|
16|#define NestFind_UseAttr /* ファイルサイズを参照する */
17|
18|#define NestFind_bufM 3000 /* ファイル名のバッファ数 BufN は、*/
19| /* ネストしているすべてのディレクトリに含まれるファイルの数の最大制限 */
20| /* NestFind_init の中の静的変数に使っています */
21|
22|#define NestFind_nestM 50 /* ネストの深さの最大 */
23|
24|#endif
25|
26|/*[END_OF_PRIORITY_HEADER]*/
27|#endif /* USES_PRIORITY_HEADER */
28|
29|
30|#ifdef __cplusplus
31|extern "C" {
32|#endif
33|
34|/**************************************************************************
35|* 2. <<< 定数 >>>
36|***************************************************************************/
37|
38|#define NestFind_Err_OverNest 9991
39|#define NestFind_Err_OverBuf 9992
40|
41|
42|/* ファイル名の最大の長さ NameSize は、MS-DOS なら 8.3 の 12 文字なので 12 */
43|#ifdef __UNIX__
44|#define NestFind_nameSize 40
45|#endif
46|#ifdef __BORLAND__
47|#define NestFind_nameSize 12
48|#endif
49|#ifdef _MSC_VER
50|#define NestFind_nameSize 255
51|#endif
52|
53|#define NestFind_absPathSize 255 /* 絶対ファイルパス名の最大の長さ */
54|
55|
56|
57|/**************************************************************************
58| 3. <<< サブ・フォルダを含めてファイルを列挙する [NestFind] >>>
59|【例】
60| NestFind f;
61| NestFind_init( &f, "path", false );
62| while ( NestFind_next( &f ) ) {
63| char* s = NestFind_getAbsPath( &f );
64| }
65| NestFind_finish( &f );
66|***************************************************************************/
67|struct _NestFind {
68| char** fname; /* ファイル名かdir名 */
69| bool* isdir;
70| #ifdef NestFind_UseAttr
71| long* size;
72| #endif
73|
74| bool bFinishedDir; /* 探索が済んだディレクトリも列挙する */
75|
76| int I [NestFind_nestM+1]; /* 現在の fname の第1配列番号 */
77| int maxI [NestFind_nestM+1]; /* そのディレクトリの最大の I */
78| int nest; /* ネスト・レベル、0 が基底 */
79|
80| char absPath[NestFind_absPathSize+1]; /* 基底ディレクトリ・パス */
81| char workPath [NestFind_absPathSize]; /* 属性参照用 */
82|};
83|
84|#ifndef K_AND_R
85|
86|void NestFind_init( NestFind*, const char*, bool bFinishedDir );
87|void NestFind_finish( NestFind* );
88|bool NestFind_next( NestFind* );
89|
90|char* NestFind_getFName( NestFind* );
91|char* NestFind_getPath( NestFind* );
92|char* NestFind_getAbsPath( NestFind* );
93|int NestFind_getNumer( NestFind* );
94|int NestFind_getDenomi( NestFind* );
95|bool NestFind_getIsDir( NestFind* );
96|#ifdef NestFind_UseAttr
97|long NestFind_getSize( NestFind* );
98|#endif
99|
100|#else
101|
102|char* NestFind_getFName( /*NestFind**/ );
103|char* NestFind_getPath( /*NestFind**/ );
104|char* NestFind_getAbsPath( /*NestFind**/ );
105|bool NestFind_getIsDir( /*NestFind* this*/ );
106|void NestFind_init( /*NestFind*, char**/ );
107|bool NestFind_next( /*NestFind**/ );
108|
109|#endif
110|
111|
112|#ifdef __cplusplus
113|}
114|#endif
115|
116|#endif
117|
118|