Author: hbelusca Date: Tue Jun 28 20:22:07 2016 New Revision: 71693
URL: http://svn.reactos.org/svn/reactos?rev=71693&view=rev Log: [SUBST] - Headers reordering. - Use ARRAYSIZE. - Give the internal helper function IsSubstedDrive just the single letter of the drive to check for. - AddSubst and DeleteSubst: both take a drive string of *exactly* two characters: the drive letter and the ':' (and of course there's the NULL terminator): fix the parameter check in this regard. - AddSubst: It is possible on Windows to use the DefineDosDevice API to map a drive letter to a *file* (yes yes!!) (but the mapping made is unusable). Forbids this case in SUBST since it is not made for that. CORE-10681
Modified: trunk/reactos/base/system/subst/lang/bg-BG.rc trunk/reactos/base/system/subst/lang/de-DE.rc trunk/reactos/base/system/subst/lang/en-US.rc trunk/reactos/base/system/subst/lang/es-ES.rc trunk/reactos/base/system/subst/lang/fr-FR.rc trunk/reactos/base/system/subst/lang/it-IT.rc trunk/reactos/base/system/subst/lang/pl-PL.rc trunk/reactos/base/system/subst/lang/ro-RO.rc trunk/reactos/base/system/subst/lang/ru-RU.rc trunk/reactos/base/system/subst/lang/sq-AL.rc trunk/reactos/base/system/subst/lang/tr-TR.rc trunk/reactos/base/system/subst/lang/uk-UA.rc trunk/reactos/base/system/subst/lang/zh-CN.rc trunk/reactos/base/system/subst/lang/zh-TW.rc trunk/reactos/base/system/subst/resource.h trunk/reactos/base/system/subst/subst.c
Modified: trunk/reactos/base/system/subst/lang/bg-BG.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/bg-B... ============================================================================== --- trunk/reactos/base/system/subst/lang/bg-BG.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/bg-BG.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -5,6 +5,7 @@ IDS_INCORRECT_PARAMETER_COUNT "ÐепÑавилен бÑой клÑÑове - %s\n" IDS_INVALID_PARAMETER "ÐепÑавилен бÑой клÑÑове - %s\n" IDS_INVALID_PARAMETER2 "ÐедопÑÑÑим клÑÑ - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "УÑÑÑойÑÑвоÑо веÑе е подложено на SUBST\n" IDS_FAILED_WITH_ERRORCODE "ÐÑеÑка номеÑ: 0x%x: %s\n" IDS_USAGE "ÐбвÑÑзва пÑÑ Ñ Ð¸Ð¼Ðµ на ÑÑÑÑойÑÑво (дÑл).\n\n\
Modified: trunk/reactos/base/system/subst/lang/de-DE.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/de-D... ============================================================================== --- trunk/reactos/base/system/subst/lang/de-DE.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/de-DE.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -5,6 +5,7 @@ IDS_INCORRECT_PARAMETER_COUNT "Falsche Anzahl an Parametern - %s\n" IDS_INVALID_PARAMETER "Falsche Anzahl an Parametern - %s\n" IDS_INVALID_PARAMETER2 "Falscher Parameter - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "SUBST wurde hier schon ausgeführt.\n" IDS_FAILED_WITH_ERRORCODE "Fehlgeschlagen - Code 0x%x: %s\n" IDS_USAGE "Weist einem Pfad einen Laufwerksbuchstaben zu.n\n\
Modified: trunk/reactos/base/system/subst/lang/en-US.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/en-U... ============================================================================== --- trunk/reactos/base/system/subst/lang/en-US.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/en-US.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -5,6 +5,7 @@ IDS_INCORRECT_PARAMETER_COUNT "Incorrect number of parameters - %s\n" IDS_INVALID_PARAMETER "Incorrect number of parameters - %s\n" IDS_INVALID_PARAMETER2 "Invalid parameter - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Drive already SUBSTed\n" IDS_FAILED_WITH_ERRORCODE "Failed with error code 0x%x: %s\n" IDS_USAGE "Associates a path with a drive letter.\n\n\
Modified: trunk/reactos/base/system/subst/lang/es-ES.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/es-E... ============================================================================== --- trunk/reactos/base/system/subst/lang/es-ES.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/es-ES.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -5,6 +5,7 @@ IDS_INCORRECT_PARAMETER_COUNT "Cantidad de parámetros incorrecta - %s\n" IDS_INVALID_PARAMETER "Cantidad de parámetros incorrecta - %s\n" IDS_INVALID_PARAMETER2 "Parámetro incorrecto - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Unidad ya sustituida\n" IDS_FAILED_WITH_ERRORCODE "Falla con código de error 0x%x: %s\n" IDS_USAGE "Asocia una ruta con una letra de unidad.\n\n\
Modified: trunk/reactos/base/system/subst/lang/fr-FR.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/fr-F... ============================================================================== --- trunk/reactos/base/system/subst/lang/fr-FR.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/fr-FR.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -5,8 +5,9 @@ IDS_INCORRECT_PARAMETER_COUNT "Nombre incorrect de paramètres - %s\n" IDS_INVALID_PARAMETER "Nombre incorrect de paramètres - %s\n" IDS_INVALID_PARAMETER2 "Paramètre incorrect - %s\n" + IDS_PATH_NOT_FOUND "Chemin d'accès introuvable - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Disque déjà substitué\n" - IDS_FAILED_WITH_ERRORCODE "Ãchoue avec le code d'erreur 0x%x: %s\n" + IDS_FAILED_WITH_ERRORCODE "Ãchoue avec le code d'erreur 0x%x : %s\n" IDS_USAGE "Associe un chemin avec une lettre de lecteur.\n\n\ SUBST [disque1: [disque2:]chemin]\n\ SUBST disque1: /D\n\n\
Modified: trunk/reactos/base/system/subst/lang/it-IT.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/it-I... ============================================================================== --- trunk/reactos/base/system/subst/lang/it-IT.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/it-IT.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -5,6 +5,7 @@ IDS_INCORRECT_PARAMETER_COUNT "Numero di parametri errato - %s\n" IDS_INVALID_PARAMETER "Numero di parametri errato - %s\n" IDS_INVALID_PARAMETER2 "Parametro errato - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Unità già sostituita\n" IDS_FAILED_WITH_ERRORCODE "Interruzione con codice di errore 0x%x: %s\n" IDS_USAGE "Associa un percorso ad una lettera di unità .\n\n\
Modified: trunk/reactos/base/system/subst/lang/pl-PL.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/pl-P... ============================================================================== --- trunk/reactos/base/system/subst/lang/pl-PL.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/pl-PL.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -13,6 +13,7 @@ IDS_INCORRECT_PARAMETER_COUNT "NieprawidÅowa liczba parametrów - %s\n" IDS_INVALID_PARAMETER "NieprawidÅowy parametr - %s\n" IDS_INVALID_PARAMETER2 "NieprawidÅowe parametry - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Na tym dysku już użyto komendy SUBST\n" IDS_FAILED_WITH_ERRORCODE "BÅÄ d 0x%x: %s\n" IDS_USAGE "PowiÄ zuje ÅcieżkÄ z literÄ napÄdu.\n\n\
Modified: trunk/reactos/base/system/subst/lang/ro-RO.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/ro-R... ============================================================================== --- trunk/reactos/base/system/subst/lang/ro-RO.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/ro-RO.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -7,6 +7,7 @@ IDS_INCORRECT_PARAMETER_COUNT "NumÄr eronat de parametri - %s\n" IDS_INVALID_PARAMETER "NumÄr eronat de parametri - %s\n" IDS_INVALID_PARAMETER2 "Parametru eronat - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Unitatea este deja SUBSTituitÄ\n" IDS_FAILED_WITH_ERRORCODE "OperaÈia a eÈuat. Codul de eroare 0x%x: %s\n" IDS_USAGE "Substituie un director cu o unitate de stocare.\n\n\
Modified: trunk/reactos/base/system/subst/lang/ru-RU.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/ru-R... ============================================================================== --- trunk/reactos/base/system/subst/lang/ru-RU.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/ru-RU.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -7,6 +7,7 @@ IDS_INCORRECT_PARAMETER_COUNT "ÐевеÑное ÑиÑло паÑамеÑÑов - %s\n" IDS_INVALID_PARAMETER "ÐевеÑное ÑиÑло паÑамеÑÑов - %s\n" IDS_INVALID_PARAMETER2 "ÐевеÑнÑй паÑамеÑÑ - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "ÐиÑк Ñже ÑопоÑÑавлен\n" IDS_FAILED_WITH_ERRORCODE "Сбой Ñ ÐºÐ¾Ð´Ð¾Ð¼ оÑибки 0x%x: %s\n" IDS_USAGE "СопоÑÑавление имени диÑка ÑÐºÐ°Ð·Ð°Ð½Ð½Ð¾Ð¼Ñ Ð¿ÑÑи.\n\n\
Modified: trunk/reactos/base/system/subst/lang/sq-AL.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/sq-A... ============================================================================== --- trunk/reactos/base/system/subst/lang/sq-AL.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/sq-AL.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -9,6 +9,7 @@ IDS_INCORRECT_PARAMETER_COUNT "Numri i parametrave jo i sakte - %s\n" IDS_INVALID_PARAMETER "Numri i parametrave jo i sakte - %s\n" IDS_INVALID_PARAMETER2 "Parameter i gabuar - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Drive tashme i SUBSTed\n" IDS_FAILED_WITH_ERRORCODE "Deshtoj me error kode 0x%x: %s\n" IDS_USAGE "Perputh rrugen e driverit me germën.\n\n\
Modified: trunk/reactos/base/system/subst/lang/tr-TR.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/tr-T... ============================================================================== --- trunk/reactos/base/system/subst/lang/tr-TR.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/tr-TR.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -7,6 +7,7 @@ IDS_INCORRECT_PARAMETER_COUNT "DeÄiÅken sayısı yanlıŠ- %s\n" IDS_INVALID_PARAMETER "DeÄiÅken sayısı yanlıŠ- %s\n" IDS_INVALID_PARAMETER2 "Geçersiz deÄiÅken - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Sürücü önceden SUBST edilmiÅ.\n" IDS_FAILED_WITH_ERRORCODE "YanlıÅlık kodu ile baÅarısız oldu 0x%x: %s\n" IDS_USAGE "Bir sürücü harfiyle bir yolu iliÅkilendirir.\n\n\
Modified: trunk/reactos/base/system/subst/lang/uk-UA.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/uk-U... ============================================================================== --- trunk/reactos/base/system/subst/lang/uk-UA.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/uk-UA.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -7,6 +7,7 @@ IDS_INCORRECT_PARAMETER_COUNT "ÐевÑÑна кÑлÑкÑÑÑÑ Ð¿Ð°ÑамеÑÑÑв - %s\n" IDS_INVALID_PARAMETER "ÐевÑÑна кÑлÑкÑÑÑÑ Ð¿Ð°ÑамеÑÑÑв - %s\n" IDS_INVALID_PARAMETER2 "ÐевÑÑний паÑамеÑÑ - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "Ðо диÑÐºÑ Ð²Ð¶Ðµ заÑÑоÑовано SUBST\n" IDS_FAILED_WITH_ERRORCODE "ÐевдаÑа з кодом помилки 0x%x: %s\n" IDS_USAGE "ÐÑоÑÑÑÑ ÑлÑÑ Ð· бÑÐºÐ²Ð¾Ñ Ð´Ð¸ÑкÑ.\n\n\
Modified: trunk/reactos/base/system/subst/lang/zh-CN.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/zh-C... ============================================================================== --- trunk/reactos/base/system/subst/lang/zh-CN.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/zh-CN.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -7,6 +7,7 @@ IDS_INCORRECT_PARAMETER_COUNT "åæ°ä¸ªæ°ä¸æ£ç¡® - %s\n" IDS_INVALID_PARAMETER "åæ°ä¸ªæ°ä¸æ£ç¡® - %s\n" IDS_INVALID_PARAMETER2 "æ æåæ° - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "驱å¨å¨å·²ç»è¿è¡è¿ SUBST\n" IDS_FAILED_WITH_ERRORCODE "æä½å¤±è´¥ï¼é误ç 0x%xï¼%s\n" IDS_USAGE "å°ä¸ä¸ªè·¯å¾ç¨é©±å¨å¨å·å ³èã\n\n\
Modified: trunk/reactos/base/system/subst/lang/zh-TW.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/lang/zh-T... ============================================================================== --- trunk/reactos/base/system/subst/lang/zh-TW.rc [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/lang/zh-TW.rc [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -7,6 +7,7 @@ IDS_INCORRECT_PARAMETER_COUNT "忏忏䏿£ç¢º - %s\n" IDS_INVALID_PARAMETER "忏忏䏿£ç¢º - %s\n" IDS_INVALID_PARAMETER2 "ç¡æåæ¸ - %s\n" + IDS_PATH_NOT_FOUND "Path not found - %s\n" IDS_DRIVE_ALREADY_SUBSTED "é© åå¨å·²ç¶éè¡é SUBST\n" IDS_FAILED_WITH_ERRORCODE "æä½å¤±æï¼é¯èª¤ç¢¼ 0x%xï¼%s\n" IDS_USAGE "å°ä¸åè·¯å¾ç¨é© åå¨èéè¯ã\n\n\
Modified: trunk/reactos/base/system/subst/resource.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/resource.... ============================================================================== --- trunk/reactos/base/system/subst/resource.h [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/resource.h [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -8,4 +8,5 @@ #define IDS_INCORRECT_PARAMETER_COUNT 1003 #define IDS_INVALID_PARAMETER 1004 #define IDS_INVALID_PARAMETER2 1005 -#define IDS_DRIVE_ALREADY_SUBSTED 1006 +#define IDS_PATH_NOT_FOUND 1006 +#define IDS_DRIVE_ALREADY_SUBSTED 1007
Modified: trunk/reactos/base/system/subst/subst.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/subst/subst.c?r... ============================================================================== --- trunk/reactos/base/system/subst/subst.c [iso-8859-1] (original) +++ trunk/reactos/base/system/subst/subst.c [iso-8859-1] Tue Jun 28 20:22:07 2016 @@ -7,13 +7,14 @@
/* INCLUDES *****************************************************************/
+#include <stdarg.h> +#include <stdlib.h> +#include <tchar.h> + #define WIN32_NO_STATUS -#include <stdarg.h> #include <windef.h> #include <winbase.h> #include <winuser.h> -#include <stdlib.h> -#include <tchar.h>
#define NDEBUG #include <debug.h> @@ -22,7 +23,7 @@
/* FUNCTIONS ****************************************************************/
-void PrintError(DWORD ErrCode) +VOID PrintError(DWORD ErrCode) { TCHAR szFmtString[RC_STRING_MAX_SIZE] = {0}; TCHAR *buffer = (TCHAR*) calloc(2048, @@ -41,7 +42,7 @@ LoadString(GetModuleHandle(NULL), IDS_FAILED_WITH_ERRORCODE, szFmtString, - sizeof(szFmtString) / sizeof(szFmtString[0])); + ARRAYSIZE(szFmtString)); _sntprintf(buffer, 2048, szFmtString, @@ -55,25 +56,25 @@ } }
-void DisplaySubstUsage(void) +VOID DisplaySubstUsage(VOID) { TCHAR szHelp[RC_STRING_MAX_SIZE] = {0};
LoadString(GetModuleHandle(NULL), IDS_USAGE, szHelp, - sizeof(szHelp) / sizeof(szHelp[0])); + ARRAYSIZE(szHelp)); _tprintf(_T("%s"), szHelp); }
-BOOLEAN IsSubstedDrive(TCHAR *Drive) +BOOLEAN IsSubstedDrive(TCHAR DriveLetter) { BOOLEAN Result = FALSE; + TCHAR Drive[3] = _T("A:"); LPTSTR lpTargetPath = NULL; DWORD CharCount, dwSize;
- if (_tcslen(Drive) > 2) - return FALSE; + Drive[0] = DriveLetter;
dwSize = MAX_PATH; lpTargetPath = (LPTSTR)malloc(sizeof(TCHAR) * dwSize); @@ -109,7 +110,7 @@ return Result; }
-void DumpSubstedDrives(void) +VOID DumpSubstedDrives(VOID) { TCHAR Drive[3] = _T("A:"); LPTSTR lpTargetPath = NULL; @@ -159,7 +160,7 @@ free(lpTargetPath); }
-int DeleteSubst(TCHAR* Drive) +INT DeleteSubst(TCHAR* Drive) { BOOL Result; TCHAR szFmtString[RC_STRING_MAX_SIZE] = {0}; @@ -167,26 +168,24 @@ LoadString(GetModuleHandle(NULL), IDS_INVALID_PARAMETER2, szFmtString, - sizeof(szFmtString) / sizeof(szFmtString[0])); - - if (_tcslen(Drive) > 2) - { - _tprintf(szFmtString, - Drive); - return 1; - } - - if (! IsSubstedDrive(Drive)) - { - _tprintf(szFmtString, - Drive); + ARRAYSIZE(szFmtString)); + + if ((_tcslen(Drive) != 2) || (Drive[1] != _T(':'))) + { + _tprintf(szFmtString, Drive); + return 1; + } + + if (!IsSubstedDrive(Drive[0])) + { + _tprintf(szFmtString, Drive); return 1; }
Result = DefineDosDevice(DDD_REMOVE_DEFINITION, Drive, NULL); - if (! Result) + if (!Result) { PrintError(GetLastError()); return 1; @@ -194,35 +193,47 @@ return 0; }
-int AddSubst(TCHAR* Drive, TCHAR *Path) +INT AddSubst(TCHAR* Drive, TCHAR *Path) { BOOL Result; - TCHAR szFmtString[RC_STRING_MAX_SIZE] = {0}; - - LoadString(GetModuleHandle(NULL), - IDS_INVALID_PARAMETER2, - szFmtString, - sizeof(szFmtString) / sizeof(szFmtString[0])); - if (_tcslen(Drive) != 2) - { - _tprintf(szFmtString, - Drive); - return 1; - } - - if (Drive[1] != _T(':')) - { - _tprintf(szFmtString, - Drive); - return 1; - } - - if (IsSubstedDrive(Drive)) - { + DWORD dwPathAttr; + TCHAR szFmtString[RC_STRING_MAX_SIZE] = {0}; + + if ((_tcslen(Drive) != 2) || (Drive[1] != _T(':'))) + { + LoadString(GetModuleHandle(NULL), + IDS_INVALID_PARAMETER2, + szFmtString, + ARRAYSIZE(szFmtString)); + _tprintf(szFmtString, Drive); + return 1; + } + + /* + * Even if DefineDosDevice allows to map files to drive letters (yes yes!!) + * it is not the purpose of SUBST to allow that. Therefore check whether + * the given path exists and really is a path to a directory, and if not, + * just fail with an error. + */ + dwPathAttr = GetFileAttributes(Path); + if ( (dwPathAttr == INVALID_FILE_ATTRIBUTES) || + !(dwPathAttr & FILE_ATTRIBUTE_DIRECTORY) ) + { + LoadString(GetModuleHandle(NULL), + IDS_PATH_NOT_FOUND, + szFmtString, + ARRAYSIZE(szFmtString)); + _tprintf(szFmtString, Path); + return 1; + } + + if (IsSubstedDrive(Drive[0])) + { + // ERROR_IS_SUBSTED LoadString(GetModuleHandle(NULL), IDS_DRIVE_ALREADY_SUBSTED, szFmtString, - sizeof(szFmtString) / sizeof(szFmtString[0])); + ARRAYSIZE(szFmtString)); _tprintf(szFmtString); return 1; } @@ -230,7 +241,7 @@ Result = DefineDosDevice(0, Drive, Path); - if (! Result) + if (!Result) { PrintError(GetLastError()); return 1; @@ -259,9 +270,8 @@ LoadString(GetModuleHandle(NULL), IDS_INVALID_PARAMETER, szFmtString, - sizeof(szFmtString) / sizeof(szFmtString[0])); - _tprintf(szFmtString, - argv[1]); + ARRAYSIZE(szFmtString)); + _tprintf(szFmtString, argv[1]); return 1; } DumpSubstedDrives(); @@ -273,15 +283,14 @@ LoadString(GetModuleHandle(NULL), IDS_INCORRECT_PARAMETER_COUNT, szFmtString, - sizeof(szFmtString) / sizeof(szFmtString[0])); - _tprintf(szFmtString, - argv[3]); - return 1; - } - - if (! _tcsicmp(argv[1], _T("/D"))) + ARRAYSIZE(szFmtString)); + _tprintf(szFmtString, argv[3]); + return 1; + } + + if (!_tcsicmp(argv[1], _T("/D"))) return DeleteSubst(argv[2]); - if (! _tcsicmp(argv[2], _T("/D"))) + if (!_tcsicmp(argv[2], _T("/D"))) return DeleteSubst(argv[1]); return AddSubst(argv[1], argv[2]); }