1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | /****************************************************************************************
|
---|
10 | *
|
---|
11 | * File: dirent.h
|
---|
12 | * Purpose: Implements UNIX-like directory reading for the Macintosh.
|
---|
13 | * This file describes Filesystem-independent directory information.
|
---|
14 | * Modifications:
|
---|
15 | *
|
---|
16 | ****************************************************************************************/
|
---|
17 |
|
---|
18 | #ifndef __dirent_h
|
---|
19 | #define __dirent_h
|
---|
20 |
|
---|
21 | #include <Files.h>
|
---|
22 | #include <Errors.h>
|
---|
23 | #include <Types.h>
|
---|
24 |
|
---|
25 | struct dirent {
|
---|
26 | /* PRIVATE FIELDS. Use fields after PUBLIC */
|
---|
27 | struct dirent **next;
|
---|
28 | FSSpec fsp;
|
---|
29 |
|
---|
30 | /* PUBLIC. */
|
---|
31 | long d_off; /* index (to seekdir()) of this entry */
|
---|
32 | long d_fileno; /* File number (dirID) of this entry */
|
---|
33 | #define d_parent fsp.parID /* File number (dirID) of parent */
|
---|
34 | #define d_reclen sizeof(struct dirent) /* Size of this record */
|
---|
35 | #define d_namelen strlen(fsp.name) /* Length of the name */
|
---|
36 | #define d_name fsp.name /* Name */
|
---|
37 | #define d_volume fsp.vRefNum
|
---|
38 | };
|
---|
39 |
|
---|
40 | #define DIRSIZ(dp) sizeof(struct dirent)
|
---|
41 |
|
---|
42 | /* Maximum path length for opendir() */
|
---|
43 | #define MAXPATHLEN 255
|
---|
44 |
|
---|
45 | /*
|
---|
46 | * Definitions for library routines operating on directories.
|
---|
47 | */
|
---|
48 | typedef struct __dirdesc
|
---|
49 | {
|
---|
50 | /* PRIVATE FIELDS. Use the fields & defines below PUBLIC */
|
---|
51 | FSSpec dir_fsp;
|
---|
52 | long dd_off; /* Current offset (ioWDIndex) in dir (for telldir) */
|
---|
53 | int dd_cached; /* true if dd_cache_hint points to the next dir to be read */
|
---|
54 |
|
---|
55 | struct dirent **dd_cache_hint;
|
---|
56 | struct dirent **dd_buf; /* directory data buffer */
|
---|
57 |
|
---|
58 | /* PUBLIC */
|
---|
59 | long dd_fd; /* file descriptor (dirID) of this dir */
|
---|
60 |
|
---|
61 | #define dd_parent dir_fsp.parID /* dirID of parent */
|
---|
62 | #define dd_bsize 1 /* amount of entries read at a time */
|
---|
63 | #define dd_size sizeof(struct dirent) /* amount of valid data in buffer */
|
---|
64 | #define dd_loc 1
|
---|
65 | #define dd_name dir_fsp.name
|
---|
66 | #define dd_volume dir_fsp.vRefNum
|
---|
67 |
|
---|
68 | long dd_numents; /* Number of files/directories in this directory */
|
---|
69 | } DIR;
|
---|
70 |
|
---|
71 | /* See dirent.c for descriptions of these routines */
|
---|
72 | extern DIR *opendir(char *dirname);
|
---|
73 | extern struct dirent *readdir(DIR *dirp);
|
---|
74 | extern int closedir(DIR *dirp);
|
---|
75 | extern void seekdir(DIR *dirp, long loc);
|
---|
76 | extern long telldir(DIR *dirp);
|
---|
77 |
|
---|
78 | #ifndef lint
|
---|
79 | #define rewinddir(dirp) seekdir((dirp), (long)0)
|
---|
80 | #else
|
---|
81 | extern void rewinddir(DIR *dirp);
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | /* Convenient routines */
|
---|
85 | extern char *getwd(char *path);
|
---|
86 | extern int chdir(char *path);
|
---|
87 | extern char *pathdir(DIR *dirp, char *path);
|
---|
88 |
|
---|
89 | /* Any errors in above routines (and hopendir()) are put here */
|
---|
90 | extern OSErr dd_errno;
|
---|
91 | extern char *dd_separator; /* If you're feeling brave, change this to "/" */
|
---|
92 | extern int dd_xform_seps;
|
---|
93 |
|
---|
94 | /* In case you like errno instead */
|
---|
95 | #ifdef UNCOMMENT_ME_IF_YOUVE_GOT_TO_HAVE_ERRNO
|
---|
96 | #define errno dd_errno
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | /* This routine is Mac-specific, but very convenient in certain situations */
|
---|
100 | OSErr hgetwd(short vRefNum, long startDirID, char *path, int max_path_len, char *sep);
|
---|
101 |
|
---|
102 | /* You probably don't want to call this. */
|
---|
103 | extern DIR *hopendir(char *dirname, short vRefNum, long dirID);
|
---|
104 |
|
---|
105 | #endif /* !__dirent_h */
|
---|