1%% options 2 3copyright owner = Dirk Krause 4copyright year = 2015-xxxx 5SPDX-License-Identifier: BSD-3-Clause 6 7 8 9%% header 10 11/** @file 12 Make directory hierarchy (create all parent directories for a 13 file or directory and the directory itself if required), 14 the file or directory name is specified as dkChar string. 15*/ 16 17#ifndef DK4CONF_H_INCLUDED 18#if DK4_BUILDING_DKTOOLS4 19#include "dk4conf.h" 20#else 21#include <dktools-4/dk4conf.h> 22#endif 23#endif 24 25#ifndef DK4TYPES_H_INCLUDED 26#if DK4_BUILDING_DKTOOLS4 27#include <libdk4base/dk4types.h> 28#else 29#include <dktools-4/dk4types.h> 30#endif 31#endif 32 33#ifndef DK4ERROR_H_INCLUDED 34#if DK4_BUILDING_DKTOOLS4 35#include <libdk4base/dk4error.h> 36#else 37#include <dktools-4/dk4error.h> 38#endif 39#endif 40 41#ifdef __cplusplus 42extern "C" { 43#endif 44 45/** Create directory structure. 46 @param fn File name. 47 @param lc Flag: Last component in fn is directory too. 48 @param erp Error report, may be NULL. 49 @return 1 on success, 0 on error. 50 51 Error codes: 52 - DK4_E_INVALID_ARGUMENTS<br> 53 if fn is NULL, 54 - DK4_E_BUFFER_TOO_SMALL<br> 55 if fn is too long, 56 - DK4_E_NON_DIR<br> 57 if one of the components in fn is not a directory, 58 - DK4_E_MKDIR_FAILED<br> 59 with errno in idetails if the function fails to create the directory 60 or a parent directory, 61*/ 62int 63dk4mkdir_hierarchy(const dkChar *fn, int lc, dk4_er_t *erp); 64 65#ifdef __cplusplus 66} 67#endif 68 69 70 71%% module 72 73#include "dk4conf.h" 74#include <libdk4c/dk4mkdh.h> 75 76#if DK4_CHAR_SIZE > 1 77#ifndef DK4MKDHW_H_INCLUDED 78#include <libdk4c/dk4mkdhw.h> 79#endif 80#else 81#ifndef DK4MKDH8_H_INCLUDED 82#include <libdk4c/dk4mkdh8.h> 83#endif 84#endif 85 86#if DK4_HAVE_ASSERT_H 87#ifndef ASSERT_H_INCLUDED 88#include <assert.h> 89#define ASSERT_H_INCLUDED 1 90#endif 91#endif 92 93 94int 95dk4mkdir_hierarchy(const dkChar *fn, int lc, dk4_er_t *erp) 96{ 97#if DK4_USE_ASSERT 98 assert(NULL != fn); 99#endif 100#if DK4_CHAR_SIZE > 1 101 return (dk4mkdir_hierarchy_wc(fn, lc, erp)); 102#else 103 return (dk4mkdir_hierarchy_c8(fn, lc, erp)); 104#endif 105} 106 107