home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name drretvol -- Return the volume label on a given
- * disk drive.
- *
- * Synopsis ercode = drretvol(drive,pvol,pfdate,pftime);
- *
- * int ercode 1 if error or no label, 0 if okay.
- * int drive Disk drive (0 = default, 1 = A:, etc.)
- * char *pvol Pointer to character buffer in which
- * to put volume name (if found). This
- * must allow space for 11 bytes plus the
- * trailing NUL ('\0').
- * unsigned *pfdate Pointer to returned date stamp
- * unsigned *pftime Pointer to returned time stamp
- *
- * Description This function returns the volume label (if any) on a
- * given disk drive as well as the label's creation date
- * and time. The volume label (if found) is always
- * returned as an 11-character string. It may contain
- * blanks or other characters which are ordinarily illegal
- * in DOS filenames.
- *
- * The date and time are represented as 16-bit quantities
- * in the following format:
- *
- * ********** bits ***********
- * 1 1 1 1 1 1
- * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- *
- * y y y y y y y m m m m d d d d d = fdate
- *
- * h h h h h m m m m m m s s s s s = ftime
- *
- * where the year bits represent 0 - 119 (1980 to 2099) and
- * the second bits represent two-second increments. This
- * is the same format used by DRRETSTP, DRSETSTP, DRSFIRST,
- * and DRSNEXT.
- *
- * Use DRSTP2DT and DRSTP2TM to split the time and date
- * stamps into year, month, day, etc.
- *
- * Returns ercode 1 if error or no label, 0 if okay.
- * *pvol Volume name.
- * *pfdate Returned date stamp
- * *pftime Returned time stamp
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- * Version 3.02 March 24, 1987
- * Removed a strong typing warning (no change in object
- * code).
- *
- **/
-
- #include <bdirect.h>
- #include <bfile.h>
-
- int drretvol(drive,pvol,pfdate,pftime)
- int drive;
- char *pvol;
- unsigned *pfdate,*pftime;
- {
- DOSREG dos_reg;
- char local_dta[39];
- ADS old_dta_ads,ldta_ads,xfcb_ads;
- char xfcb[44];
- register int i;
- int result;
-
- #define fcb (xfcb + 7)
- #define found_fcb (local_dta + 7)
-
- flretdta(&old_dta_ads); /* Save former Data Transfer */
- /* Address. */
- utabsptr(local_dta,&ldta_ads);
- flsetdta(&ldta_ads); /* Select local DTA. */
-
- for (i = 0; i < 44; i++) /* Clear entire Extended FCB */
- xfcb[i] = 0;
- fcb[-7] = (char) 0xff; /* Mark this as an Extended FCB */
- fcb[-1] = AT_VOLUME; /* Select volume attribute. */
- fcb[0] = (char) drive;
- for (i = 1; i <= 11; i++) /* Search for "????????.???" */
- fcb[i] = '?';
-
- dos_reg.ax = 0x1100; /* DOS function 0x11: search */
- utabsptr(xfcb,&xfcb_ads); /* for first matching entry. */
- dos_reg.ds = xfcb_ads.s;
- dos_reg.dx = xfcb_ads.r;
- dos(&dos_reg);
-
- if (utlobyte(dos_reg.ax) == 0)
- { /* Found a volume label. */
- for (i = 1; i <= 11; i++)
- *pvol++ = found_fcb[i];
- *pvol = '\0';
- *pftime = *((unsigned *) &(found_fcb[23]));
- *pfdate = *((unsigned *) &(found_fcb[25]));
- result = 0;
- }
- else
- { /* No volume label found. */
- *pvol = '\0';
- *pfdate =
- *pftime = 0;
- result = 1;
- }
-
- flsetdta(&old_dta_ads); /* Restore former DTA. */
-
- return result;
- }