Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #138995
| From | rbowman <bowman@montana.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: file system lib for C |
| Date | 2018-12-23 13:38 -0700 |
| Message-ID | <g8a9vsFplqbU1@mid.individual.net> (permalink) |
| References | <2156f362-0d1f-4e41-bbd9-bcc27344fe56@googlegroups.com> |
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