7956442ccb0dcc7079e72f0aa9d186edbb9692a1
[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 #include "resource.h"
25
26 #ifdef INCLUDE_CMD_VOL
27
28
29 static INT
30 PrintVolumeHeader (LPTSTR pszRootPath)
31 {
32 TCHAR szMsg[RC_STRING_MAX_SIZE];
33 TCHAR szVolName[80];
34 DWORD dwSerialNr;
35
36 /* get the volume information of the drive */
37 if(!GetVolumeInformation (pszRootPath,
38 szVolName,
39 80,
40 &dwSerialNr,
41 NULL,
42 NULL,
43 NULL,
44 0))
45 {
46 ErrorMessage (GetLastError (), _T(""));
47 return 1;
48 }
49
50 /* print drive info */
51 if (szVolName[0] != '\0')
52 {
53 LoadString(CMD_ModuleHandle, STRING_VOL_HELP1, szMsg, RC_STRING_MAX_SIZE);
54 ConOutPrintf(szMsg, pszRootPath[0],szVolName);
55 }
56 else
57 {
58 LoadString(CMD_ModuleHandle, STRING_VOL_HELP2, szMsg, RC_STRING_MAX_SIZE);
59 ConOutPrintf(szMsg, pszRootPath[0]);
60 }
61
62 /* print the volume serial number */
63 LoadString(CMD_ModuleHandle, STRING_VOL_HELP3, szMsg, RC_STRING_MAX_SIZE);
64 ConOutPrintf(szMsg, HIWORD(dwSerialNr), LOWORD(dwSerialNr));
65 return 0;
66 }
67
68
69 INT cmd_vol (LPTSTR cmd, LPTSTR param)
70 {
71 TCHAR szRootPath[] = _T("A:\\");
72 TCHAR szPath[MAX_PATH];
73
74 if (!_tcsncmp (param, _T("/?"), 2))
75 {
76 ConOutResPuts(STRING_VOL_HELP4);
77 return 0;
78 }
79
80 if (param[0] == _T('\0'))
81 {
82 GetCurrentDirectory (MAX_PATH, szPath);
83 szRootPath[0] = szPath[0];
84 }
85 else
86 {
87 _tcsupr (param);
88 if (param[1] == _T(':'))
89 szRootPath[0] = param[0];
90 else
91 {
92 error_invalid_drive ();
93 return 1;
94 }
95 }
96
97 if (!IsValidPathName (szRootPath))
98 {
99 error_invalid_drive ();
100 return 1;
101 }
102
103 /* print the header */
104 if (!PrintVolumeHeader (szRootPath))
105 return 1;
106
107 return 0;
108 }
109
110 #endif