dir.h
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* dir.h: as one might suggest here are definitions and prototypes for
* posix/dir.c
*
* Copyright (C) 2006 Georg Steffers
*
* Author: Georg Steffers [GST] <georg.steffers@aschendorff.de>
* Developer:
*
* Changes (for this file only):
* (2006-06-12) [GST] Started this changelog...well the program is
* ready since some weeks right now.
*/
#ifndef DIR_H
#define DIR_H
#include <sys/stat.h>
#include <dirent.h>
#include <scot/dir_common.h>
#include <scot/event_listener.h>
struct scot_dir
{
struct scot_event_listener el;
DIR * handle;
const char * path;
int notify_handle;
};
/* abstraction for file information and an directory handle */
#define FILE_DATA struct dirent_stat
#define DIR_HANDLE DIR *
/* #define DIR_HANDLE struct scot_dir * */
/* abstraction for checking if a file is a directory */
#define IS_DIRECTORY(file_data) (S_ISDIR ((file_data).stat.st_mode))
/* abstraction for getting the filename of a directory entry. */
#define DIRENT_FNAME(file_data) ((file_data).file->d_name)
/* !!!FIXME!!! is there any place where this is already defined in posix? */
#ifndef MAX_PATH
# define MAX_PATH 2000
#endif /* MAX_PATH */
/* structure for all available information about the directory entry. */
struct dirent_stat
{
char path [MAX_PATH+1];
struct dirent * file;
struct stat stat;
};
/* the last parameter is posix specific. It defines if stat should
* follow symlinks or not. Under Windows it is ignored. */
DIR_HANDLE get_dir_first (const char *, FILE_DATA *, int);
int get_dir_next (DIR_HANDLE, const char *, FILE_DATA *, int);
/*
DIR_HANDLE scot_dir_new (const char *);
void scot_dir_free (DIR_HANDLE);
int get_dir_first (DIR_HANDLE, FILE_DATA *, int);
int get_dir_next (DIR_HANDLE, FILE_DATA *, int);
*/
#endif /* DIR_H */