Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: file system lib for C Date: Sun, 23 Dec 2018 13:39:06 -0800 Organization: None to speak of Lines: 33 Message-ID: References: <2156f362-0d1f-4e41-bbd9-bcc27344fe56@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader01.eternal-september.org; posting-host="2f7fe63fc186ce2b6b28d678feefa8a5"; logging-data="20104"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182wXVPr+5AFgXyr0ae2PlY" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:VIOx5cuwdnrj94wXut14KohUqXk= sha1:9XG3tgt+BMDYw3zGybfPb1vc/44= Xref: csiph.com comp.lang.c:138999 rbowman writes: > 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 > #include > ................ > if (mkdir(path, mode) == -1) { > fprintf(stderr, "mkdir failed: %s\n", strerror(errno)); > /* do whatever error recovery you need */ > } mkdir() requires `#include `, which is POSIX-specific and not part of the C standard. C++'s std::filesystem (new in C++17) is, I think, intended to be more general. [...] -- Keith Thompson (The_Other_Keith) kst@mib.org Will write code for food. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"