home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / RENAME.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  2.2 KB  |  65 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - rename.cas
  3.  *
  4.  * function(s)
  5.  *        rename - renames a file
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18. #pragma inline
  19. #include <asmrules.h>
  20. #include <stdio.h>
  21. #include <_io.h>
  22.  
  23. /*-----------------------------------------------------------------------*
  24.  
  25. Name            rename - renames a file
  26.  
  27. Usage           int rename(const char *oldname, const char *newname);
  28.  
  29. Prototype in    stdio.h
  30.  
  31. Description     rename changes the name of a file from oldname to
  32.                 newname. If a drive specifier is given in newname, the
  33.         specifier must be the same as that given in oldname.
  34.  
  35.                 Directories in a path need not be the same, so rename can be
  36.                 used to move a file from one directory to another. Wildcards
  37.                 are not allowed.
  38.  
  39. Return value    On successfully renaming the file, rename returns
  40.                 0. In the event of error, -1 is returned, and errno is set
  41.                 to one of the following:
  42.  
  43.                         ENOENT  Path or file name not found
  44.                         EACCES  Permission denied
  45.                         ENOTSAM Not same device
  46.  
  47. *------------------------------------------------------------------------*/
  48. int rename(const char *oldname, const char *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.