diff options
author | midipix <writeonce@midipix.org> | 2016-05-03 12:42:43 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-05-03 12:42:43 -0400 |
commit | 3895afa953a49e842fa99fa08842268d6f58aae9 (patch) | |
tree | 11038948722193d6edf0207f2e4dbf8636c1e470 /src/internal/slibtool_mkdir_impl.h | |
parent | 77a4b7c9b9108b8af21b3bb1ad5efb3249c55821 (diff) | |
download | slibtool-3895afa953a49e842fa99fa08842268d6f58aae9.tar.bz2 slibtool-3895afa953a49e842fa99fa08842268d6f58aae9.tar.xz |
internals: slbt_mkdir(): initial implementation and integration.
Diffstat (limited to 'src/internal/slibtool_mkdir_impl.h')
-rw-r--r-- | src/internal/slibtool_mkdir_impl.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/internal/slibtool_mkdir_impl.h b/src/internal/slibtool_mkdir_impl.h new file mode 100644 index 0000000..9be237b --- /dev/null +++ b/src/internal/slibtool_mkdir_impl.h @@ -0,0 +1,25 @@ +/*******************************************************************/ +/* slibtool: a skinny libtool implementation, written in C */ +/* Copyright (C) 2016 Z. Gilboa */ +/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */ +/*******************************************************************/ + +#include <errno.h> +#include <unistd.h> + +#ifndef O_DIRECTORY +#define O_DIRECTORY 0 +#endif + +static inline int slbt_mkdir(const char * path) +{ + int fdlibs; + + if ((fdlibs = open(path,O_DIRECTORY)) >= 0) + close(fdlibs); + else if ((errno != ENOENT) || mkdir(path,0777)) + if (errno != EEXIST) + return -1; + + return 0; +} |