1 /* 2 Copyright (C) 2015-2021, Dirk Krause 3 SPDX-License-Identifier: BSD-3-Clause 4 */ 5 6 /* 7 WARNING: This file was generated by the dkct program (see 8 http://dktools.sourceforge.net/ for details). 9 Changes you make here will be lost if dkct is run again! 10 You should modify the original source and run dkct on it. 11 Original source: dk4mkdh8.ctr 12 */ 13 14 #ifndef DK4MKDH8_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4MKDH8_H_INCLUDED 1 17 18 19 /** @file 20 Make directory hierarchy (create all parent directories for a 21 file or directory and the directory itself if required), 22 the file or directory name is specified as char string. 23 */ 24 25 #ifndef DK4CONF_H_INCLUDED 26 #if DK4_BUILDING_DKTOOLS4 27 #include "dk4conf.h" 28 #else 29 #include <dktools-4/dk4conf.h> 30 #endif 31 #endif 32 33 #ifndef DK4TYPES_H_INCLUDED 34 #if DK4_BUILDING_DKTOOLS4 35 #include <libdk4base/dk4types.h> 36 #else 37 #include <dktools-4/dk4types.h> 38 #endif 39 #endif 40 41 #ifndef DK4ERROR_H_INCLUDED 42 #if DK4_BUILDING_DKTOOLS4 43 #include <libdk4base/dk4error.h> 44 #else 45 #include <dktools-4/dk4error.h> 46 #endif 47 #endif 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 /** Find position of first separator for real directory. 54 55 This function is not intended for use in application programs, 56 it is exported only for use from the dk4appmkdh module. 57 58 The function either returns a value or sets the back variable 59 to 1 or reports an error. 60 @param fn File name. 61 @param bptr Pointer to the back variable. 62 @param lc Flag: Last component in fn is directory too. 63 @param erp Error report, may be NULL. 64 @return First separator after a real directory on success if 65 found, NULL otherwise. 66 */ 67 char * 68 dk4mkdir_hierarchy_c8_first_sep(char *fn, int *bptr, int lc, dk4_er_t *erp); 69 70 /** Check whether directory exists or attempt to create directory. 71 @param fn File name. 72 @param ro Flag: Read only (test directory presence), 73 do not attempt to create the directory. 74 @param erp Error report, may be NULL. 75 @return 1 if directory is available now, 0 otherwise. 76 77 Error codes: 78 - DK4_E_INVALID_ARGUMENTS<br> 79 if fn is NULL, 80 - DK4_E_NOT_FOUND<br> 81 if a server/share combination is not present on Windows, 82 - DK4_E_NON_DIR<br> 83 if any component in the path is not a directory, 84 - DK4_E_MKDIR_FAILED<br> 85 with errno value in iDetails1 if the mkdir() function failed on a 86 non-Windows system. 87 - DK4_E_CREATE_DIR_FAILED<br> 88 with GetLastError() result in lDetails1 if the CreateDirectory() 89 function failed on a Windows system. 90 */ 91 int 92 dk4mkdir_hierarchy_c8_one(const char *fn, int ro, dk4_er_t *erp); 93 94 /** Create directory structure. 95 @param fn File name. 96 @param lc Flag: Last component in fn is directory too. 97 @param erp Error report, may be NULL. 98 @return 1 on success, 0 on error. 99 100 Error codes: 101 - DK4_E_INVALID_ARGUMENTS<br> 102 if fn is NULL, 103 - DK4_E_BUFFER_TOO_SMALL<br> 104 if fn is too long, 105 - DK4_E_MATH_OVERFLOW<br> 106 if a mathematical overflow occured in size allocation, 107 - DK4_E_NOT_FOUND<br> 108 if a server/share combination is not present on Windows, 109 - DK4_E_NON_DIR<br> 110 if one of the components in fn is not a directory, 111 - DK4_E_MKDIR_FAILED<br> 112 with errno in idetails if the function fails to create the directory 113 or a parent directory, 114 - DK4_E_CREATE_DIR_FAILED<br> 115 with GetLastError() result in lDetails1 if the CreateDirectory() 116 function failed on a Windows system. 117 */ 118 int 119 dk4mkdir_hierarchy_c8(const char *fn, int lc, dk4_er_t *erp); 120 121 122 #if DK4_HAVE_UID_T && DK4_HAVE_GID_T && DK4_HAVE_MODE_T && (!DK4_ON_WINDOWS) 123 124 /** Create directory structure for a given POSIX user and group. 125 @param fn File name. 126 @param lc Flag: Last component in fn is directory too. 127 @param uid User ID for new directories. 128 @param gid Group ID for new directories. 129 @param mode Permissions to new directories. 130 @param erp Error report, may be NULL. 131 @return 1 on success, 0 on error. 132 133 Error codes: 134 - DK4_E_INVALID_ARGUMENTS<br> 135 if fn is NULL, 136 - DK4_E_BUFFER_TOO_SMALL<br> 137 if fn is too long, 138 - DK4_E_MATH_OVERFLOW<br> 139 if a mathematical overflow occured in size allocation, 140 - DK4_E_NOT_FOUND<br> 141 if a server/share combination is not present on Windows, 142 - DK4_E_NON_DIR<br> 143 if one of the components in fn is not a directory, 144 - DK4_E_MKDIR_FAILED<br> 145 with errno in idetails if the function fails to create the directory 146 or a parent directory, 147 - DK4_E_CHOWN_FAILED<br> 148 with errno value in iDetails1 if the chown() function failed on a 149 non-Windows system, 150 - DK4_E_CHMOD_FAILED<br> 151 with errno value in iDetails1 if the chmod() function failed on a 152 non-Windows system, 153 - DK4_E_CREATE_DIR_FAILED<br> 154 with GetLastError() result in lDetails1 if the CreateDirectory() 155 function failed on a Windows system. 156 */ 157 int 158 dk4mkdir_hierarchy_ugm_c8( 159 const char *fn, 160 int lc, 161 uid_t uid, 162 gid_t gid, 163 mode_t mode, 164 dk4_er_t *erp 165 ); 166 167 #endif 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 174 175 176 #endif 177