home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / RENAME.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.8 KB  |  65 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - rename.cas
  3.  *
  4.  * function(s)
  5.  *        rename - renames a file
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #pragma inline
  18. #include <asmrules.h>
  19. #include <stdio.h>
  20. #include <_io.h>
  21.  
  22. /*-----------------------------------------------------------------------*
  23.  
  24. Name            rename - renames a file
  25.  
  26. Usage           int rename(const char *oldname, const char *newname);
  27.  
  28. Prototype in    stdio.h
  29.  
  30. Description     rename changes the name of a file from oldname to
  31.                 newname. If a drive specifier is given in newname, the
  32.                 specifier must be the same as that given in oldname.
  33.  
  34.                 Directories in a path need not be the same, so rename can be
  35.                 used to move a file from one directory to another. Wildcards
  36.                 are not allowed.
  37.  
  38. Return value    On successfully renaming the file, rename returns
  39.                 0. In the event of error, -1 is returned, and errno is set
  40.                 to one of the following:
  41.  
  42.                         ENOENT  Path or file name not found
  43.                         EACCES  Permission denied
  44.                         ENOTSAM Not same device
  45.  
  46. *------------------------------------------------------------------------*/
  47.  
  48. int _CType _FARFUNC rename(const char _FAR *oldname, const char _FAR *newname)
  49. {
  50. #if !LDATA
  51.         _ES = _DS;
  52. #endif
  53.         pushDS_
  54. asm     mov     ah, 056h
  55. asm     LDS_    dx, oldname
  56. asm     LES_    di, newname
  57. asm     int     021H
  58.         popDS_
  59. asm     jc      renameFailed
  60.         return(0);
  61.  
  62. renameFailed:
  63.         return __IOerror(_AX);
  64. }
  65.