1 krisbash 1.1 #ifndef _pal_dir_h
2 #define _pal_dir_h
3
4 #include "palcommon.h"
5
6 #if defined(_MSC_VER)
7 # include <io.h>
8 # include <direct.h>
9 #else
10 # include <sys/types.h>
11 # include <sys/stat.h>
12 # include <unistd.h>
13 #endif
14
15 PAL_BEGIN_EXTERNC
16
17 typedef struct _DirEnt
18 {
19 char name[PAL_MAX_PATH_SIZE];
20 int isDir;
21 }
22 krisbash 1.1 DirEnt;
23
24 typedef struct _Dir Dir;
25
26 Dir* Dir_Open(const char* path);
27
28 DirEnt* Dir_Read(Dir* dir);
29
30 int Dir_Close(Dir* dir);
31
32 PAL_INLINE int Mkdir(const char* path, int mode)
33 {
34 #if defined(_MSC_VER)
35 PAL_UNUSED(mode);
36 return _mkdir(path);
37 #else
38 return mkdir(path, mode);
39 #endif
40 }
41
42 /* Create the given directory and any directories along the path */
43 krisbash 1.1 int Mkdirhier(const char* path, int mode);
44
45 PAL_INLINE int Chdir(const char* path)
46 {
47 #if defined(_MSC_VER)
48 return _chdir(path);
49 #else
50 return chdir(path);
51 #endif
52 }
53
54 PAL_INLINE int Rmdir(const char* path)
55 {
56 #if defined(_MSC_VER)
57 return _rmdir(path);
58 #else
59 return rmdir(path);
60 #endif
61 }
62
63 PAL_Boolean Isdir(const char* path);
64 krisbash 1.1
65 /* Find the 'basename' of a path (final component without leading directory) */
66 const char* Basename(const char* path);
67
68 PAL_END_EXTERNC
69
70 #endif /* _pal_dir_h */
|