home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / ansi / stdio / rename.txh < prev    next >
Encoding:
Text File  |  1996-08-31  |  3.0 KB  |  82 lines

  1. @node rename, file system
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <stdio.h>
  6.  
  7. int rename(const char *oldname, const char *newname);
  8. @end example
  9.  
  10. @subheading Description
  11.  
  12. This function renames an existing file or directory @var{oldname} to
  13. @var{newname}.  If @var{newname} exists, then it is first removed.  If
  14. @var{newname} is a directory, it must be empty (or else @var{errno} will
  15. be set to @code{ENOTEMPTY}), and must not include @var{oldname} in its
  16. path prefix (otherwise, @var{errno} will be set to @code{EINVAL}).  If
  17. @var{newname} exists, both @var{oldname} and @var{newname} must be of the
  18. same type (both directories or both regular files) (or else @var{errno}
  19. will be set to @code{ENOTDIR} or @code{EISDIR}), and must reside on the
  20. same logical device (otherwise, @var{errno} will be set to @code{EXDEV}). 
  21. Wildcards are not allowed in either @var{oldname} or @var{newname}.  DOS
  22. won't allow renaming a current directory even on a non-default drive (you
  23. will get the @code{EBUSY} or @code{EINVAL} in @var{errno}).
  24. @code{ENAMETOOLONG} will be returned for pathnames which are longer than
  25. the limit imposed by DOS.  If @var{oldname} doesn't exist, @var{errno}
  26. will be set to @code{ENOENT}.  For most of the other calamities, DOS will
  27. usually set @var{errno} to @code{EACCES}.
  28.  
  29. If anything goes wrong during the operation of @code{rename()}, the
  30. function tries very hard to leave the things as ther were before it was
  31. invoked, but it might not always succeed.
  32.  
  33. @subheading Return Value
  34.  
  35. Zero on success, nonzero on failure.
  36.  
  37. @subheading Example
  38.  
  39. @example
  40. rename("c:/mydir/some.doc", "c:/yourdir/some.sav");
  41. rename("c:/path1/mydir", "c:/path2");
  42. @end example
  43.  
  44. @c -------------------------------------------------------------------------
  45.  
  46. @node _rename, file system
  47. @subheading Syntax
  48.  
  49. @example
  50. #include <stdio.h>
  51.  
  52. int _rename(const char *oldname, const char *newname);
  53. @end example
  54.  
  55. @subheading Description
  56.  
  57. This function renames an existing file or directory @var{oldname} to
  58. @var{newname}.  It is much smaller that @code{rename} (@pxref{rename}),
  59. but it can only rename a directory so it stays under the same perent, it
  60. cannot move directories between different branches of the directory
  61. tree.  This means that in the following example, the first call will
  62. succeed, while the second will fail:
  63.  
  64. @example
  65. _rename("c:/path1/mydir", "c:/path1/yourdir");
  66. _rename("c:/path1/mydir", "c:/path2");
  67. @end example
  68.  
  69. On systems that support long filenames (@pxref{_use_lfn}),
  70. @code{_rename} can also move directories (so that both calls in the
  71. above example succeed there), unless the @samp{LFN} environment variable
  72. is set to @kbd{n}, or the @code{_CRT0_FLAG_NO_LFN} is set in the
  73. @code{_crt0_startup_flags} variable, @xref{_crt0_startup_flags}.
  74.  
  75. If you don't need the extra functionality offered by @code{rename}
  76. (which usually is only expected by Unix-born programs), you can use
  77. @code{_rename} instead and thus make your program a lot smaller.
  78.  
  79. @subheading Return Value
  80.  
  81. Zero on success, nonzero on failure.
  82.