
{"id":342,"date":"2010-01-15T17:59:18","date_gmt":"2010-01-15T17:59:18","guid":{"rendered":"http:\/\/froisa.com\/?p=342"},"modified":"2010-01-15T17:59:18","modified_gmt":"2010-01-15T17:59:18","slug":"rename-c","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2010\/01\/15\/rename-c\/","title":{"rendered":"rename.c"},"content":{"rendered":"<pre class=\"brush:c\">\n\/* Work around the bug in some systems whereby rename fails when the source\n   file has a trailing slash.  The rename functions of SunOS 4.1.1_U1 and\n   mips-dec-ultrix4.4 have this bug.\n   Copyright (C) 2001, 2002, 2003, 2005 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 Volker Borchert *\/\n\n#ifdef HAVE_CONFIG_H\n# include &lt;config.h&gt;\n#endif\n#undef rename\n\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\/* Rename the file SRC to DST, removing any trailing\n   slashes from SRC.  Needed for SunOS 4.1.1_U1.  *\/\n\nint\nrpl_rename (char const *src, char const *dst)\n{\n  char *src_temp;\n  int ret_val;\n  size_t s_len = strlen (src);\n\n  if (s_len &amp;&amp; src[s_len - 1] == '\/')\n    {\n      src_temp = xstrdup (src);\n      strip_trailing_slashes (src_temp);\n    }\n  else\n    src_temp = (char *) src;\n\n  ret_val = rename (src_temp, dst);\n\n  if (src_temp != src)\n    free (src_temp);\n\n  return ret_val;\n}\n<\/pre>\n<p><a href=\"http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/strdup.html\"> http:\/\/www.opengroup.org\/onlinepubs\/009695399\/functions\/strdup.html<\/a><br \/>\n<a href=\"http:\/\/en.wikipedia.org\/wiki\/SunOS\"> http:\/\/en.wikipedia.org\/wiki\/SunOS<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* Work around the bug in some systems whereby rename fails when the source file has a trailing slash. The rename functions of SunOS 4.1.1_U1 and mips-dec-ultrix4.4 have this bug. Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and\/or modify it under the terms &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2010\/01\/15\/rename-c\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;rename.c&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[1701],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/342"}],"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=342"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/342\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}