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>)
19 #ifdef INCLUDE_CMD_LABEL
29 INT cmd_label (LPTSTR cmd, LPTSTR param)
31 TCHAR szRootPath[] = _T("A:\\");
38 /* set empty label string */
39 szLabel[0] = _T('\0');
42 if (!_tcsncmp (param, _T("/?"), 2))
44 ConOutPuts (_T("Displays or changes drive label.\n\n"
45 "LABEL [drive:][label]"));
50 arg = split (param, &args, FALSE);
54 /* too many parameters */
55 error_too_many_parameters (arg[args - 1]);
62 /* get label of current drive */
63 TCHAR szCurPath[MAX_PATH];
64 GetCurrentDirectory (MAX_PATH, szCurPath);
65 szRootPath[0] = szCurPath[0];
69 if ((_tcslen (arg[0]) >= 2) && (arg[0][1] == _T(':')))
71 szRootPath[0] = toupper (*arg[0]);
73 _tcsncpy (szLabel, arg[1], 12);
77 TCHAR szCurPath[MAX_PATH];
78 GetCurrentDirectory (MAX_PATH, szCurPath);
79 szRootPath[0] = szCurPath[0];
80 _tcsncpy (szLabel, arg[0], 12);
85 if (!IsValidPathName (szRootPath))
87 error_invalid_drive ();
92 GetVolumeInformation (szRootPath, szOldLabel, 80, &dwSerialNr,
95 /* print drive info */
96 ConOutPrintf (_T("Volume in drive %c:"), _totupper (szRootPath[0]));
98 if (szOldLabel[0] != _T('\0'))
99 ConOutPrintf (_T(" is %s\n"), szOldLabel);
101 ConOutPrintf (_T(" has no label\n"));
103 /* print the volume serial number */
104 ConOutPrintf (_T("Volume Serial Number is %04X-%04X\n"),
105 HIWORD(dwSerialNr), LOWORD(dwSerialNr));
107 if (szLabel[0] == _T('\0'))
109 ConOutPrintf (_T("Drive label (11 Characters, ENTER if none)? "));
110 ConInString (szLabel, 80);
113 SetVolumeLabel (szRootPath, szLabel);
120 #endif /* INCLUDE_CMD_LABEL */