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: dk4getcwd8.ctr 12 */ 13 14 #ifndef DK4GETCWD8_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4GETCWD8_H_INCLUDED 1 17 18 19 /** @file dk4getcwd8.h Get current working directory as char string. 20 */ 21 22 #ifndef DK4CONF_H_INCLUDED 23 #if DK4_BUILDING_DKTOOLS4 24 #include "dk4conf.h" 25 #else 26 #include <dktools-4/dk4conf.h> 27 #endif 28 #endif 29 30 #ifndef DK4ERROR_H_INCLUDED 31 #if DK4_BUILDING_DKTOOLS4 32 #include <libdk4base/dk4error.h> 33 #else 34 #include <dktools-4/dk4error.h> 35 #endif 36 #endif 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /** Find current working directory. 43 @param dptr Destination buffer pointer. 44 @param sz Buffer size. 45 @param erp Error report, may be NULL. 46 @return 1 on success, 0 on error. 47 48 Error codes: 49 - DK4_E_INVALID_ARGUMENTS<br> 50 if dptr is NULL or sz is 0, 51 - DK4_E_SYSTEM<br> 52 with errno in iDetails if getcwd() or _getcwd() failed 53 or GetLastError() result in iDetails if GetCurrentDirectoryA() 54 failed. 55 */ 56 int 57 dk4getcwd_c8(char *dptr, size_t sz, dk4_er_t *erp); 58 59 /** Find current working directory, return string in newly 60 allocated memory. 61 @param erp Error report, may be NULL. 62 @return Valid pointer to newly allocated memory containing 63 the directory name on success, NULL on error. 64 On success, use dk4mem_free() to release the memory when done 65 with it. 66 67 Error codes: 68 - DK4_E_SYSTEM<br> 69 with errno in iDetails if getcwd() or _getcwd() failed 70 or GetLastError() result in iDetails if GetCurrentDirectoryA() 71 failed. 72 - DK4_E_MATH_OVERFLOW<br> 73 on mathematical overflow in size calculation, 74 - DK4_E_MEMORY<br> 75 if no memory is available. 76 */ 77 char * 78 dk4getcwd_c8_dup(dk4_er_t *erp); 79 80 #ifdef __cplusplus 81 } 82 #endif 83 84 85 #endif 86