File: zdir.h

package info (click to toggle)
libzia 4.36-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,320 kB
  • sloc: ansic: 24,172; sh: 4,408; makefile: 211
file content (86 lines) | stat: -rw-r--r-- 1,969 bytes parent folder | download | duplicates (3)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
    zdir.h
    Copyright (C) 2011 Ladislav Vaiz <ok1zia@nagano.cz>

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    version 2 as published by the Free Software Foundation.

*/

#ifndef __ZDIR_H
#define __ZDIR_H

#include <libziaint.h>

#ifdef Z_HAVE_IO_H
#include <io.h>
#endif

#include <sys/types.h>
/*#ifdef Z_HAVE_WINDOWS_H
#include <windows.h>
#endif*/

#ifdef Z_HAVE_DIRECT_H
#include <direct.h>
#endif

#ifdef Z_HAVE_UNISTD_H
#include <unistd.h>
#endif

#define Z_MAX_PATH 260

#ifdef Z_HAVE_DIRENT_H

#include <dirent.h>

#else

#define __S_IFMT        0170000 
#define __S_IFDIR       0040000
#define __S_IFREG       0100000

#define __S_ISTYPE(mode, mask)  (((mode) & __S_IFMT) == (mask))
#define S_ISDIR(mode)    __S_ISTYPE((mode), __S_IFDIR)
#define S_ISREG(mode)    __S_ISTYPE((mode), __S_IFREG)


typedef struct dirent{
	char d_name[Z_MAX_PATH];
};

typedef struct DIR{
	long                handle; /* -1 for failed rewind */
    struct _finddata_t  info;
    struct dirent       result; /* d_name null iff first time */
    char                *name;  /* null-terminated char string */
}DIR;


DIR *opendir(char *name);
struct dirent *readdir(DIR *dir);
int closedir(DIR *dir);

#endif

#ifdef Z_MSC
#define zchdir(dir) _chdir(dir)
#else
#define zchdir(dir) chdir(dir)
#endif

int z_scandir (char *dir, struct dirent ***namelist, int (*select) (const char *, const struct dirent *), int (*cmp) (const void *, const void *));
void z_free_namelist(struct dirent ***namelist, int *namelistlen);
int z_select_dir_func(const char *, const struct dirent *de);
int z_select_file_func(const char *, const struct dirent *de);
int z_compare_name_func(const void *d1, const void *d2);
int z_scandir_alphasort(const void *a, const void *b);

int z_mkdir(const char *s, int mode);
int z_mkdir_p(const char *s, int mode);
int z_fmkdir_p(const char *filename, int mode);


#endif