285421954dd6974d40970c04f870e60c6d204545
2 * LABEL.C - label internal command.
7 * 10-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
10 * 11-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
13 * 19-Jan-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
17 #define WIN32_LEAN_AND_MEAN
21 #ifdef INCLUDE_CMD_LABEL
30 INT
cmd_label (LPTSTR cmd
, LPTSTR param
)
32 TCHAR szRootPath
[] = _T("A:\\");
39 /* set empty label string */
40 szLabel
[0] = _T('\0');
43 if (!_tcsncmp (param
, _T("/?"), 2))
45 ConOutPuts (_T("Displays or changes drive label.\n\n"
46 "LABEL [drive:][label]"));
51 arg
= split (param
, &args
);
55 /* too many parameters */
56 error_too_many_parameters (arg
[args
- 1]);
63 /* get label of current drive */
64 TCHAR szCurPath
[MAX_PATH
];
65 GetCurrentDirectory (MAX_PATH
, szCurPath
);
66 szRootPath
[0] = szCurPath
[0];
70 if ((_tcslen (arg
[0]) >= 2) && (arg
[0][1] == _T(':')))
72 szRootPath
[0] = toupper (*arg
[0]);
74 _tcsncpy (szLabel
, arg
[1], 12);
78 TCHAR szCurPath
[MAX_PATH
];
79 GetCurrentDirectory (MAX_PATH
, szCurPath
);
80 szRootPath
[0] = szCurPath
[0];
81 _tcsncpy (szLabel
, arg
[0], 12);
86 if (!IsValidPathName (szRootPath
))
88 error_invalid_drive ();
93 GetVolumeInformation (szRootPath
, szOldLabel
, 80, &dwSerialNr
,
96 /* print drive info */
97 ConOutPrintf (_T("Volume in drive %c:"), _totupper (szRootPath
[0]));
99 if (szOldLabel
[0] != _T('\0'))
100 ConOutPrintf (_T(" is %s\n"), szOldLabel
);
102 ConOutPrintf (_T(" has no label\n"));
104 /* print the volume serial number */
105 ConOutPrintf (_T("Volume Serial Number is %04X-%04X\n"),
106 HIWORD(dwSerialNr
), LOWORD(dwSerialNr
));
108 if (szLabel
[0] == _T('\0'))
110 ConOutPrintf (_T("Drive label (11 Characters, ENTER if none)? "));
111 ConInString (szLabel
, 80);
114 SetVolumeLabel (szRootPath
, szLabel
);
121 #endif /* INCLUDE_CMD_LABEL */