aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/file/evas_path.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/evas/src/lib/file/evas_path.c')
-rw-r--r--libraries/evas/src/lib/file/evas_path.c152
1 files changed, 0 insertions, 152 deletions
diff --git a/libraries/evas/src/lib/file/evas_path.c b/libraries/evas/src/lib/file/evas_path.c
deleted file mode 100644
index 2ff646d..0000000
--- a/libraries/evas/src/lib/file/evas_path.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/* os dependent file code. for unix-y like fs's only for now */
2/* if your os doesn't use unix-like fs starting with "/" for the root and */
3/* the file path separator isn't "/" then you may need to help out by */
4/* adding in a new set of functions here */
5
6#ifdef HAVE_CONFIG_H
7# include <config.h>
8#endif
9
10#include <limits.h>
11#include <stdlib.h>
12#include <sys/types.h>
13#include <sys/stat.h>
14/* get the casefold feature! */
15#include <fnmatch.h>
16#ifndef _MSC_VER
17# include <unistd.h>
18# include <sys/param.h>
19#endif
20
21#ifdef HAVE_EVIL
22# include <Evil.h>
23#endif
24
25#include "evas_common.h"
26#include "evas_private.h"
27
28#ifdef _WIN32
29# define EVAS_PATH_SEPARATOR "\\"
30#else
31# define EVAS_PATH_SEPARATOR "/"
32#endif
33
34int
35evas_file_path_is_full_path(const char *path)
36{
37 if (!path) return 0;
38#if defined _WIN32_WCE
39 if (path[0] == '\\') return 1;
40#elif defined _WIN32
41 if (evil_path_is_absolute(path)) return 1;
42#else
43 if (path[0] == '/') return 1;
44#endif
45 return 0;
46}
47
48char *
49evas_file_path_join(const char *path, const char *end)
50{
51 char *res = NULL;
52 size_t len;
53
54 if ((!path) && (!end)) return NULL;
55 if (!path) return strdup(end);
56 if (!end) return strdup(path);
57 len = strlen(path);
58 len += strlen(end);
59 len += strlen(EVAS_PATH_SEPARATOR);
60 res = malloc(len + 1);
61 if (!res) return NULL;
62 strcpy(res, path);
63 strcat(res, EVAS_PATH_SEPARATOR);
64 strcat(res, end);
65 return res;
66}
67
68int
69evas_file_path_exists(const char *path)
70{
71 struct stat st;
72
73 if (!stat(path, &st)) return 1;
74 return 0;
75}
76
77int
78evas_file_path_is_file(const char *path)
79{
80 struct stat st;
81
82 if (stat(path, &st) == -1) return 0;
83 if (S_ISREG(st.st_mode)) return 1;
84 return 0;
85}
86
87int
88evas_file_path_is_dir(const char *path)
89{
90 struct stat st;
91
92 if (stat(path, &st) == -1) return 0;
93 if (S_ISDIR(st.st_mode)) return 1;
94 return 0;
95}
96
97Eina_List *
98evas_file_path_list(char *path, const char *match, int match_case)
99{
100 Eina_File_Direct_Info *info;
101 Eina_Iterator *it;
102 Eina_List *files = NULL;
103 int flags;
104
105 flags = FNM_PATHNAME;
106#ifdef FNM_CASEFOLD
107 if (!match_case)
108 flags |= FNM_CASEFOLD;
109#else
110/*#warning "Your libc does not provide case-insensitive matching!"*/
111#endif
112
113 it = eina_file_direct_ls(path);
114 EINA_ITERATOR_FOREACH(it, info)
115 {
116 if (match)
117 {
118 if (fnmatch(match, info->path + info->name_start, flags) == 0)
119 files = eina_list_append(files, strdup(info->path + info->name_start));
120 }
121 else
122 files = eina_list_append(files, strdup(info->path + info->name_start));
123 }
124 if (it) eina_iterator_free(it);
125 return files;
126}
127
128DATA64
129evas_file_modified_time(const char *file)
130{
131 struct stat st;
132
133 if (stat(file, &st) < 0) return 0;
134 if (st.st_ctime > st.st_mtime) return (DATA64)st.st_ctime;
135 else return (DATA64)st.st_mtime;
136 return 0;
137}
138
139char *
140evas_file_path_resolve(const char *file)
141{
142#if 0
143 char buf[PATH_MAX], *buf2;
144#endif
145
146 return strdup(file);
147#if 0
148 if (!realpath(file, buf)) return NULL;
149 buf2 = strdup(buf);
150 return buf2;
151#endif
152}