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>
59#define DISABLE_DEBUGLOG
94 if (entry && isalpha(*entry)) {
99 if ((len==2) && (entry[1] ==
':')) {
109 if (strcasecmp(entry,
"..")==0) {
148 if (!S_ISREG(st.st_mode)) {
155 if (!S_ISDIR(st.st_mode)) {
188 fd=open(p, O_RDWR | O_CREAT | O_TRUNC,
198 fd=open(p, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
263 int transformDriveElement)
271 if (transformDriveElement) {
274 if (p[2]==
'/' || p[2]==0) {
283 if (*p==
'/' || *p==
'\\') {
284 while (*p==
'/' || *p==
'\\')
304 const char *filePath,
324 "File \"%s\" found in folder \"%s\"",
343 const char *filePath,
363 "File \"%s\" found in folder \"%s\"",
387 tmp_dir = getenv(
"TMPDIR");
389 tmp_dir = getenv(
"TMP");
391 tmp_dir = getenv(
"TEMP");
401 strncpy(buffer, tmp_dir, size);
424 if (strcmp(buffer,
".")!=0 &&
425 strcmp(buffer,
"..")!=0 &&
462 if (strcmp(buffer,
".")!=0 &&
463 strcmp(buffer,
"..")!=0 &&
470 if (S_ISREG(st.st_mode))
472 else if (S_ISDIR(st.st_mode))
513 if (strcmp(buffer,
".")!=0 &&
514 strcmp(buffer,
"..")!=0 &&
521 if (S_ISREG(st.st_mode))
559 if (strcmp(buffer,
".")!=0 &&
560 strcmp(buffer,
"..")!=0 &&
567 if (S_ISDIR(st.st_mode))
609 if (strcmp(buffer,
".")!=0 &&
610 strcmp(buffer,
"..")!=0) {
615 if (S_ISDIR(st.st_mode))
658 if (getcwd(savedPwd,
sizeof(savedPwd)-1)==
NULL) {
669 if (getcwd(dataPwd,
sizeof(dataPwd)-1)==
NULL) {
673 dataPwd[
sizeof(dataPwd)-1]=0;
676 if (chdir(savedPwd)) {
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
uint32_t GWEN_Buffer_GetPos(const GWEN_BUFFER *bf)
int GWEN_Buffer_AppendBuffer(GWEN_BUFFER *bf, GWEN_BUFFER *sf)
void GWEN_Buffer_free(GWEN_BUFFER *bf)
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
int GWEN_Buffer_Crop(GWEN_BUFFER *bf, uint32_t pos, uint32_t l)
int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c)
#define DBG_VERBOUS(dbg_logger, format,...)
#define DBG_INFO(dbg_logger, format,...)
#define DBG_ERROR(dbg_logger, format,...)
#define DBG_DEBUG(dbg_logger, format,...)
GWENHYWFAR_API int GWEN_Directory_CreatePublic(const char *path)
#define GWEN_DIR_FLAGS_PUBLIC_NAME
GWENHYWFAR_API int GWEN_Directory_Read(GWEN_DIRECTORY *d, char *buffer, unsigned int len)
struct GWEN_DIRECTORY GWEN_DIRECTORY
GWENHYWFAR_API int GWEN_Directory_Open(GWEN_DIRECTORY *d, const char *n)
GWENHYWFAR_API GWEN_DIRECTORY * GWEN_Directory_new(void)
GWENHYWFAR_API void GWEN_Directory_free(GWEN_DIRECTORY *d)
GWENHYWFAR_API int GWEN_Directory_Close(GWEN_DIRECTORY *d)
GWENHYWFAR_API int GWEN_Directory_Create(const char *path)
#define GWEN_DIR_FLAGS_PUBLIC_PATH
int GWEN_Directory_GetMatchingFilesRecursively(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
static void * GWEN_Directory_HandlePathElement(const char *entry, void *data, unsigned int flags)
int GWEN_Directory_FindPathForFile(const GWEN_STRINGLIST *paths, const char *filePath, GWEN_BUFFER *fbuf)
int GWEN_Directory_GetTmpDirectory(char *buffer, unsigned int size)
int GWEN_Directory_GetFileEntriesWithType(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
int GWEN_Directory_FindFileInPaths(const GWEN_STRINGLIST *paths, const char *filePath, GWEN_BUFFER *fbuf)
int GWEN_Directory_GetDirEntries(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
int GWEN_Directory_GetAllEntries(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
int GWEN_Directory_GetFileEntries(const char *folder, GWEN_STRINGLIST *sl, const char *mask)
int GWEN_Directory_OsifyPath(const char *path, GWEN_BUFFER *pbuf, GWEN_UNUSED int transformDriveElement)
int GWEN_Directory_GetAbsoluteFolderPath(const char *folder, GWEN_BUFFER *tbuf)
int GWEN_Directory_GetPath(const char *path, unsigned int flags)
#define GWEN_ERROR_NOT_FOUND
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
#define GWEN_DIR_SEPARATOR_S
void * GWEN_Path_Handle(const char *path, void *data, uint32_t flags, GWEN_PATHHANDLERPTR elementFunction)
#define GWEN_PATH_FLAGS_CHECKROOT
#define GWEN_PATH_FLAGS_PATHMUSTEXIST
#define GWEN_PATH_FLAGS_NAMEMUSTNOTEXIST
#define GWEN_PATH_FLAGS_LAST
#define GWEN_PATH_FLAGS_PATHMUSTNOTEXIST
#define GWEN_PATH_FLAGS_VARIABLE
#define GWEN_PATH_FLAGS_NAMEMUSTEXIST
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
GWEN_STRINGLISTENTRY * GWEN_StringListEntry_Next(const GWEN_STRINGLISTENTRY *se)
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
GWEN_STRINGLISTENTRY * GWEN_StringList_FirstEntry(const GWEN_STRINGLIST *sl)
GWEN_STRINGLIST * GWEN_StringList_new(void)
struct GWEN_STRINGLISTENTRYSTRUCT GWEN_STRINGLISTENTRY
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
int GWEN_Text_ComparePattern(const char *w, const char *p, int sensecase)