gwenhywfar  4.99.8beta
directory_all.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Sun Nov 23 2003
3  copyright : (C) 2003 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2.1 of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * Lesser General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU Lesser General Public *
19  * License along with this library; if not, write to the Free Software *
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21  * MA 02111-1307 USA *
22  * *
23  ***************************************************************************/
24 
25 
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29 
30 
31 #include <gwenhywfar/directory.h>
32 #include <gwenhywfar/debug.h>
33 #include <gwenhywfar/path.h>
34 #include <gwenhywfar/buffer.h>
35 #include <gwenhywfar/text.h>
36 
37 #ifdef HAVE_UNISTD_H
38 # include <unistd.h>
39 #endif
40 #ifdef HAVE_SYS_STAT_H
41 # include <sys/stat.h>
42 #endif
43 #include <sys/types.h>
44 #ifdef HAVE_FCNTL_H
45 # include <fcntl.h>
46 #endif
47 #include <string.h>
48 #include <errno.h>
49 #include <assert.h>
50 #include <stdlib.h>
51 #include <ctype.h>
52 
53 #ifdef OS_WIN32
54 # define DIRSEP "\\"
55 #else
56 # define DIRSEP "/"
57 #endif
58 
59 #define DISABLE_DEBUGLOG
60 
61 
62 
63 void *GWEN_Directory_HandlePathElement(const char *entry,
64  void *data,
65  unsigned int flags) {
66  char *p;
67  struct stat st;
68  int exists;
69  int withDrive;
70  GWEN_BUFFER *buf;
71  GWEN_BUFFER *ebuf = 0;
72 
73  withDrive=0;
74 
75 #ifdef OS_WIN32
76  if (entry && isalpha(*entry)) {
77  int len;
78 
79  /* append backslash if entry only consists of a drive specification */
80  len=strlen(entry);
81  if ( (len==2) && (entry[1] == ':') ) {
82  ebuf=GWEN_Buffer_new(0, len+2, 0, 1);
83  GWEN_Buffer_AppendString(ebuf, entry);
84  GWEN_Buffer_AppendByte(ebuf, '\\');
85  withDrive=1;
86  entry=GWEN_Buffer_GetStart(ebuf);
87  }
88  }
89 #endif /* OS_WIN32 */
90 
91  if (strcasecmp(entry, "..")==0) {
92  DBG_ERROR(GWEN_LOGDOMAIN, "\"..\" detected");
93  GWEN_Buffer_free(ebuf);
94  return 0;
95  }
96 
97  buf=(GWEN_BUFFER*)data;
98  if (GWEN_Buffer_GetUsedBytes(buf) && !withDrive) {
99  char c;
100 
102 #ifdef OS_WIN32
103  if (c!='\\')
104  GWEN_Buffer_AppendByte(buf, '\\');
105 #else
106  if (c!='/')
107  GWEN_Buffer_AppendByte(buf, '/');
108 #endif /* OS_WIN32 */
109  }
110  GWEN_Buffer_AppendString(buf, entry);
111 
112  /* check for existence of the file/folder */
113  p=GWEN_Buffer_GetStart(buf);
114  DBG_VERBOUS(GWEN_LOGDOMAIN, "Checking path \"%s\"", p);
115  if (stat(p, &st)) {
116  exists=0;
117  DBG_DEBUG(GWEN_LOGDOMAIN, "stat: %s (%s)", strerror(errno), p);
118  if ((flags & GWEN_PATH_FLAGS_PATHMUSTEXIST) ||
119  ((flags & GWEN_PATH_FLAGS_LAST) &&
120  (flags & GWEN_PATH_FLAGS_NAMEMUSTEXIST))) {
121  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" does not exist (it should)", p);
122  GWEN_Buffer_free(ebuf);
123  return 0;
124  }
125  }
126  else {
127  DBG_VERBOUS(GWEN_LOGDOMAIN, "Checking for type");
128  exists=1;
129  if (flags & GWEN_PATH_FLAGS_VARIABLE) {
130  if (!S_ISREG(st.st_mode)) {
131  DBG_INFO(GWEN_LOGDOMAIN, "%s not a regular file", p);
132  GWEN_Buffer_free(ebuf);
133  return 0;
134  }
135  }
136  else {
137  if (!S_ISDIR(st.st_mode)) {
138  DBG_INFO(GWEN_LOGDOMAIN, "%s not a direcory", p);
139  GWEN_Buffer_free(ebuf);
140  return 0;
141  }
142  }
143  if ((flags & GWEN_PATH_FLAGS_PATHMUSTNOTEXIST) ||
144  ((flags & GWEN_PATH_FLAGS_LAST) &&
146  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" exists (it should not)", p);
147  GWEN_Buffer_free(ebuf);
148  return 0;
149  }
150  } /* if stat is ok */
151 
152  if (!exists) {
153  int isPublic;
154 
155  DBG_DEBUG(GWEN_LOGDOMAIN, "Entry \"%s\" does not exist", p);
156 
157  isPublic=(
158  ((flags & GWEN_PATH_FLAGS_LAST) &&
159  (flags & GWEN_DIR_FLAGS_PUBLIC_NAME)) ||
160  (!(flags & GWEN_PATH_FLAGS_LAST) &&
161  (flags & GWEN_DIR_FLAGS_PUBLIC_PATH))
162  );
163 
164  if (flags & GWEN_PATH_FLAGS_VARIABLE) {
165  /* create file */
166  int fd;
167 
168  DBG_DEBUG(GWEN_LOGDOMAIN, "Creating file \"%s\"", p);
169  if (isPublic)
170  fd=open(p, O_RDWR | O_CREAT | O_TRUNC,
171  S_IRUSR | S_IWUSR
172 #ifdef S_IRGRP
173  | S_IRGRP
174 #endif
175 #ifdef S_IROTH
176  | S_IROTH
177 #endif
178  );
179  else
180  fd=open(p, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
181  if (fd==-1) {
182  DBG_ERROR(GWEN_LOGDOMAIN, "open: %s (%s)", strerror(errno), p);
183  GWEN_Buffer_free(ebuf);
184  return 0;
185  }
186  close(fd);
187  DBG_VERBOUS(GWEN_LOGDOMAIN, "Successfully created");
188  }
189  else {
190  /* create dir */
191  DBG_VERBOUS(GWEN_LOGDOMAIN, "Creating folder \"%s\"", p);
192 
193  if (isPublic) {
195  DBG_ERROR(GWEN_LOGDOMAIN, "Could not create directory \"%s\"", p);
196  GWEN_Buffer_free(ebuf);
197  return 0;
198  }
199  }
200  else {
201  if (GWEN_Directory_Create(p)) {
202  DBG_ERROR(GWEN_LOGDOMAIN, "Could not create directory \"%s\"", p);
203  GWEN_Buffer_free(ebuf);
204  return 0;
205  }
206  }
207  }
208  } /* if exists */
209  else {
210  DBG_VERBOUS(GWEN_LOGDOMAIN, "Entry \"%s\" exists", p);
211  }
212  DBG_VERBOUS(GWEN_LOGDOMAIN, "Returning this: %s", p);
213  GWEN_Buffer_free(ebuf);
214  return buf;
215 }
216 
217 
218 
219 int GWEN_Directory_GetPath(const char *path,
220  unsigned int flags) {
221  GWEN_BUFFER *buf;
222  void *p;
223 
224  assert(path);
225  buf=GWEN_Buffer_new(0, strlen(path)+10, 0, 1);
226  p=GWEN_Path_Handle(path, buf,
229  if (!p) {
230  DBG_INFO(GWEN_LOGDOMAIN, "Path so far: \"%s\"", GWEN_Buffer_GetStart(buf));
231  GWEN_Buffer_free(buf);
232  return -1;
233  }
234  GWEN_Buffer_free(buf);
235  return 0;
236 }
237 
238 
239 
240 int GWEN_Directory_OsifyPath(const char *path, GWEN_BUFFER *pbuf,
241  int transformDriveElement) {
242  const char *p;
243 
244  p=path;
245 
246  /* handle drive letters (only check for normal slashes here) */
247 #ifdef OS_WIN32
248  if (transformDriveElement) {
249  if (*p=='/')
250  if (isalpha(p[1]))
251  if (p[2]=='/' || p[2]==0) {
252  GWEN_Buffer_AppendByte(pbuf, p[0]);
253  GWEN_Buffer_AppendByte(pbuf, ':');
254  p+=2;
255  }
256  }
257 #endif
258 
259  while(*p) {
260  if (*p=='/' || *p=='\\') {
261  while (*p=='/' || *p=='\\')
262  p++;
263 #ifdef OS_WIN32
264  GWEN_Buffer_AppendByte(pbuf, '\\');
265 #else
266  GWEN_Buffer_AppendByte(pbuf, '/');
267 #endif
268  }
269  else {
270  GWEN_Buffer_AppendByte(pbuf, *p);
271  p++;
272  }
273  }
274 
275  return 0;
276 }
277 
278 
279 
281  const char *filePath,
282  GWEN_BUFFER *fbuf) {
284 
285  se=GWEN_StringList_FirstEntry(paths);
286  while(se) {
287  GWEN_BUFFER *tbuf;
288  FILE *f;
289 
290  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
293  GWEN_Buffer_AppendString(tbuf, filePath);
294  DBG_VERBOUS(GWEN_LOGDOMAIN, "Trying \"%s\"",
295  GWEN_Buffer_GetStart(tbuf));
296  f=fopen(GWEN_Buffer_GetStart(tbuf), "r");
297  if (f) {
298  fclose(f);
300  "File \"%s\" found in folder \"%s\"",
301  filePath,
303  GWEN_Buffer_AppendBuffer(fbuf, tbuf);
304  GWEN_Buffer_free(tbuf);
305  return 0;
306  }
307  GWEN_Buffer_free(tbuf);
308 
310  }
311 
312  DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", filePath);
313  return GWEN_ERROR_NOT_FOUND;
314 }
315 
316 
317 
319  const char *filePath,
320  GWEN_BUFFER *fbuf) {
322 
323  se=GWEN_StringList_FirstEntry(paths);
324  while(se) {
325  GWEN_BUFFER *tbuf;
326  FILE *f;
327 
328  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
331  GWEN_Buffer_AppendString(tbuf, filePath);
332  DBG_VERBOUS(GWEN_LOGDOMAIN, "Trying \"%s\"",
333  GWEN_Buffer_GetStart(tbuf));
334  f=fopen(GWEN_Buffer_GetStart(tbuf), "r");
335  if (f) {
336  fclose(f);
338  "File \"%s\" found in folder \"%s\"",
339  filePath,
342  GWEN_Buffer_free(tbuf);
343  return 0;
344  }
345  GWEN_Buffer_free(tbuf);
346 
348  }
349 
350  DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", filePath);
351  return GWEN_ERROR_NOT_FOUND;
352 }
353 
354 
355 
356 int GWEN_Directory_GetTmpDirectory(char *buffer, unsigned int size) {
357  const char *tmp_dir;
358  assert(buffer);
359 
360  /* Copied from http://svn.gnome.org/viewcvs/glib/trunk/glib/gutils.c */
361  tmp_dir = getenv ("TMPDIR");
362  if (!tmp_dir)
363  tmp_dir = getenv ("TMP");
364  if (!tmp_dir)
365  tmp_dir = getenv ("TEMP");
366 
367  if (!tmp_dir) {
368 #ifdef OS_WIN32
369  tmp_dir = "C:\\";
370 #else
371  tmp_dir = "/tmp";
372 #endif /* !OS_WIN32 */
373  }
374 
375  strncpy (buffer, tmp_dir, size);
376  return 0;
377 }
378 
379 
380 
381 int GWEN_Directory_GetAllEntries(const char *folder,
382  GWEN_STRINGLIST *sl,
383  const char *mask) {
384  GWEN_DIRECTORY *d;
385  int rv;
386  char buffer[256];
387 
388  d=GWEN_Directory_new();
389  rv=GWEN_Directory_Open(d, folder);
390  if (rv<0) {
391  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
393  return rv;
394  }
395 
396  while(0==GWEN_Directory_Read(d, buffer, sizeof(buffer))) {
397  if (strcmp(buffer, ".")!=0 &&
398  strcmp(buffer, "..")!=0 &&
399  (mask==NULL ||
400  GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1))
401  GWEN_StringList_AppendString(sl, buffer, 0, 1);
402  }
403 
406  return 0;
407 }
408 
409 
410 
412  GWEN_STRINGLIST *sl,
413  const char *mask) {
414  GWEN_DIRECTORY *d;
415  int rv;
416  char buffer[256];
417  GWEN_BUFFER *pbuf;
418  uint32_t pos;
419 
420  d=GWEN_Directory_new();
421  rv=GWEN_Directory_Open(d, folder);
422  if (rv<0) {
423  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
425  return rv;
426  }
427 
428  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
429  GWEN_Buffer_AppendString(pbuf, folder);
431  pos=GWEN_Buffer_GetPos(pbuf);
432 
433  while(0==GWEN_Directory_Read(d, buffer+1, sizeof(buffer)-2)) {
434  if (strcmp(buffer, ".")!=0 &&
435  strcmp(buffer, "..")!=0 &&
436  (mask==NULL ||
437  GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1)) {
438  struct stat st;
439 
440  GWEN_Buffer_AppendString(pbuf, buffer+1);
441  if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
442  if (S_ISREG(st.st_mode))
443  buffer[0]='f';
444  else if (S_ISDIR(st.st_mode))
445  buffer[0]='d';
446  else
447  buffer[0]='?';
448  GWEN_StringList_AppendString(sl, buffer, 0, 1);
449  }
450  GWEN_Buffer_Crop(pbuf, 0, pos);
451  }
452  }
453 
456  return 0;
457 }
458 
459 
460 
461 
462 int GWEN_Directory_GetFileEntries(const char *folder, GWEN_STRINGLIST *sl,
463  const char *mask) {
464  GWEN_DIRECTORY *d;
465  int rv;
466  char buffer[256];
467  GWEN_BUFFER *pbuf;
468  uint32_t pos;
469 
470  d=GWEN_Directory_new();
471  rv=GWEN_Directory_Open(d, folder);
472  if (rv<0) {
473  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
475  return rv;
476  }
477 
478  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
479  GWEN_Buffer_AppendString(pbuf, folder);
481  pos=GWEN_Buffer_GetPos(pbuf);
482 
483  while(0==GWEN_Directory_Read(d, buffer, sizeof(buffer))) {
484  if (strcmp(buffer, ".")!=0 &&
485  strcmp(buffer, "..")!=0 &&
486  (mask==NULL ||
487  GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1)) {
488  struct stat st;
489 
490  GWEN_Buffer_AppendString(pbuf, buffer);
491  if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
492  if (S_ISREG(st.st_mode))
493  GWEN_StringList_AppendString(sl, buffer, 0, 1);
494  }
495  GWEN_Buffer_Crop(pbuf, 0, pos);
496  }
497  }
498 
499  GWEN_Buffer_free(pbuf);
502  return 0;
503 }
504 
505 
506 
507 int GWEN_Directory_GetDirEntries(const char *folder, GWEN_STRINGLIST *sl,
508  const char *mask) {
509  GWEN_DIRECTORY *d;
510  int rv;
511  char buffer[256];
512  GWEN_BUFFER *pbuf;
513  uint32_t pos;
514 
515  d=GWEN_Directory_new();
516  rv=GWEN_Directory_Open(d, folder);
517  if (rv<0) {
518  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
520  return rv;
521  }
522 
523  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
524  GWEN_Buffer_AppendString(pbuf, folder);
526  pos=GWEN_Buffer_GetPos(pbuf);
527 
528  while(0==GWEN_Directory_Read(d, buffer, sizeof(buffer))) {
529  if (strcmp(buffer, ".")!=0 &&
530  strcmp(buffer, "..")!=0 &&
531  (mask==NULL ||
532  GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1)) {
533  struct stat st;
534 
535  GWEN_Buffer_AppendString(pbuf, buffer);
536  if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
537  if (S_ISDIR(st.st_mode))
538  GWEN_StringList_AppendString(sl, buffer, 0, 1);
539  }
540  GWEN_Buffer_Crop(pbuf, 0, pos);
541  }
542  }
543 
546  return 0;
547 }
548 
549 
550 
552  GWEN_STRINGLIST *sl,
553  const char *mask) {
554  GWEN_DIRECTORY *d;
555  int rv;
556  char buffer[256];
557  GWEN_BUFFER *pbuf;
558  uint32_t pos;
559  GWEN_STRINGLIST *folderList;
560 
561  folderList=GWEN_StringList_new();
562 
563  d=GWEN_Directory_new();
564  rv=GWEN_Directory_Open(d, folder);
565  if (rv<0) {
566  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
568  GWEN_StringList_free(folderList);
569  return rv;
570  }
571 
572  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
573  GWEN_Buffer_AppendString(pbuf, folder);
575  pos=GWEN_Buffer_GetPos(pbuf);
576 
577  while(0==GWEN_Directory_Read(d, buffer, sizeof(buffer)-2)) {
578  if (strcmp(buffer, ".")!=0 &&
579  strcmp(buffer, "..")!=0) {
580  struct stat st;
581 
582  GWEN_Buffer_AppendString(pbuf, buffer);
583  if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
584  if (S_ISDIR(st.st_mode))
585  /* add folders to the folder list */
586  GWEN_StringList_AppendString(folderList, GWEN_Buffer_GetStart(pbuf), 0, 0);
587  else {
588  if (mask==NULL || GWEN_Text_ComparePattern(buffer, mask, 0)!=-1)
589  /* don't check for duplicates here (i.e. last param =0) */
591  }
592  }
593  GWEN_Buffer_Crop(pbuf, 0, pos);
594  }
595  }
596 
599 
600  if (GWEN_StringList_Count(folderList)) {
602 
603  se=GWEN_StringList_FirstEntry(folderList);
604  while(se) {
605  const char *s;
606 
608  if (s && *s)
611  }
612  }
613  GWEN_StringList_free(folderList);
614  GWEN_Buffer_free(pbuf);
615 
616  return 0;
617 }
618 
619 
620 
621 int GWEN_Directory_GetAbsoluteFolderPath(const char *folder, GWEN_BUFFER *tbuf) {
622  char savedPwd[300];
623  char dataPwd[300];
624 
625  /* get current working dir */
626  if (getcwd(savedPwd, sizeof(savedPwd)-1)==NULL) {
627  DBG_ERROR(GWEN_LOGDOMAIN, "getcwd(): %s", strerror(errno));
628  return GWEN_ERROR_IO;
629  }
630 
631  if (chdir(folder)) {
632  DBG_ERROR(GWEN_LOGDOMAIN, "chdir(%s): %s", folder, strerror(errno));
633  return GWEN_ERROR_IO;
634  }
635 
636  /* get new current working dir */
637  if (getcwd(dataPwd, sizeof(dataPwd)-1)==NULL) {
638  DBG_ERROR(GWEN_LOGDOMAIN, "getcwd(): %s", strerror(errno));
639  return GWEN_ERROR_IO;
640  }
641  dataPwd[sizeof(dataPwd)-1]=0;
642 
643  /* change back to previous pwd */
644  if (chdir(savedPwd)) {
645  DBG_ERROR(GWEN_LOGDOMAIN, "chdir(%s): %s", folder, strerror(errno));
646  return GWEN_ERROR_IO;
647  }
648 
649  GWEN_Buffer_AppendString(tbuf, dataPwd);
650  return 0;
651 }
652 
653 
654 
655 
656 
657 
void * GWEN_Path_Handle(const char *path, void *data, uint32_t flags, GWEN_PATHHANDLERPTR elementFunction)
Definition: path.c:39
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:223
int GWEN_Directory_GetAbsoluteFolderPath(const char *folder, GWEN_BUFFER *tbuf)
GWENHYWFAR_API void GWEN_Directory_free(GWEN_DIRECTORY *d)
struct GWEN_STRINGLISTENTRYSTRUCT GWEN_STRINGLISTENTRY
Definition: stringlist.h:51
int GWEN_Directory_OsifyPath(const char *path, GWEN_BUFFER *pbuf, int transformDriveElement)
int GWEN_Directory_FindPathForFile(const GWEN_STRINGLIST *paths, const char *filePath, GWEN_BUFFER *fbuf)
#define GWEN_DIR_SEPARATOR_S
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
Definition: buffer.c:266
#define NULL
Definition: binreloc.c:290
GWENHYWFAR_API int GWEN_Directory_Close(GWEN_DIRECTORY *d)
#define DBG_VERBOUS(dbg_logger, format, args...)
Definition: debug.h:200
#define GWEN_LOGDOMAIN
Definition: logger.h:35
uint32_t GWEN_Buffer_GetPos(const GWEN_BUFFER *bf)
Definition: buffer.c:239
GWENHYWFAR_API GWEN_DIRECTORY * GWEN_Directory_new(void)
int GWEN_Directory_GetMatchingFilesRecursively(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:38
#define DIRSEP
Definition: directory_all.c:56
GWEN_STRINGLISTENTRY * GWEN_StringList_FirstEntry(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:352
#define GWEN_ERROR_IO
Definition: error.h:123
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:366
struct GWEN_DIRECTORY GWEN_DIRECTORY
Definition: directory.h:41
#define GWEN_DIR_FLAGS_PUBLIC_PATH
Definition: directory.h:60
#define GWEN_PATH_FLAGS_LAST
Definition: path.h:166
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
Definition: stringlist.c:57
GWENHYWFAR_API int GWEN_Directory_Create(const char *path)
#define GWEN_PATH_FLAGS_NAMEMUSTNOTEXIST
Definition: path.h:89
#define GWEN_DIR_FLAGS_PUBLIC_NAME
Definition: directory.h:61
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
Definition: stringlist.c:230
#define DBG_DEBUG(dbg_logger, format, args...)
Definition: debug.h:192
int GWEN_Buffer_AppendBuffer(GWEN_BUFFER *bf, GWEN_BUFFER *sf)
Definition: buffer.c:549
int GWEN_Directory_GetTmpDirectory(char *buffer, unsigned int size)
int GWEN_Directory_FindFileInPaths(const GWEN_STRINGLIST *paths, const char *filePath, GWEN_BUFFER *fbuf)
#define GWEN_PATH_FLAGS_VARIABLE
Definition: path.h:111
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
Definition: stringlist.h:54
int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c)
Definition: buffer.c:380
int GWEN_Directory_GetDirEntries(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:83
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:41
int GWEN_Directory_GetFileEntriesWithType(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
int GWEN_Buffer_Crop(GWEN_BUFFER *bf, uint32_t pos, uint32_t l)
Definition: buffer.c:973
#define GWEN_PATH_FLAGS_CHECKROOT
Definition: path.h:142
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:382
#define GWEN_PATH_FLAGS_PATHMUSTNOTEXIST
Definition: path.h:70
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
int GWEN_Directory_GetAllEntries(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
int GWEN_Text_ComparePattern(const char *w, const char *p, int sensecase)
Definition: text.c:1162
GWEN_STRINGLISTENTRY * GWEN_StringListEntry_Next(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:359
#define GWEN_PATH_FLAGS_PATHMUSTEXIST
Definition: path.h:66
#define GWEN_ERROR_NOT_FOUND
Definition: error.h:89
GWENHYWFAR_API int GWEN_Directory_CreatePublic(const char *path)
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:164
int GWEN_Directory_GetPath(const char *path, unsigned int flags)
int GWEN_Directory_GetFileEntries(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
GWENHYWFAR_API int GWEN_Directory_Read(GWEN_DIRECTORY *d, char *buffer, unsigned int len)
GWEN_STRINGLIST * GWEN_StringList_new(void)
Definition: stringlist.c:46
#define GWEN_PATH_FLAGS_NAMEMUSTEXIST
Definition: path.h:84
void * GWEN_Directory_HandlePathElement(const char *entry, void *data, unsigned int flags)
Definition: directory_all.c:63
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition: buffer.c:1014
GWENHYWFAR_API int GWEN_Directory_Open(GWEN_DIRECTORY *d, const char *n)