OSDN Git Service

Merge UnkoTim214
[timidity41/timidity41.git] / utils / readdir.h
1 /*
2     TiMidity++ -- MIDI to WAVE converter and player
3     Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4     Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20     readdir.h
21
22     Structures and types used to implement opendir/readdir/closedir
23     on Windows 95/NT.
24 */
25
26 #ifndef ___READDIR_H_
27 #define ___READDIR_H_
28
29 #include <io.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <sys/types.h>
33
34 /* Borland C++ */
35 #ifdef __BORLANDC__
36 #include <dir.h>
37 #endif /* __BORLANDC__ */
38
39 /* PellesC */
40 #ifdef __POCC__
41 #define _MAX_FNAME 256
42 #endif /* __POCC___ */
43
44 #ifndef _MAX_FNAME
45 #define _MAX_FNAME 256
46 #endif /* _MAX_FNAME */
47
48 #ifdef __CYGWIN__
49 struct _finddata_t {
50     unsigned attrib;
51     time_t time_create;
52     time_t time_access;
53     time_t time_write;
54     size_t size;
55     char name[_MAX_FNAME];
56 };
57 #endif /* __CYGWIN__ */
58
59 #if 0
60 #define API_EXPORT(type)    __declspec(dllexport) type __stdcall
61 #else
62 #define API_EXPORT(type)    type
63 #endif
64
65 /* struct dirent - same as Unix */
66 struct dirent {
67     long d_ino;                 /* inode (always 1 in WIN32) */
68     off_t d_off;                /* offset to this dirent */
69     unsigned short d_reclen;    /* length of d_name */
70     char d_name[_MAX_FNAME+1];  /* filename (null terminated) */
71 };
72
73 /* typedef DIR - not the same as Unix */
74 typedef struct {
75     ptr_size_t handle;          /* _findfirst/_findnext handle */
76     short offset;               /* offset into directory */
77     short finished;             /* 1 if there are not more files */
78 #ifdef __BORLANDC__
79     struct ffblk       fileinfo;/* from _findfirst/_findnext */
80 #else
81     struct _finddata_t fileinfo;/* from _findfirst/_findnext */
82 #endif /* __BORLANDC__ */
83
84     char *dir;                  /* the dir we are reading */
85     struct dirent dent;         /* the dirent to return */
86 } DIR;
87
88 /* Function prototypes */
89 extern API_EXPORT(DIR *) opendir(const char *);
90 extern API_EXPORT(struct dirent *) readdir(DIR *);
91 extern API_EXPORT(int) closedir(DIR *);
92
93 #ifdef __BORLANDC__
94 #define _findfirst(x,y) findfirst((x),(y),0)
95 #define _findnext(x,y) findnext((y))
96 #endif /* __BORLANDC__ */
97
98 #endif /* ___READDIR_H_ */