OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdio/] [rename.c] - Diff between revs 1010 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 1010 Rev 1765
/*
/*
FUNCTION
FUNCTION
<<rename>>---rename a file
<<rename>>---rename a file
 
 
INDEX
INDEX
        rename
        rename
INDEX
INDEX
        _rename_r
        _rename_r
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <stdio.h>
        #include <stdio.h>
        int rename(const char *<[old]>, const char *<[new]>);
        int rename(const char *<[old]>, const char *<[new]>);
 
 
        int _rename_r(void *<[reent]>,
        int _rename_r(void *<[reent]>,
                      const char *<[old]>, const char *<[new]>);
                      const char *<[old]>, const char *<[new]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <stdio.h>
        #include <stdio.h>
        int rename(<[old]>, <[new]>)
        int rename(<[old]>, <[new]>)
        char *<[old]>;
        char *<[old]>;
        char *<[new]>;
        char *<[new]>;
 
 
        int _rename_r(<[reent]>, <[old]>, <[new]>)
        int _rename_r(<[reent]>, <[old]>, <[new]>)
        char *<[reent]>;
        char *<[reent]>;
        char *<[old]>;
        char *<[old]>;
        char *<[new]>;
        char *<[new]>;
 
 
DESCRIPTION
DESCRIPTION
Use <<rename>> to establish a new name (the string at <[new]>) for a
Use <<rename>> to establish a new name (the string at <[new]>) for a
file now known by the string at <[old]>.  After a successful
file now known by the string at <[old]>.  After a successful
<<rename>>, the file is no longer accessible by the string at <[old]>.
<<rename>>, the file is no longer accessible by the string at <[old]>.
 
 
If <<rename>> fails, the file named <<*<[old]>>> is unaffected.  The
If <<rename>> fails, the file named <<*<[old]>>> is unaffected.  The
conditions for failure depend on the host operating system.
conditions for failure depend on the host operating system.
 
 
The alternate function <<_rename_r>> is a reentrant version.  The
The alternate function <<_rename_r>> is a reentrant version.  The
extra argument <[reent]> is a pointer to a reentrancy structure.
extra argument <[reent]> is a pointer to a reentrancy structure.
 
 
RETURNS
RETURNS
The result is either <<0>> (when successful) or <<-1>> (when the file
The result is either <<0>> (when successful) or <<-1>> (when the file
could not be renamed).
could not be renamed).
 
 
PORTABILITY
PORTABILITY
ANSI C requires <<rename>>, but only specifies that the result on
ANSI C requires <<rename>>, but only specifies that the result on
failure be nonzero.  The effects of using the name of an existing file
failure be nonzero.  The effects of using the name of an existing file
as <<*<[new]>>> may vary from one implementation to another.
as <<*<[new]>>> may vary from one implementation to another.
 
 
Supporting OS subroutines required: <<link>>, <<unlink>>, or <<rename>>.
Supporting OS subroutines required: <<link>>, <<unlink>>, or <<rename>>.
*/
*/
 
 
#include <stdio.h>
#include <stdio.h>
#include <sys/unistd.h>
#include <sys/unistd.h>
#include <reent.h>
#include <reent.h>
 
 
int
int
_rename_r (ptr, old, new)
_rename_r (ptr, old, new)
     struct _reent *ptr;
     struct _reent *ptr;
     _CONST char *old;
     _CONST char *old;
     _CONST char *new;
     _CONST char *new;
{
{
#ifdef HAVE_RENAME
#ifdef HAVE_RENAME
  return _rename (old,new);
  return _rename (old,new);
#else
#else
  if (_link_r (ptr, old, new) == -1)
  if (_link_r (ptr, old, new) == -1)
    return -1;
    return -1;
 
 
  if (_unlink_r (ptr, old) == -1)
  if (_unlink_r (ptr, old) == -1)
    {
    {
      /* ??? Should we unlink new? (rhetorical question) */
      /* ??? Should we unlink new? (rhetorical question) */
      return -1;
      return -1;
    }
    }
#endif
#endif
  return 0;
  return 0;
}
}
 
 
#ifndef _REENT_ONLY
#ifndef _REENT_ONLY
 
 
int
int
rename (old, new)
rename (old, new)
     _CONST char *old;
     _CONST char *old;
     _CONST char *new;
     _CONST char *new;
{
{
  return _rename_r (_REENT, old, new);
  return _rename_r (_REENT, old, new);
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.