summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2018-01-12 13:33:47 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-01-12 13:34:32 -0800
commit83b91fff02c84fc522fb6f126d4917de4e85ea14 (patch)
treeb4eb9f1853e478b013fe2a4144fbf8a9249f86bc
parentabc88c498e47380aec01369b3ce3526ae32c6cdf (diff)
Evil: remove useless dirent code
Test Plan: compilation of the EFL Reviewers: cedric Subscribers: jpeg Differential Revision: https://phab.enlightenment.org/D5735 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/Makefile_Evil.am2
-rw-r--r--src/lib/evil/dirent.h146
-rw-r--r--src/lib/evil/evil_dirent.c180
3 files changed, 0 insertions, 328 deletions
diff --git a/src/Makefile_Evil.am b/src/Makefile_Evil.am
index 6ec4b51..b5c7f02 100644
--- a/src/Makefile_Evil.am
+++ b/src/Makefile_Evil.am
@@ -21,7 +21,6 @@ lib/evil/evil_string.h \
21lib/evil/evil_time.h \ 21lib/evil/evil_time.h \
22lib/evil/evil_unistd.h \ 22lib/evil/evil_unistd.h \
23lib/evil/evil_util.h \ 23lib/evil/evil_util.h \
24lib/evil/dirent.h \
25lib/evil/fnmatch.h \ 24lib/evil/fnmatch.h \
26lib/evil/pwd.h 25lib/evil/pwd.h
27 26
@@ -30,7 +29,6 @@ dist_evilmmanheaders_DATA = \
30lib/evil/sys/mman.h 29lib/evil/sys/mman.h
31 30
32lib_evil_libevil_la_SOURCES = \ 31lib_evil_libevil_la_SOURCES = \
33lib/evil/evil_dirent.c \
34lib/evil/evil_dlfcn.c \ 32lib/evil/evil_dlfcn.c \
35lib/evil/evil_fcntl.c \ 33lib/evil/evil_fcntl.c \
36lib/evil/evil_fnmatch.c \ 34lib/evil/evil_fnmatch.c \
diff --git a/src/lib/evil/dirent.h b/src/lib/evil/dirent.h
deleted file mode 100644
index 9c58019..0000000
--- a/src/lib/evil/dirent.h
+++ /dev/null
@@ -1,146 +0,0 @@
1#ifndef __EVIL_DIRENT_H__
2#define __EVIL_DIRENT_H__
3
4#ifdef EAPI
5# undef EAPI
6#endif /* EAPI */
7
8#ifdef _WIN32
9# ifdef EFL_EVIL_BUILD
10# ifdef DLL_EXPORT
11# define EAPI __declspec(dllexport)
12# else
13# define EAPI
14# endif /* ! DLL_EXPORT */
15# else
16# define EAPI __declspec(dllimport)
17# endif /* ! EFL_EVIL_BUILD */
18#endif /* _WIN32 */
19
20
21/**
22 * @file dirent.h
23 * @brief The file that provides functions ported from Unix in dirent.h.
24 * @defgroup Evil_Dirent_Group Dirent.h functions
25 * @ingroup Evil
26 *
27 * This header provides functions ported from Unix in dirent.h.
28 *
29 * @{
30 */
31
32
33#ifdef UNICODE
34# include <wchar.h>
35#endif
36
37/**
38 * @def DT_UNKNOWN
39 * Specifies that the file type is unknown.
40 */
41#define DT_UNKNOWN 0
42
43/**
44 * @def DT_DIR
45 * Specifies that the file type is a directory.
46 */
47#define DT_DIR 4
48
49/**
50 * @typedef DIR
51 * @brief A structure that describes a directory stream.
52 */
53typedef struct DIR DIR;
54
55/**
56 * @struct dirent
57 * @brief A structure that describes a directory stream.
58 */
59struct dirent
60{
61 char d_name[260 + 1]; /**< The filename. */
62 int d_mode; /**< The mode */
63 unsigned char d_type; /**< The type */
64};
65
66
67#ifdef __cplusplus
68extern "C" {
69#endif /* __cplusplus */
70
71
72/**
73 * @brief Open the given directory.
74 *
75 * @param name The directory to open.
76 * @return A pointer to the directory stream.
77 *
78 * This function opens the directory @p name and return the directory
79 * stream. On error or if @p dir is NULL, -1 is returned, and errno is
80 * set appropriately (on Windows XP only). On success, 0 is returned.
81 *
82 * @see closedir()
83 * @see readdir()
84 *
85 * Conformity: None.
86 *
87 * Supported OS: Windows XP, CE.
88 */
89EAPI DIR *opendir(char const *name);
90
91/**
92 * @brief Close the given directory.
93 *
94 * @param dir The directory stream to close.
95 * @return A pointer to the directory stream.
96 *
97 * This function closes the stream directory @p dir. On error or is
98 * @p path is NULL or an empty string, NULL is returned, and errno is set
99 * appropriately (on Windows XP only).
100 *
101 * @see opendir()
102 * @see readdir()
103 *
104 * Conformity: None.
105 *
106 * Supported OS: Windows XP, CE.
107 */
108EAPI int closedir(DIR *dir);
109
110/**
111 * @brief Read the given directory.
112 *
113 * @param dir The directory stream to read.
114 * @return A pointer to a dirent structure, @c NULL oterhwise.
115 *
116 * This function returns a pointer to a dirent structure representing
117 * the next directory entry in the directory stream pointed to by
118 * @p dir. It returns NULL on reaching the end of the directory stream
119 * or if an error occurred and errno is set appropriately (on Windows XP only).
120 *
121 * @see opendir()
122 * @see readdir()
123 *
124 * Conformity: None.
125 *
126 * Supported OS: Windows XP, CE.
127 */
128EAPI struct dirent *readdir(DIR *dir);
129
130
131#ifdef __cplusplus
132}
133#endif /* __cplusplus */
134
135
136#undef EAPI
137#define EAPI
138
139
140
141/**
142 * @}
143 */
144
145
146#endif /* __EVIL_DIRENT_H__ */
diff --git a/src/lib/evil/evil_dirent.c b/src/lib/evil/evil_dirent.c
deleted file mode 100644
index 6f6b86a..0000000
--- a/src/lib/evil/evil_dirent.c
+++ /dev/null
@@ -1,180 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif /* HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <dirent.h>
7#include <errno.h>
8#include <sys/types.h>
9
10#ifndef WIN32_LEAN_AND_MEAN
11# define WIN32_LEAN_AND_MEAN
12#endif
13#include <windows.h>
14#undef WIN32_LEAN_AND_MEAN
15
16#include "evil_macro.h"
17#include "evil_stdio.h"
18
19
20struct DIR
21{
22 struct dirent dirent;
23 WIN32_FIND_DATA data;
24 HANDLE handle;
25};
26
27
28DIR *opendir(char const *name)
29{
30 DIR *dir;
31 char *tmp;
32 DWORD attr;
33 size_t l;
34#ifdef UNICODE
35 wchar_t *wname;
36 char *d_name;
37#endif
38
39 /* valid name */
40 if (!name || !*name)
41 {
42 errno = ENOENT;
43 return NULL;
44 }
45
46#ifdef UNICODE
47 wname = evil_char_to_wchar(name);
48 if (!wname)
49 {
50 errno = ENOMEM;
51 return NULL;
52 }
53
54 if((attr = GetFileAttributes(wname)) == 0xFFFFFFFF)
55#else
56 if((attr = GetFileAttributes(name)) == 0xFFFFFFFF)
57#endif
58 {
59 errno = ENOENT;
60 return NULL;
61 }
62
63#ifdef UNICODE
64 free(wname);
65#endif
66
67 /* directory */
68 if (!(attr & FILE_ATTRIBUTE_DIRECTORY))
69 {
70 errno = ENOTDIR;
71 return NULL;
72 }
73
74 dir = (DIR *)malloc(sizeof(DIR));
75 if (!dir)
76 {
77 errno = ENOMEM;
78 return NULL;
79 }
80
81 l = strlen(name);
82 tmp = (char *)malloc(sizeof(char) * l + 5);
83 if (!tmp)
84 {
85 errno = ENOMEM;
86 free(dir);
87 return NULL;
88 }
89
90 memcpy(tmp, name, l);
91 memcpy(tmp + l, "\\*.*", 5);
92
93 EVIL_PATH_SEP_UNIX_TO_WIN32(tmp);
94
95#ifdef UNICODE
96 wname = evil_char_to_wchar(tmp);
97 if (!wname)
98 {
99 errno = ENOMEM;
100 free(tmp);
101 free(dir);
102 return NULL;
103 }
104 dir->handle = FindFirstFile(wname, &dir->data);
105 free(wname);
106#else
107 dir->handle = FindFirstFile(tmp, &dir->data);
108#endif
109
110 free(tmp);
111
112 if (dir->handle == INVALID_HANDLE_VALUE)
113 {
114 free(dir);
115 return NULL;
116 }
117
118#ifdef UNICODE
119 d_name = evil_wchar_to_char(dir->data.cFileName);
120 strcpy(dir->dirent.d_name, d_name);
121 free(d_name);
122#else
123 strcpy(dir->dirent.d_name, dir->data.cFileName);
124#endif
125 dir->dirent.d_mode = (int)dir->data.dwFileAttributes;
126
127 if (dir->data.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
128 dir->dirent.d_type = DT_DIR;
129 else
130 dir->dirent.d_type = DT_UNKNOWN;
131
132 return dir;
133}
134
135int closedir(DIR *dir)
136{
137 if (!dir)
138 {
139 errno = EBADF;
140 return -1;
141 }
142
143 if (dir->handle != INVALID_HANDLE_VALUE)
144 FindClose(dir->handle);
145 free(dir);
146
147 return 0;
148}
149
150struct dirent *readdir(DIR *dir)
151{
152#ifdef UNICODE
153 char *d_name;
154#endif
155
156 if (!dir)
157 {
158 errno = EBADF;
159 return NULL;
160 }
161
162 if (dir->handle == INVALID_HANDLE_VALUE)
163 return NULL;
164
165#ifdef UNICODE
166 d_name = evil_wchar_to_char(dir->data.cFileName);
167 strcpy(dir->dirent.d_name, d_name);
168 free(d_name);
169#else
170 strcpy(dir->dirent.d_name, dir->data.cFileName);
171#endif
172
173 if (!FindNextFile(dir->handle, &dir->data))
174 {
175 FindClose(dir->handle);
176 dir->handle = INVALID_HANDLE_VALUE;
177 }
178
179 return &dir->dirent;
180}