home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name drcurdir -- Return the current directory path on a given
- * disk drive.
- *
- * Synopsis ercode = drcurdir(drive,pdir);
- *
- * int ercode DOS function return code
- * int drive Disk drive (0 = default, 1 = A:, etc.)
- * char *pdir Directory path of current directory
- *
- * Description This function returns the full path name (starting from
- * the root directory) of the current directory for the
- * specified drive. The returned path name begins with the
- * drive specification and a backslash character ('\\').
- *
- * The calling function must allocate sufficient space for
- * the returned full path name. Because the path can be 64
- * characters (including the trailing null byte), at least
- * MAX_FLEN bytes should be allocated by the calling
- * function for pdir. (MAX_FLEN is defined in BFILE.H.)
- *
- * Returns ercode DOS function error code
- * *pdir The full path name of the current directory
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- **/
-
- #include <string.h>
-
- #include <bdirect.h>
- #include <butility.h>
-
- int drcurdir(drive,pdir)
- int drive;
- char *pdir;
- {
- DOSREG dos_reg;
- int ercode,cur_drive;
- char path[65];
- ADS path_ads;
-
- dos_reg.ax = 0x4700; /* DOS function 0x47 returns */
- dos_reg.dx = (unsigned)drive; /* path (without drive */
- utabsptr(path,&path_ads); /* specifier) */
- dos_reg.ds = path_ads.s;
- dos_reg.si = path_ads.r;
-
- ercode = dos(&dos_reg);
-
- if (ercode == 0)
- { /* Add the drive specifier. */
- if (drive == 0)
- cur_drive = drretdrv(); /* Default drive. Which drive? */
- else
- cur_drive = drive - 1;
- *pdir = (char)(cur_drive + 'A');/* First char is drive letter*/
- pdir[1] = '\0'; /* Now set to concatenate */
- strcat(pdir,":\\");
- strcat(pdir,path);
- }
-
- return(ercode);
- }