home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name FLRETVOL -- Return the volume label on a given
- * disk drive.
- *
- * Synopsis ercode = flretvol (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 = *pfdate
- *
- * h h h h h m m m m m m s s s s s = *pftime
- *
- * 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 the DOS disk directory.
- *
- * Returns ercode 1 if error or no label, 0 if okay.
- * *pvol Volume name.
- * *pfdate Returned date stamp
- * *pftime Returned time stamp
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1986, 1987, 1989
- *
- **/
-
- #include <dos.h>
-
- #include <bfiles.h>
-
- #define fcb (xfcb + 7)
- #define found_fcb (local_dta + 7)
-
- int flretvol (drive, pvol, pfdate, pftime)
- int drive;
- char *pvol;
- unsigned *pfdate, *pftime;
- {
- union REGS regs;
- struct SREGS sregs;
- unsigned char local_dta[44], xfcb[44];
- register int i;
- int result;
- void far *pold_dta;
-
- /* Save former Data Transfer Address. */
- pold_dta = flgetdta ();
- /* Select local DTA. */
- flputdta ((void far *) local_dta);
-
- /* Clear entire Extended FCB */
- for (i = 0; i < 44; i++)
- xfcb[i] = 0;
-
- /* Mark this as an Extended FCB */
- fcb[-7] = 0xff;
- /* Select volume attribute. */
- fcb[-1] = AT_VOLUME;
- fcb[0] = (char) drive;
-
- /* Search for "????????.???" */
- for (i = 1; i <= 11; i++)
- fcb[i] = '?';
-
- /* Set up for DOS function 0x11: search for first */
- /* matching entry. */
- regs.x.ax = 0x1100;
- sregs.ds = utseg (xfcb);
- regs.x.dx = utoff (xfcb);
-
- /* Go do the search. */
- int86x (FL_DOS_INT, ®s,®s,&sregs);
-
- if (regs.h.al == 0)
- { /* Found a volume label -- copy name to *pvol. */
- for (i = 1; i <= 11; i++)
- *pvol++ = found_fcb[i];
- *pvol = '\0';
-
- /* Copy time and date stamps. */
- *pftime = *((unsigned *) &(found_fcb[23]));
- *pfdate = *((unsigned *) &(found_fcb[25]));
-
- result = 0;
- }
-
- else
- { /* No volume label found. */
- *pvol = '\0';
- *pfdate = 0;
- *pftime = 0;
- result = 1;
- }
-
- /* Restore former DTA. */
- flputdta (pold_dta);
-
- return (result);
- }