gwenhywfar  4.99.15beta
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 {
67  char *p;
68  struct stat st;
69  int exists;
70  int withDrive;
71  GWEN_BUFFER *buf;
72  GWEN_BUFFER *ebuf = 0;
73 
74  withDrive=0;
75 
76 #ifdef OS_WIN32
77  if (entry && isalpha(*entry)) {
78  int len;
79 
80  /* append backslash if entry only consists of a drive specification */
81  len=strlen(entry);
82  if ((len==2) && (entry[1] == ':')) {
83  ebuf=GWEN_Buffer_new(0, len+2, 0, 1);
84  GWEN_Buffer_AppendString(ebuf, entry);
85  GWEN_Buffer_AppendByte(ebuf, '\\');
86  withDrive=1;
87  entry=GWEN_Buffer_GetStart(ebuf);
88  }
89  }
90 #endif /* OS_WIN32 */
91 
92  if (strcasecmp(entry, "..")==0) {
93  DBG_ERROR(GWEN_LOGDOMAIN, "\"..\" detected");
94  GWEN_Buffer_free(ebuf);
95  return 0;
96  }
97 
98  buf=(GWEN_BUFFER *)data;
99  if (GWEN_Buffer_GetUsedBytes(buf) && !withDrive) {
100  char c;
101 
103 #ifdef OS_WIN32
104  if (c!='\\')
105  GWEN_Buffer_AppendByte(buf, '\\');
106 #else
107  if (c!='/')
108  GWEN_Buffer_AppendByte(buf, '/');
109 #endif /* OS_WIN32 */
110  }
111  GWEN_Buffer_AppendString(buf, entry);
112 
113  /* check for existence of the file/folder */
114  p=GWEN_Buffer_GetStart(buf);
115  DBG_VERBOUS(GWEN_LOGDOMAIN, "Checking path \"%s\"", p);
116  if (stat(p, &st)) {
117  exists=0;
118  DBG_DEBUG(GWEN_LOGDOMAIN, "stat: %s (%s)", strerror(errno), p);
119  if ((flags & GWEN_PATH_FLAGS_PATHMUSTEXIST) ||
120  ((flags & GWEN_PATH_FLAGS_LAST) &&
121  (flags & GWEN_PATH_FLAGS_NAMEMUSTEXIST))) {
122  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" does not exist (it should)", p);
123  GWEN_Buffer_free(ebuf);
124  return 0;
125  }
126  }
127  else {
128  DBG_VERBOUS(GWEN_LOGDOMAIN, "Checking for type");
129  exists=1;
130  if (flags & GWEN_PATH_FLAGS_VARIABLE) {
131  if (!S_ISREG(st.st_mode)) {
132  DBG_INFO(GWEN_LOGDOMAIN, "%s not a regular file", p);
133  GWEN_Buffer_free(ebuf);
134  return 0;
135  }
136  }
137  else {
138  if (!S_ISDIR(st.st_mode)) {
139  DBG_INFO(GWEN_LOGDOMAIN, "%s not a direcory", p);
140  GWEN_Buffer_free(ebuf);
141  return 0;
142  }
143  }
144  if ((flags & GWEN_PATH_FLAGS_PATHMUSTNOTEXIST) ||
145  ((flags & GWEN_PATH_FLAGS_LAST) &&
147  DBG_INFO(GWEN_LOGDOMAIN, "Path \"%s\" exists (it should not)", p);
148  GWEN_Buffer_free(ebuf);
149  return 0;
150  }
151  } /* if stat is ok */
152 
153  if (!exists) {
154  int isPublic;
155 
156  DBG_DEBUG(GWEN_LOGDOMAIN, "Entry \"%s\" does not exist", p);
157 
158  isPublic=(
159  ((flags & GWEN_PATH_FLAGS_LAST) &&
160  (flags & GWEN_DIR_FLAGS_PUBLIC_NAME)) ||
161  (!(flags & GWEN_PATH_FLAGS_LAST) &&
162  (flags & GWEN_DIR_FLAGS_PUBLIC_PATH))
163  );
164 
165  if (flags & GWEN_PATH_FLAGS_VARIABLE) {
166  /* create file */
167  int fd;
168 
169  DBG_DEBUG(GWEN_LOGDOMAIN, "Creating file \"%s\"", p);
170  if (isPublic)
171  fd=open(p, O_RDWR | O_CREAT | O_TRUNC,
172  S_IRUSR | S_IWUSR
173 #ifdef S_IRGRP
174  | S_IRGRP
175 #endif
176 #ifdef S_IROTH
177  | S_IROTH
178 #endif
179  );
180  else
181  fd=open(p, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
182  if (fd==-1) {
183  DBG_ERROR(GWEN_LOGDOMAIN, "open: %s (%s)", strerror(errno), p);
184  GWEN_Buffer_free(ebuf);
185  return 0;
186  }
187  close(fd);
188  DBG_VERBOUS(GWEN_LOGDOMAIN, "Successfully created");
189  }
190  else {
191  /* create dir */
192  DBG_VERBOUS(GWEN_LOGDOMAIN, "Creating folder \"%s\"", p);
193 
194  if (isPublic) {
196  DBG_ERROR(GWEN_LOGDOMAIN, "Could not create directory \"%s\"", p);
197  GWEN_Buffer_free(ebuf);
198  return 0;
199  }
200  }
201  else {
202  if (GWEN_Directory_Create(p)) {
203  DBG_ERROR(GWEN_LOGDOMAIN, "Could not create directory \"%s\"", p);
204  GWEN_Buffer_free(ebuf);
205  return 0;
206  }
207  }
208  }
209  } /* if exists */
210  else {
211  DBG_VERBOUS(GWEN_LOGDOMAIN, "Entry \"%s\" exists", p);
212  }
213  DBG_VERBOUS(GWEN_LOGDOMAIN, "Returning this: %s", p);
214  GWEN_Buffer_free(ebuf);
215  return buf;
216 }
217 
218 
219 
220 int GWEN_Directory_GetPath(const char *path,
221  unsigned int flags)
222 {
223  GWEN_BUFFER *buf;
224  void *p;
225 
226  assert(path);
227  buf=GWEN_Buffer_new(0, strlen(path)+10, 0, 1);
228  p=GWEN_Path_Handle(path, buf,
231  if (!p) {
232  DBG_INFO(GWEN_LOGDOMAIN, "Path so far: \"%s\"", GWEN_Buffer_GetStart(buf));
233  GWEN_Buffer_free(buf);
234  return -1;
235  }
236  GWEN_Buffer_free(buf);
237  return 0;
238 }
239 
240 
241 
242 int GWEN_Directory_OsifyPath(const char *path, GWEN_BUFFER *pbuf,
243  int transformDriveElement)
244 {
245  const char *p;
246 
247  p=path;
248 
249  /* handle drive letters (only check for normal slashes here) */
250 #ifdef OS_WIN32
251  if (transformDriveElement) {
252  if (*p=='/')
253  if (isalpha(p[1]))
254  if (p[2]=='/' || p[2]==0) {
255  GWEN_Buffer_AppendByte(pbuf, p[0]);
256  GWEN_Buffer_AppendByte(pbuf, ':');
257  p+=2;
258  }
259  }
260 #endif
261 
262  while (*p) {
263  if (*p=='/' || *p=='\\') {
264  while (*p=='/' || *p=='\\')
265  p++;
266 #ifdef OS_WIN32
267  GWEN_Buffer_AppendByte(pbuf, '\\');
268 #else
269  GWEN_Buffer_AppendByte(pbuf, '/');
270 #endif
271  }
272  else {
273  GWEN_Buffer_AppendByte(pbuf, *p);
274  p++;
275  }
276  }
277 
278  return 0;
279 }
280 
281 
282 
284  const char *filePath,
285  GWEN_BUFFER *fbuf)
286 {
288 
289  se=GWEN_StringList_FirstEntry(paths);
290  while (se) {
291  GWEN_BUFFER *tbuf;
292  FILE *f;
293 
294  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
297  GWEN_Buffer_AppendString(tbuf, filePath);
298  DBG_VERBOUS(GWEN_LOGDOMAIN, "Trying \"%s\"",
299  GWEN_Buffer_GetStart(tbuf));
300  f=fopen(GWEN_Buffer_GetStart(tbuf), "r");
301  if (f) {
302  fclose(f);
304  "File \"%s\" found in folder \"%s\"",
305  filePath,
307  GWEN_Buffer_AppendBuffer(fbuf, tbuf);
308  GWEN_Buffer_free(tbuf);
309  return 0;
310  }
311  GWEN_Buffer_free(tbuf);
312 
314  }
315 
316  DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", filePath);
317  return GWEN_ERROR_NOT_FOUND;
318 }
319 
320 
321 
323  const char *filePath,
324  GWEN_BUFFER *fbuf)
325 {
327 
328  se=GWEN_StringList_FirstEntry(paths);
329  while (se) {
330  GWEN_BUFFER *tbuf;
331  FILE *f;
332 
333  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
336  GWEN_Buffer_AppendString(tbuf, filePath);
337  DBG_VERBOUS(GWEN_LOGDOMAIN, "Trying \"%s\"",
338  GWEN_Buffer_GetStart(tbuf));
339  f=fopen(GWEN_Buffer_GetStart(tbuf), "r");
340  if (f) {
341  fclose(f);
343  "File \"%s\" found in folder \"%s\"",
344  filePath,
347  GWEN_Buffer_free(tbuf);
348  return 0;
349  }
350  GWEN_Buffer_free(tbuf);
351 
353  }
354 
355  DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", filePath);
356  return GWEN_ERROR_NOT_FOUND;
357 }
358 
359 
360 
361 int GWEN_Directory_GetTmpDirectory(char *buffer, unsigned int size)
362 {
363  const char *tmp_dir;
364  assert(buffer);
365 
366  /* Copied from http://svn.gnome.org/viewcvs/glib/trunk/glib/gutils.c */
367  tmp_dir = getenv("TMPDIR");
368  if (!tmp_dir)
369  tmp_dir = getenv("TMP");
370  if (!tmp_dir)
371  tmp_dir = getenv("TEMP");
372 
373  if (!tmp_dir) {
374 #ifdef OS_WIN32
375  tmp_dir = "C:\\";
376 #else
377  tmp_dir = "/tmp";
378 #endif /* !OS_WIN32 */
379  }
380 
381  strncpy(buffer, tmp_dir, size);
382  return 0;
383 }
384 
385 
386 
387 int GWEN_Directory_GetAllEntries(const char *folder,
388  GWEN_STRINGLIST *sl,
389  const char *mask)
390 {
391  GWEN_DIRECTORY *d;
392  int rv;
393  char buffer[256];
394 
395  d=GWEN_Directory_new();
396  rv=GWEN_Directory_Open(d, folder);
397  if (rv<0) {
398  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
400  return rv;
401  }
402 
403  while (0==GWEN_Directory_Read(d, buffer, sizeof(buffer))) {
404  if (strcmp(buffer, ".")!=0 &&
405  strcmp(buffer, "..")!=0 &&
406  (mask==NULL ||
407  GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1))
408  GWEN_StringList_AppendString(sl, buffer, 0, 1);
409  }
410 
413  return 0;
414 }
415 
416 
417 
419  GWEN_STRINGLIST *sl,
420  const char *mask)
421 {
422  GWEN_DIRECTORY *d;
423  int rv;
424  char buffer[256];
425  GWEN_BUFFER *pbuf;
426  uint32_t pos;
427 
428  d=GWEN_Directory_new();
429  rv=GWEN_Directory_Open(d, folder);
430  if (rv<0) {
431  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
433  return rv;
434  }
435 
436  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
437  GWEN_Buffer_AppendString(pbuf, folder);
439  pos=GWEN_Buffer_GetPos(pbuf);
440 
441  while (0==GWEN_Directory_Read(d, buffer+1, sizeof(buffer)-2)) {
442  if (strcmp(buffer, ".")!=0 &&
443  strcmp(buffer, "..")!=0 &&
444  (mask==NULL ||
445  GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1)) {
446  struct stat st;
447 
448  GWEN_Buffer_AppendString(pbuf, buffer+1);
449  if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
450  if (S_ISREG(st.st_mode))
451  buffer[0]='f';
452  else if (S_ISDIR(st.st_mode))
453  buffer[0]='d';
454  else
455  buffer[0]='?';
456  GWEN_StringList_AppendString(sl, buffer, 0, 1);
457  }
458  GWEN_Buffer_Crop(pbuf, 0, pos);
459  }
460  }
461 
464  return 0;
465 }
466 
467 
468 
469 
470 int GWEN_Directory_GetFileEntries(const char *folder, GWEN_STRINGLIST *sl,
471  const char *mask)
472 {
473  GWEN_DIRECTORY *d;
474  int rv;
475  char buffer[256];
476  GWEN_BUFFER *pbuf;
477  uint32_t pos;
478 
479  d=GWEN_Directory_new();
480  rv=GWEN_Directory_Open(d, folder);
481  if (rv<0) {
482  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
484  return rv;
485  }
486 
487  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
488  GWEN_Buffer_AppendString(pbuf, folder);
490  pos=GWEN_Buffer_GetPos(pbuf);
491 
492  while (0==GWEN_Directory_Read(d, buffer, sizeof(buffer))) {
493  if (strcmp(buffer, ".")!=0 &&
494  strcmp(buffer, "..")!=0 &&
495  (mask==NULL ||
496  GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1)) {
497  struct stat st;
498 
499  GWEN_Buffer_AppendString(pbuf, buffer);
500  if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
501  if (S_ISREG(st.st_mode))
502  GWEN_StringList_AppendString(sl, buffer, 0, 1);
503  }
504  GWEN_Buffer_Crop(pbuf, 0, pos);
505  }
506  }
507 
508  GWEN_Buffer_free(pbuf);
511  return 0;
512 }
513 
514 
515 
516 int GWEN_Directory_GetDirEntries(const char *folder, GWEN_STRINGLIST *sl,
517  const char *mask)
518 {
519  GWEN_DIRECTORY *d;
520  int rv;
521  char buffer[256];
522  GWEN_BUFFER *pbuf;
523  uint32_t pos;
524 
525  d=GWEN_Directory_new();
526  rv=GWEN_Directory_Open(d, folder);
527  if (rv<0) {
528  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
530  return rv;
531  }
532 
533  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
534  GWEN_Buffer_AppendString(pbuf, folder);
536  pos=GWEN_Buffer_GetPos(pbuf);
537 
538  while (0==GWEN_Directory_Read(d, buffer, sizeof(buffer))) {
539  if (strcmp(buffer, ".")!=0 &&
540  strcmp(buffer, "..")!=0 &&
541  (mask==NULL ||
542  GWEN_Text_ComparePattern(buffer+1, mask, 0)!=-1)) {
543  struct stat st;
544 
545  GWEN_Buffer_AppendString(pbuf, buffer);
546  if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
547  if (S_ISDIR(st.st_mode))
548  GWEN_StringList_AppendString(sl, buffer, 0, 1);
549  }
550  GWEN_Buffer_Crop(pbuf, 0, pos);
551  }
552  }
553 
556  return 0;
557 }
558 
559 
560 
562  GWEN_STRINGLIST *sl,
563  const char *mask)
564 {
565  GWEN_DIRECTORY *d;
566  int rv;
567  char buffer[256];
568  GWEN_BUFFER *pbuf;
569  uint32_t pos;
570  GWEN_STRINGLIST *folderList;
571 
572  folderList=GWEN_StringList_new();
573 
574  d=GWEN_Directory_new();
575  rv=GWEN_Directory_Open(d, folder);
576  if (rv<0) {
577  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
579  GWEN_StringList_free(folderList);
580  return rv;
581  }
582 
583  pbuf=GWEN_Buffer_new(0, 256, 0, 1);
584  GWEN_Buffer_AppendString(pbuf, folder);
586  pos=GWEN_Buffer_GetPos(pbuf);
587 
588  while (0==GWEN_Directory_Read(d, buffer, sizeof(buffer)-2)) {
589  if (strcmp(buffer, ".")!=0 &&
590  strcmp(buffer, "..")!=0) {
591  struct stat st;
592 
593  GWEN_Buffer_AppendString(pbuf, buffer);
594  if (stat(GWEN_Buffer_GetStart(pbuf), &st)==0) {
595  if (S_ISDIR(st.st_mode))
596  /* add folders to the folder list */
597  GWEN_StringList_AppendString(folderList, GWEN_Buffer_GetStart(pbuf), 0, 0);
598  else {
599  if (mask==NULL || GWEN_Text_ComparePattern(buffer, mask, 0)!=-1)
600  /* don't check for duplicates here (i.e. last param =0) */
602  }
603  }
604  GWEN_Buffer_Crop(pbuf, 0, pos);
605  }
606  }
607 
610 
611  if (GWEN_StringList_Count(folderList)) {
613 
614  se=GWEN_StringList_FirstEntry(folderList);
615  while (se) {
616  const char *s;
617 
619  if (s && *s)
622  }
623  }
624  GWEN_StringList_free(folderList);
625  GWEN_Buffer_free(pbuf);
626 
627  return 0;
628 }
629 
630 
631 
632 int GWEN_Directory_GetAbsoluteFolderPath(const char *folder, GWEN_BUFFER *tbuf)
633 {
634  char savedPwd[300];
635  char dataPwd[300];
636 
637  /* get current working dir */
638  if (getcwd(savedPwd, sizeof(savedPwd)-1)==NULL) {
639  DBG_ERROR(GWEN_LOGDOMAIN, "getcwd(): %s", strerror(errno));
640  return GWEN_ERROR_IO;
641  }
642 
643  if (chdir(folder)) {
644  DBG_ERROR(GWEN_LOGDOMAIN, "chdir(%s): %s", folder, strerror(errno));
645  return GWEN_ERROR_IO;
646  }
647 
648  /* get new current working dir */
649  if (getcwd(dataPwd, sizeof(dataPwd)-1)==NULL) {
650  DBG_ERROR(GWEN_LOGDOMAIN, "getcwd(): %s", strerror(errno));
651  return GWEN_ERROR_IO;
652  }
653  dataPwd[sizeof(dataPwd)-1]=0;
654 
655  /* change back to previous pwd */
656  if (chdir(savedPwd)) {
657  DBG_ERROR(GWEN_LOGDOMAIN, "chdir(%s): %s", folder, strerror(errno));
658  return GWEN_ERROR_IO;
659  }
660 
661  GWEN_Buffer_AppendString(tbuf, dataPwd);
662  return 0;
663 }
664 
665 
666 
667 
668 
669 
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:235
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:282
#define NULL
Definition: binreloc.c:297
GWENHYWFAR_API int GWEN_Directory_Close(GWEN_DIRECTORY *d)
#define DBG_VERBOUS(dbg_logger, format, args...)
Definition: debug.h:216
#define GWEN_LOGDOMAIN
Definition: logger.h:35
uint32_t GWEN_Buffer_GetPos(const GWEN_BUFFER *bf)
Definition: buffer.c:253
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:366
#define GWEN_ERROR_IO
Definition: error.h:123
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:382
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:58
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:241
#define DBG_DEBUG(dbg_logger, format, args...)
Definition: debug.h:208
int GWEN_Buffer_AppendBuffer(GWEN_BUFFER *bf, GWEN_BUFFER *sf)
Definition: buffer.c:576
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:399
int GWEN_Directory_GetDirEntries(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:85
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:1020
#define GWEN_PATH_FLAGS_CHECKROOT
Definition: path.h:142
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:403
#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:1181
GWEN_STRINGLISTENTRY * GWEN_StringListEntry_Next(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:374
#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:177
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:1062
GWENHYWFAR_API int GWEN_Directory_Open(GWEN_DIRECTORY *d, const char *n)