
{"id":18564,"date":"2010-01-11T17:33:44","date_gmt":"2010-01-11T17:33:44","guid":{"rendered":"http:\/\/froisa.com\/?p=251"},"modified":"2010-01-11T17:33:44","modified_gmt":"2010-01-11T17:33:44","slug":"mkdir-c-2","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2010\/01\/11\/mkdir-c-2\/","title":{"rendered":"Create the DIRECTORY(ies), if they do not already exist"},"content":{"rendered":"<h2><u>source code<\/u><\/h2>\n<pre class=\"brush:c\">\n\/* On some systems, mkdir (\"foo\/\", 0700) fails because of the trailing\n   slash.  On those systems, this wrapper removes the trailing slash.\n\n   Copyright (C) 2001, 2003 Free Software Foundation, Inc.\n\n   This program is free software; you can redistribute it and\/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; either version 3, or (at your option)\n   any later version.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software Foundation,\n   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  *\/\n\n\/* written by Jim Meyering *\/\n\n#ifdef HAVE_CONFIG_H\n# include config.h\n#endif\n\n\/* Disable the definition of mkdir to rpl_mkdir (from config.h) in this\n   file.  Otherwise, we'd get conflicting prototypes for rpl_mkdir on\n   most systems.  *\/\n#undef mkdir\n\n#include &lt;sys\/types.h&gt;\n#include &lt;sys\/stat.h&gt;\n#include  &lt;stdio.h&gt;\n#include  &lt;stdlib.h&gt;\n#include &lt;string.h&gt;\n\n#include \"dirname.h\"\n#include \"xalloc.h\"\n\n\/* This function is required at least for NetBSD 1.5.2.  *\/\n\nint\nrpl_mkdir (char const *dir, mode_t mode)\n{\n  int ret_val;\n  char *tmp_dir;\n  size_t len = strlen (dir);\n\n  if (len &amp;&amp; dir[len - 1] == '\/')\n    {\n      tmp_dir = xstrdup (dir);\n      strip_trailing_slashes (tmp_dir);\n    }\n  else\n    {\n      tmp_dir = (char *) dir;\n    }\n\n  ret_val = mkdir (tmp_dir, mode);\n\n  if (tmp_dir != dir)\n    free (tmp_dir);\n\n  return ret_val;\n}\n<\/pre>\n<p><a href=\"http:\/\/www.opengroup.org\/onlinepubs\/000095399\/functions\/mkdir.html\">http:\/\/www.opengroup.org\/onlinepubs\/000095399\/functions\/mkdir.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>source code \/* On some systems, mkdir (&#8220;foo\/&#8221;, 0700) fails because of the trailing slash. On those systems, this wrapper removes the trailing slash. Copyright (C) 2001, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and\/or modify it under the terms of the GNU General Public License as published &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2010\/01\/11\/mkdir-c-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Create the DIRECTORY(ies), if they do not already exist&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"page-templates\/full-width.php","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/18564"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=18564"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/18564\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=18564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=18564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=18564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}