home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------
- * filename - chdir.cas
- *
- * function(s)
- * chdir - changes working directory
- * getdisk - gets current drive
- * setdisk - sets current drive
- *--------------------------------------------------------------------------*/
-
- /*[]------------------------------------------------------------[]*/
- /*| |*/
- /*| 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 <dir.h>
- #include <_io.h>
-
- /*--------------------------------------------------------------------------*
-
- Name chdir - changes working directory
-
- Usage int chdir(const char *path);
-
- Prototype in dir.h
-
- Description causes the directory specified by path to become the
- current working directory.
-
- Return value success : 0
- failure : -1 and errno is set to ENOENT (Path or file
- name not found)
-
- *---------------------------------------------------------------------------*/
- int chdir(const char *pathP)
- {
- pushDS_
- asm mov ah, 03Bh
- asm LDS_ dx, pathP
- asm int 021H
- popDS_
- asm jc chdirFailed
-
- return(0);
-
- chdirFailed:
- return __IOerror(_AX);
- }
-
- /*--------------------------------------------------------------------------*
-
- Name getdisk - gets current drive
-
- Usage int getdisk(void);
-
- Prototype in dir.h
-
- Description gets the current drive.
-
- Return value 0 = A:, 1 = B:, 2 = C:; etc.
-
- *---------------------------------------------------------------------------*/
- int getdisk(void)
- {
- asm mov ah, 019h
- asm int 021h
- asm cbw
-
- return _AX;
- }
-
- /*--------------------------------------------------------------------------*
-
- Name setdisk - sets current drive
-
- Usage int setdisk(int drive);
-
- Prototype in dir.h
-
- Description sets the current drive.
- 0 = A:, 1 = B:, 2 = C:; etc.
-
- Return value the total number of drives available.
-
- *---------------------------------------------------------------------------*/
- int setdisk(int drive)
- {
- asm mov ah, 00Eh
- asm mov dl, drive
- asm int 021h
- asm cbw
-
- return _AX;
- }
-