home *** CD-ROM | disk | FTP | other *** search
- /*-----------------------------------------------------------------------*
- * filename - rename.cas
- *
- * function(s)
- * rename - renames a file
- *-----------------------------------------------------------------------*/
-
- /*[]------------------------------------------------------------[]*/
- /*| |*/
- /*| Turbo C Run Time Library - Version 3.0 |*/
- /*| |*/
- /*| |*/
- /*| Copyright (c) 1987,1988,1990 by Borland International |*/
- /*| All Rights Reserved. |*/
- /*| |*/
- /*[]------------------------------------------------------------[]*/
-
- #pragma inline
- #include <asmrules.h>
- #include <stdio.h>
- #include <_io.h>
-
- /*-----------------------------------------------------------------------*
-
- Name rename - renames a file
-
- Usage int rename(const char *oldname, const char *newname);
-
- Prototype in stdio.h
-
- Description rename changes the name of a file from oldname to
- newname. If a drive specifier is given in newname, the
- specifier must be the same as that given in oldname.
-
- Directories in a path need not be the same, so rename can be
- used to move a file from one directory to another. Wildcards
- are not allowed.
-
- Return value On successfully renaming the file, rename returns
- 0. In the event of error, -1 is returned, and errno is set
- to one of the following:
-
- ENOENT Path or file name not found
- EACCES Permission denied
- ENOTSAM Not same device
-
- *------------------------------------------------------------------------*/
- int rename(const char *oldname, const char *newname)
- {
- #if !LDATA
- _ES = _DS;
- #endif
- pushDS_
- asm mov ah, 056h
- asm LDS_ dx, oldname
- asm LES_ di, newname
- asm int 021H
- popDS_
- asm jc renameFailed
- return(0);
-
- renameFailed:
- return __IOerror(_AX);
- }
-