Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenlabel.c
Go to the documentation of this file.
00001 /* 00002 * LABEL.C - label internal command. 00003 * 00004 * 00005 * History: 00006 * 00007 * 10-Dec-1998 (Eric Kohl) 00008 * Started. 00009 * 00010 * 11-Dec-1998 (Eric Kohl) 00011 * Finished. 00012 * 00013 * 19-Jan-1998 (Eric Kohl) 00014 * Unicode ready! 00015 * 00016 * 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>) 00017 * Remove all hardcode string to En.rc 00018 */ 00019 00020 #include <precomp.h> 00021 00022 #ifdef INCLUDE_CMD_LABEL 00023 00024 00025 INT cmd_label (LPTSTR param) 00026 { 00027 TCHAR szRootPath[] = _T("A:\\"); 00028 TCHAR szLabel[80]; 00029 TCHAR szOldLabel[80]; 00030 DWORD dwSerialNr; 00031 00032 /* set empty label string */ 00033 szLabel[0] = _T('\0'); 00034 00035 nErrorLevel = 0; 00036 00037 /* print help */ 00038 if (!_tcsncmp (param, _T("/?"), 2)) 00039 { 00040 ConOutResPaging(TRUE,STRING_LABEL_HELP1); 00041 return 0; 00042 } 00043 00044 /* get parameters */ 00045 if (param[0] != _T('\0') && param[1] == _T(':')) 00046 { 00047 szRootPath[0] = toupper(*param); 00048 param += 2; 00049 while (_istspace(*param)) 00050 param++; 00051 } 00052 else 00053 { 00054 /* get label of current drive */ 00055 TCHAR szCurPath[MAX_PATH]; 00056 GetCurrentDirectory (MAX_PATH, szCurPath); 00057 szRootPath[0] = szCurPath[0]; 00058 } 00059 00060 _tcsncat(szLabel, param, 79); 00061 00062 /* check root path */ 00063 if (!IsValidPathName (szRootPath)) 00064 { 00065 error_invalid_drive (); 00066 nErrorLevel = 1; 00067 return 1; 00068 } 00069 00070 if (szLabel[0] == _T('\0')) 00071 { 00072 GetVolumeInformation(szRootPath, szOldLabel, 80, &dwSerialNr, 00073 NULL, NULL, NULL, 0); 00074 00075 /* print drive info */ 00076 if (szOldLabel[0] != _T('\0')) 00077 { 00078 ConOutResPrintf(STRING_LABEL_HELP2, _totupper(szRootPath[0]), szOldLabel); 00079 } 00080 else 00081 { 00082 ConOutResPrintf(STRING_LABEL_HELP3, _totupper(szRootPath[0])); 00083 } 00084 00085 /* print the volume serial number */ 00086 ConOutResPrintf(STRING_LABEL_HELP4, HIWORD(dwSerialNr), LOWORD(dwSerialNr)); 00087 00088 ConOutResPuts(STRING_LABEL_HELP5); 00089 00090 ConInString(szLabel, 80); 00091 } 00092 00093 if (!SetVolumeLabel(szRootPath, szLabel)) 00094 { 00095 ConOutFormatMessage(GetLastError()); 00096 nErrorLevel = 1; 00097 return 1; 00098 } 00099 00100 return 0; 00101 } 00102 00103 #endif /* INCLUDE_CMD_LABEL */ 00104 00105 /* EOF */ Generated on Sun May 27 2012 04:18:12 for ReactOS by
1.7.6.1
|