Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #138995
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | rbowman <bowman@montana.com> |
| Newsgroups | comp.lang.c |
| Subject | Re: file system lib for C |
| Date | Sun, 23 Dec 2018 13:38:35 -0700 |
| Lines | 31 |
| Message-ID | <g8a9vsFplqbU1@mid.individual.net> (permalink) |
| References | <2156f362-0d1f-4e41-bbd9-bcc27344fe56@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net P34U/uguJwGZcbPg7DBJpgeLAGbl6QXA5Rl5TAIGjrHPy4NI0g |
| Cancel-Lock | sha1:JUrwgJFBLJA5SsIma3QqHr9Zfmg= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 |
| In-Reply-To | <2156f362-0d1f-4e41-bbd9-bcc27344fe56@googlegroups.com> |
| Xref | csiph.com comp.lang.c:138995 |
Show key headers only | View raw
On 12/23/2018 11:12 AM, Thiago Adams wrote:
> bool create_directory( const std::filesystem::path& p, std::error_code& ec ) noexcept;
>
> I don't think error_code deserves a exactly copy
> https://en.cppreference.com/w/cpp/error/error_code
> because it is too complicated.
>
> Suggestions how to adapt this for C and contributions/critics
> are welcome.
>
I'm not sure I understand your question but
#include <errno.h>
#include <string.h>
................
if (mkdir(path, mode) == -1) {
fprintf(stderr, "mkdir failed: %s\n", strerror(errno));
/* do whatever error recovery you need */
}
Check the man pages for the appropriate return. Ones that return an int
like mkdir() typically return -1 for an error condition. Those like
fopen() which return a FILE* return a null.
The <string.h> include is for strerror() which returns a descriptive
string. That's generally more useful than 'the error was 23'.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
file system lib for C Thiago Adams <thiago.adams@gmail.com> - 2018-12-23 10:12 -0800
Re: file system lib for C Clark Smith <noaddress@nowhere.net> - 2018-12-23 20:20 +0000
Re: file system lib for C James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-23 16:41 -0500
Re: file system lib for C Thiago Adams <thiago.adams@gmail.com> - 2018-12-30 10:33 -0800
Re: file system lib for C nobody@example.org (Scott) - 2018-12-30 20:42 +0000
Re: file system lib for C Thiago Adams <thiago.adams@gmail.com> - 2018-12-30 12:52 -0800
Re: file system lib for C rbowman <bowman@montana.com> - 2018-12-23 13:38 -0700
Re: file system lib for C Keith Thompson <kst-u@mib.org> - 2018-12-23 13:39 -0800
Re: file system lib for C Thiago Adams <thiago.adams@gmail.com> - 2018-12-30 11:09 -0800
Re: file system lib for C "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-30 14:59 -0800
Re: file system lib for C rbowman <bowman@montana.com> - 2018-12-30 16:09 -0700
Re: file system lib for C nobody@example.org (Scott) - 2018-12-23 20:51 +0000
Re: file system lib for C jgh@mdfs.net - 2018-12-30 09:15 -0800
Re: file system lib for C Thiago Adams <thiago.adams@gmail.com> - 2018-12-30 10:34 -0800
csiph-web