1c2c66affSColin Finck /*
2c2c66affSColin Finck * VOL.C - vol internal command.
3c2c66affSColin Finck *
4c2c66affSColin Finck *
5c2c66affSColin Finck * History:
6c2c66affSColin Finck *
7c2c66affSColin Finck * 03-Dec-1998 (Eric Kohl)
8c2c66affSColin Finck * Replaced DOS calls by Win32 calls.
9c2c66affSColin Finck *
10c2c66affSColin Finck * 08-Dec-1998 (Eric Kohl)
11c2c66affSColin Finck * Added help text ("/?").
12c2c66affSColin Finck *
13c2c66affSColin Finck * 07-Jan-1999 (Eric Kohl)
14c2c66affSColin Finck * Cleanup.
15c2c66affSColin Finck *
16c2c66affSColin Finck * 18-Jan-1999 (Eric Kohl)
17c2c66affSColin Finck * Unicode ready!
18c2c66affSColin Finck *
19c2c66affSColin Finck * 20-Jan-1999 (Eric Kohl)
20c2c66affSColin Finck * Redirection ready!
21c2c66affSColin Finck */
22c2c66affSColin Finck
23c2c66affSColin Finck #include "precomp.h"
24c2c66affSColin Finck
25c2c66affSColin Finck #ifdef INCLUDE_CMD_VOL
26c2c66affSColin Finck
27c2c66affSColin Finck
28c2c66affSColin Finck static INT
PrintVolumeHeader(LPTSTR pszRootPath)29c2c66affSColin Finck PrintVolumeHeader (LPTSTR pszRootPath)
30c2c66affSColin Finck {
31c2c66affSColin Finck TCHAR szVolName[80];
32c2c66affSColin Finck DWORD dwSerialNr;
33c2c66affSColin Finck
34c2c66affSColin Finck /* get the volume information of the drive */
35c2c66affSColin Finck if (!GetVolumeInformation(pszRootPath,
36c2c66affSColin Finck szVolName,
37c2c66affSColin Finck 80,
38c2c66affSColin Finck &dwSerialNr,
39c2c66affSColin Finck NULL,
40c2c66affSColin Finck NULL,
41c2c66affSColin Finck NULL,
42c2c66affSColin Finck 0))
43c2c66affSColin Finck {
44*d0ced4ffSHermès Bélusca-Maïto ErrorMessage(GetLastError (), NULL);
45c2c66affSColin Finck return 1;
46c2c66affSColin Finck }
47c2c66affSColin Finck
48c2c66affSColin Finck /* print drive info */
49c2c66affSColin Finck if (szVolName[0] != '\0')
50c2c66affSColin Finck {
51c2c66affSColin Finck ConOutResPrintf(STRING_VOL_HELP1, pszRootPath[0],szVolName);
52c2c66affSColin Finck }
53c2c66affSColin Finck else
54c2c66affSColin Finck {
55c2c66affSColin Finck ConOutResPrintf(STRING_VOL_HELP2, pszRootPath[0]);
56c2c66affSColin Finck }
57c2c66affSColin Finck
58c2c66affSColin Finck /* print the volume serial number */
59c2c66affSColin Finck ConOutResPrintf(STRING_VOL_HELP3, HIWORD(dwSerialNr), LOWORD(dwSerialNr));
60c2c66affSColin Finck return 0;
61c2c66affSColin Finck }
62c2c66affSColin Finck
63c2c66affSColin Finck
cmd_vol(LPTSTR param)64c2c66affSColin Finck INT cmd_vol (LPTSTR param)
65c2c66affSColin Finck {
66c2c66affSColin Finck TCHAR szRootPath[] = _T("A:\\");
67c2c66affSColin Finck TCHAR szPath[MAX_PATH];
68c2c66affSColin Finck
69c2c66affSColin Finck if (!_tcsncmp(param, _T("/?"), 2))
70c2c66affSColin Finck {
71c2c66affSColin Finck ConOutResPaging(TRUE,STRING_VOL_HELP4);
72c2c66affSColin Finck return 0;
73c2c66affSColin Finck }
74c2c66affSColin Finck
75c2c66affSColin Finck nErrorLevel = 0;
76c2c66affSColin Finck
77c2c66affSColin Finck if (param[0] == _T('\0'))
78c2c66affSColin Finck {
79c2c66affSColin Finck GetCurrentDirectory(MAX_PATH, szPath);
80c2c66affSColin Finck szRootPath[0] = szPath[0];
81c2c66affSColin Finck }
82c2c66affSColin Finck else
83c2c66affSColin Finck {
84c2c66affSColin Finck _tcsupr (param);
85c2c66affSColin Finck if (param[1] == _T(':'))
86c2c66affSColin Finck {
87c2c66affSColin Finck szRootPath[0] = param[0];
88c2c66affSColin Finck }
89c2c66affSColin Finck else
90c2c66affSColin Finck {
91c2c66affSColin Finck error_invalid_drive ();
92c2c66affSColin Finck nErrorLevel = 1;
93c2c66affSColin Finck return 1;
94c2c66affSColin Finck }
95c2c66affSColin Finck }
96c2c66affSColin Finck
97c2c66affSColin Finck if (!IsValidPathName (szRootPath))
98c2c66affSColin Finck {
99c2c66affSColin Finck error_invalid_drive ();
100c2c66affSColin Finck nErrorLevel = 1;
101c2c66affSColin Finck return 1;
102c2c66affSColin Finck }
103c2c66affSColin Finck
104c2c66affSColin Finck /* print the header */
105c2c66affSColin Finck if (!PrintVolumeHeader (szRootPath))
106c2c66affSColin Finck {
107c2c66affSColin Finck nErrorLevel = 1;
108c2c66affSColin Finck return 1;
109c2c66affSColin Finck }
110c2c66affSColin Finck
111c2c66affSColin Finck return 0;
112c2c66affSColin Finck }
113c2c66affSColin Finck
114c2c66affSColin Finck #endif
115