Added MORE command.
[reactos.git] / rosapps / cmd / vol.c
1 /*
2 * VOL.C - vol internal command.
3 *
4 *
5 * History:
6 *
7 * 03-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
8 * Replaced DOS calls by Win32 calls.
9 *
10 * 08-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
11 * Added help text ("/?").
12 *
13 * 07-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
14 * Cleanup.
15 *
16 * 18-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
17 * Unicode ready!
18 *
19 * 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
20 * Redirection ready!
21 */
22
23 #include "config.h"
24
25 #ifdef INCLUDE_CMD_VOL
26
27 #include <windows.h>
28 #include <tchar.h>
29 #include <string.h>
30
31 #include "cmd.h"
32
33
34 static INT
35 PrintVolumeHeader (LPTSTR pszRootPath)
36 {
37 TCHAR szVolName[80];
38 DWORD dwSerialNr;
39
40 /* get the volume information of the drive */
41 if(!GetVolumeInformation (pszRootPath, szVolName, 80, &dwSerialNr,
42 NULL, NULL, NULL, 0))
43 {
44 ErrorMessage (GetLastError (), _T(""));
45 return 1;
46 }
47
48 /* print drive info */
49 ConOutPrintf (_T(" Volume in drive %c:"), pszRootPath[0]);
50
51 if (szVolName[0] != '\0')
52 ConOutPrintf (_T(" is %s\n"), szVolName);
53 else
54 ConOutPrintf (_T(" has no label\n"));
55
56 /* print the volume serial number */
57 ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
58 HIWORD(dwSerialNr), LOWORD(dwSerialNr));
59 return 0;
60 }
61
62
63 INT cmd_vol (LPTSTR cmd, LPTSTR param)
64 {
65 TCHAR szRootPath[] = _T("A:\\");
66 TCHAR szPath[MAX_PATH];
67
68 if (!_tcsncmp (param, _T("/?"), 2))
69 {
70 ConOutPuts (_T("Displays the disk volume label and serial number, if they exist.\n\n"
71 "VOL [drive:]"));
72 return 0;
73 }
74
75 if (param[0] == _T('\0'))
76 {
77 GetCurrentDirectory (MAX_PATH, szPath);
78 szRootPath[0] = szPath[0];
79 }
80 else
81 {
82 _tcsupr (param);
83 if (param[1] == _T(':'))
84 szRootPath[0] = param[0];
85 else
86 {
87 error_invalid_drive ();
88 return 1;
89 }
90 }
91
92 if (!IsValidPathName (szRootPath))
93 {
94 error_invalid_drive ();
95 return 1;
96 }
97
98 /* print the header */
99 if (!PrintVolumeHeader (szRootPath))
100 return 1;
101
102 return 0;
103 }
104
105 #endif