Copy wininet to branch
[reactos.git] / reactos / subsys / system / 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 "precomp.h"
24
25 #ifdef INCLUDE_CMD_VOL
26
27
28 static INT
29 PrintVolumeHeader (LPTSTR pszRootPath)
30 {
31 TCHAR szVolName[80];
32 DWORD dwSerialNr;
33
34 /* get the volume information of the drive */
35 if(!GetVolumeInformation (pszRootPath,
36 szVolName,
37 80,
38 &dwSerialNr,
39 NULL,
40 NULL,
41 NULL,
42 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"),
53 szVolName);
54 else
55 ConOutPrintf (_T(" has no label\n"));
56
57 /* print the volume serial number */
58 ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
59 HIWORD(dwSerialNr),
60 LOWORD(dwSerialNr));
61 return 0;
62 }
63
64
65 INT cmd_vol (LPTSTR cmd, LPTSTR param)
66 {
67 TCHAR szRootPath[] = _T("A:\\");
68 TCHAR szPath[MAX_PATH];
69
70 if (!_tcsncmp (param, _T("/?"), 2))
71 {
72 ConOutPuts (_T("Displays the disk volume label and serial number, if they exist.\n\n"
73 "VOL [drive:]"));
74 return 0;
75 }
76
77 if (param[0] == _T('\0'))
78 {
79 GetCurrentDirectory (MAX_PATH, szPath);
80 szRootPath[0] = szPath[0];
81 }
82 else
83 {
84 _tcsupr (param);
85 if (param[1] == _T(':'))
86 szRootPath[0] = param[0];
87 else
88 {
89 error_invalid_drive ();
90 return 1;
91 }
92 }
93
94 if (!IsValidPathName (szRootPath))
95 {
96 error_invalid_drive ();
97 return 1;
98 }
99
100 /* print the header */
101 if (!PrintVolumeHeader (szRootPath))
102 return 1;
103
104 return 0;
105 }
106
107 #endif