Annotation of GNUtools/libg++/libiberty/rename.c, revision 1.1

1.1     ! root        1: /* rename -- rename a file
        !             2:    Copyright (C) 1992 Free Software Foundation, Inc.
        !             3: 
        !             4: This file is part of the libiberty library.
        !             5: Libiberty is free software; you can redistribute it and/or
        !             6: modify it under the terms of the GNU Library General Public
        !             7: License as published by the Free Software Foundation; either
        !             8: version 2 of the License, or (at your option) any later version.
        !             9: 
        !            10: Libiberty is distributed in the hope that it will be useful,
        !            11: but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
        !            13: Library General Public License for more details.
        !            14: 
        !            15: You should have received a copy of the GNU Library General Public
        !            16: License along with libiberty; see the file COPYING.LIB.  If
        !            17: not, write to the Free Software Foundation, Inc., 675 Mass Ave,
        !            18: Cambridge, MA 02139, USA.  */
        !            19: 
        !            20: /* Rename a file.  */
        !            21: 
        !            22: #include <errno.h>
        !            23: 
        !            24: int
        !            25: rename (zfrom, zto)
        !            26:      char *zfrom;
        !            27:      char *zto;
        !            28: {
        !            29:   if (link (zfrom, zto) < 0)
        !            30:     {
        !            31:       if (errno != EEXIST)
        !            32:        return -1;
        !            33:       if (unlink (zto) < 0
        !            34:          || link (zfrom, zto) < 0)
        !            35:        return -1;
        !            36:     }
        !            37:   return unlink (zfrom);
        !            38: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.