|
gwenhywfar 5.14.1
|
#include <gwenhywfar/directory.h>#include <gwenhywfar/debug.h>#include <gwenhywfar/path.h>#include <gwenhywfar/buffer.h>#include <gwenhywfar/text.h>#include <sys/types.h>#include <string.h>#include <errno.h>#include <assert.h>#include <stdlib.h>#include <ctype.h>
Go to the source code of this file.
Macros | |
| #define | DIRSEP "/" |
| #define | DISABLE_DEBUGLOG |
Functions | |
| int | GWEN_Directory_FindFileInPaths (const GWEN_STRINGLIST *paths, const char *filePath, GWEN_BUFFER *fbuf) |
| int | GWEN_Directory_FindPathForFile (const GWEN_STRINGLIST *paths, const char *filePath, GWEN_BUFFER *fbuf) |
| int | GWEN_Directory_GetAbsoluteFolderPath (const char *folder, GWEN_BUFFER *tbuf) |
| int | GWEN_Directory_GetAllEntries (const char *folder, GWEN_STRINGLIST *sl, const char *mask) |
| int | GWEN_Directory_GetDirEntries (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_GetFileEntriesWithType (const char *folder, GWEN_STRINGLIST *sl, const char *mask) |
| int | GWEN_Directory_GetMatchingFilesRecursively (const char *folder, GWEN_STRINGLIST *sl, const char *mask) |
| int | GWEN_Directory_GetPath (const char *path, unsigned int flags) |
| int | GWEN_Directory_GetTmpDirectory (char *buffer, unsigned int size) |
| static void * | GWEN_Directory_HandlePathElement (const char *entry, void *data, unsigned int flags) |
| int | GWEN_Directory_OsifyPath (const char *path, GWEN_BUFFER *pbuf, GWEN_UNUSED int transformDriveElement) |
| #define DIRSEP "/" |
Definition at line 56 of file directory_all.c.
| #define DISABLE_DEBUGLOG |
Definition at line 59 of file directory_all.c.
| int GWEN_Directory_FindFileInPaths | ( | const GWEN_STRINGLIST * | paths, |
| const char * | filePath, | ||
| GWEN_BUFFER * | fbuf ) |
Definition at line 303 of file directory_all.c.
References DBG_DEBUG, DBG_INFO, DBG_VERBOUS, DIRSEP, GWEN_Buffer_AppendBuffer(), GWEN_Buffer_AppendString(), GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_ERROR_NOT_FOUND, GWEN_LOGDOMAIN, GWEN_StringList_FirstEntry(), GWEN_StringListEntry_Data(), and GWEN_StringListEntry_Next().
Referenced by _determineNamePath(), _getToolPath(), CocoaGui_WPushButton_Setup(), FOX16_GuiDialog::getIcon(), FOX16_HtmlCtx::getImage(), Gtk2Gui_WPushButton_Setup(), Gtk3Gui_WPushButton_Setup(), GWEN_SyncIo_Tls_Prepare(), and Typemaker2_TypeManager_LoadType().


| int GWEN_Directory_FindPathForFile | ( | const GWEN_STRINGLIST * | paths, |
| const char * | filePath, | ||
| GWEN_BUFFER * | fbuf ) |
Definition at line 342 of file directory_all.c.
References DBG_INFO, DBG_VERBOUS, DIRSEP, GWEN_Buffer_AppendString(), GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_ERROR_NOT_FOUND, GWEN_LOGDOMAIN, GWEN_StringList_FirstEntry(), GWEN_StringListEntry_Data(), and GWEN_StringListEntry_Next().

| int GWEN_Directory_GetAbsoluteFolderPath | ( | const char * | folder, |
| GWEN_BUFFER * | tbuf ) |
This function determines the absolute path og the given folder and returns it in the given buffer. It uses a combination of getcwd() and chdir() to get the result. This function should return with the current working directory effectively unchanged.
| folder | folder for which to retrieve the absolute path |
| tbuf | buffer to receive the result |
Definition at line 652 of file directory_all.c.
References DBG_ERROR, GWEN_Buffer_AppendString(), GWEN_ERROR_IO, GWEN_LOGDOMAIN, and NULL.
Referenced by _makeAbsolutePaths(), and GWB_Builder_AddAbsFileNameToBuffer().


| int GWEN_Directory_GetAllEntries | ( | const char * | folder, |
| GWEN_STRINGLIST * | sl, | ||
| const char * | mask ) |
This function reads all entries of the given folder and stores them in the given string list if they match a mask.
The entries added to the string list are the names returned by the operating systems. They do not contain the full path.
| folder | folder to inspect |
| sl | string list to add new entries to |
| mask | if omitted, all entries match (wildcards and jokers allowed) |
Definition at line 407 of file directory_all.c.
References DBG_INFO, GWEN_Directory_Close(), GWEN_Directory_free(), GWEN_Directory_new(), GWEN_Directory_Open(), GWEN_Directory_Read(), GWEN_LOGDOMAIN, GWEN_StringList_AppendString(), GWEN_Text_ComparePattern(), and NULL.

| int GWEN_Directory_GetDirEntries | ( | const char * | folder, |
| GWEN_STRINGLIST * | sl, | ||
| const char * | mask ) |
This function does the same as GWEN_Directory_GetAllEntries, but it only adds folder entries.
| folder | folder to inspect |
| sl | string list to add new entries to |
| mask | if omitted, all entries match (wildcards and jokers allowed) |
Definition at line 536 of file directory_all.c.
References DBG_INFO, GWEN_Buffer_AppendString(), GWEN_Buffer_Crop(), GWEN_Buffer_GetPos(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_DIR_SEPARATOR_S, GWEN_Directory_Close(), GWEN_Directory_free(), GWEN_Directory_new(), GWEN_Directory_Open(), GWEN_Directory_Read(), GWEN_LOGDOMAIN, GWEN_StringList_AppendString(), GWEN_Text_ComparePattern(), and NULL.
Referenced by GWEN_ConfigMgrDir_ListGroups().


| int GWEN_Directory_GetFileEntries | ( | const char * | folder, |
| GWEN_STRINGLIST * | sl, | ||
| const char * | mask ) |
This function does the same as GWEN_Directory_GetAllEntries, but it only adds file entries.
| folder | folder to inspect |
| sl | string list to add new entries to |
| mask | if omitted, all entries match (wildcards and jokers allowed) |
Definition at line 490 of file directory_all.c.
References DBG_INFO, GWEN_Buffer_AppendString(), GWEN_Buffer_Crop(), GWEN_Buffer_free(), GWEN_Buffer_GetPos(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_DIR_SEPARATOR_S, GWEN_Directory_Close(), GWEN_Directory_free(), GWEN_Directory_new(), GWEN_Directory_Open(), GWEN_Directory_Read(), GWEN_LOGDOMAIN, GWEN_StringList_AppendString(), GWEN_Text_ComparePattern(), and NULL.
Referenced by GWEN_ConfigMgrDir_ListSubGroups(), and GWEN_LoadPluginDescrsByType().


| int GWEN_Directory_GetFileEntriesWithType | ( | const char * | folder, |
| GWEN_STRINGLIST * | sl, | ||
| const char * | mask ) |
This function does the same as GWEN_Directory_GetAllEntries, but in addition a entry type indicator is prepended to the entries added to the string list. Known indicators are:
| folder | folder to inspect |
| sl | string list to add new entries to |
| mask | if omitted, all entries match (wildcards and jokers allowed) |
Definition at line 438 of file directory_all.c.
References DBG_INFO, GWEN_Buffer_AppendString(), GWEN_Buffer_Crop(), GWEN_Buffer_GetPos(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_DIR_SEPARATOR_S, GWEN_Directory_Close(), GWEN_Directory_free(), GWEN_Directory_new(), GWEN_Directory_Open(), GWEN_Directory_Read(), GWEN_LOGDOMAIN, GWEN_StringList_AppendString(), GWEN_Text_ComparePattern(), and NULL.
Referenced by GWEN_MDigest__HashFileTree().


| int GWEN_Directory_GetMatchingFilesRecursively | ( | const char * | folder, |
| GWEN_STRINGLIST * | sl, | ||
| const char * | mask ) |
This function adds all matching files to the given string list recursively. Each entry of the stringlist starts with the given folder, so if that argument is an absolute path all stringlist entries will be absolute paths.
| folder | folder to inspect (including sub-folders) |
| sl | string list to add new entries to |
| mask | if omitted, all entries match (wildcards and jokers allowed) |
Definition at line 581 of file directory_all.c.
References DBG_INFO, GWEN_Buffer_AppendString(), GWEN_Buffer_Crop(), GWEN_Buffer_free(), GWEN_Buffer_GetPos(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_DIR_SEPARATOR_S, GWEN_Directory_Close(), GWEN_Directory_free(), GWEN_Directory_GetMatchingFilesRecursively(), GWEN_Directory_new(), GWEN_Directory_Open(), GWEN_Directory_Read(), GWEN_LOGDOMAIN, GWEN_StringList_AppendString(), GWEN_StringList_Count(), GWEN_StringList_FirstEntry(), GWEN_StringList_free(), GWEN_StringList_new(), GWEN_StringListEntry_Data(), GWEN_StringListEntry_Next(), GWEN_Text_ComparePattern(), and NULL.
Referenced by GWB_GBuilderDescr_ReadAll(), GWEN_Directory_GetMatchingFilesRecursively(), and GWEN_PathManager_GetMatchingFilesRecursively().


| int GWEN_Directory_GetPath | ( | const char * | path, |
| unsigned int | flags ) |
Gets a file path. It uses Paths to either create or check for the existence of a given path.
| path | path to inspect |
| flags | flags, please see GWEN_PATH_FLAGS_PATHMUSTEXIST et. al. |
Definition at line 237 of file directory_all.c.
References DBG_INFO, GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_Directory_HandlePathElement(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_CHECKROOT, and GWEN_Path_Handle().
Referenced by _addLogLineToFile(), _copyLink(), _copyRegFile(), _prepareBaseLogPath(), _writeLinesToFile(), GWB_BuildCtx_CreateAndSetLogFilenameForSubCmd(), GWB_Parser_ParseSubdirs(), GWEN_ConfigMgrDir__GetUniqueId(), GWEN_ConfigMgrDir__UpdateLastUniqueId(), GWEN_ConfigMgrDir_DeleteGroup(), GWEN_ConfigMgrDir_GetGroup(), GWEN_ConfigMgrDir_HasGroup(), GWEN_ConfigMgrDir_ListSubGroups(), GWEN_ConfigMgrDir_LockGroup(), GWEN_ConfigMgrDir_MkUniqueIdFromId(), GWEN_ConfigMgrDir_SetGroup(), GWEN_PasswordStore_EncryptWriteFile(), GWEN_PasswordStore_GetPassword(), GWEN_PasswordStore_GetTokenList(), GWEN_PasswordStore_SetPassword(), and GWEN_SyncIo_Tls_Prepare().


| int GWEN_Directory_GetTmpDirectory | ( | char * | buffer, |
| unsigned int | size ) |
Gets the directory to use for temporary files and copies it into the given buffer.
This is found from inspecting the environment variables TMPDIR, TMP, and TEMP in that order. If none of those are defined, "/tmp" is returned on UNIX and "C:\" on Windows. This is similar to glib's g_get_tmp_dir().
Definition at line 381 of file directory_all.c.
Referenced by check_directory().

|
static |
Definition at line 80 of file directory_all.c.
References DBG_DEBUG, DBG_ERROR, DBG_INFO, DBG_VERBOUS, GWEN_Buffer_AppendByte(), GWEN_Buffer_AppendString(), GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_GetUsedBytes(), GWEN_Buffer_new(), GWEN_DIR_FLAGS_PUBLIC_NAME, GWEN_DIR_FLAGS_PUBLIC_PATH, GWEN_Directory_Create(), GWEN_Directory_CreatePublic(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_LAST, GWEN_PATH_FLAGS_NAMEMUSTEXIST, GWEN_PATH_FLAGS_NAMEMUSTNOTEXIST, GWEN_PATH_FLAGS_PATHMUSTEXIST, GWEN_PATH_FLAGS_PATHMUSTNOTEXIST, and GWEN_PATH_FLAGS_VARIABLE.
Referenced by GWEN_Directory_GetPath().


| int GWEN_Directory_OsifyPath | ( | const char * | path, |
| GWEN_BUFFER * | pbuf, | ||
| GWEN_UNUSED int | transformDriveElement ) |
Definition at line 259 of file directory_all.c.
References GWEN_Buffer_AppendByte(), and GWEN_UNUSED.
