- Timestamp:
- Aug 7, 2012 11:39:09 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp
r42645 r42655 960 960 */ 961 961 static void toolboxRmReport(const char *pcszMessage, const char *pcszFile, 962 int rc, uint32_t fOutputFlags, int *prc) 963 { 962 bool fActive, int rc, uint32_t fOutputFlags, 963 int *prc) 964 { 965 if (!fActive) 966 return; 964 967 if (!(fOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE)) 965 968 { 966 if (RT_FAILURE(rc)) 969 if (RT_SUCCESS(rc)) 970 RTPrintf(pcszMessage, pcszFile, rc); 971 else 967 972 RTMsgError(pcszMessage, pcszFile, rc); 968 973 } … … 1046 1051 } 1047 1052 } 1048 /* We need at least one file. */1049 if (RT_SUCCESS(rc) && cNonOptions == 0)1050 {1051 RTMsgError("No files or directories specified.");1052 return RTEXITCODE_FAILURE;1053 }1054 1055 1053 if (RT_SUCCESS(rc)) 1056 1054 { … … 1065 1063 } 1066 1064 1065 /* We need at least one file. */ 1066 if (RT_SUCCESS(rc) && cNonOptions == 0) 1067 { 1068 toolboxRmReport("No files or directories specified.\n", NULL, true, 0, 1069 fOutputFlags, NULL); 1070 return RTEXITCODE_FAILURE; 1071 } 1067 1072 if (RT_SUCCESS(rc)) 1068 1073 { … … 1075 1080 if (!(fFlags & VBOXSERVICETOOLBOXRMFLAG_RECURSIVE)) 1076 1081 toolboxRmReport("Cannot remove directory '%s' as the '-R' option was not specified.\n", 1077 argv[i], VERR_INVALID_PARAMETER,1082 argv[i], true, VERR_INVALID_PARAMETER, 1078 1083 fOutputFlags, &rc); 1079 1084 else … … 1081 1086 rc2 = RTDirRemoveRecursive(argv[i], 1082 1087 RTDIRRMREC_F_CONTENT_AND_DIR); 1088 toolboxRmReport("", argv[i], RT_SUCCESS(rc2), rc2, 1089 fOutputFlags, NULL); 1083 1090 toolboxRmReport("The following error occurred while removing directory '%s': %Rrc.\n", 1084 argv[i], rc2, fOutputFlags, &rc); 1091 argv[i], RT_FAILURE(rc2), rc2, 1092 fOutputFlags, &rc); 1085 1093 } 1086 1094 } … … 1088 1096 { 1089 1097 rc2 = RTFileDelete(argv[i]); 1098 toolboxRmReport("", argv[i], RT_SUCCESS(rc2), rc2, 1099 fOutputFlags, NULL); 1090 1100 toolboxRmReport("The following error occurred while removing file '%s': %Rrc.\n", 1091 argv[i], rc2, fOutputFlags, &rc); 1101 argv[i], RT_FAILURE(rc2), rc2, fOutputFlags, 1102 &rc); 1092 1103 } 1093 1104 else 1094 1105 toolboxRmReport("File '%s' does not exist.\n", argv[i], 1095 VERR_FILE_NOT_FOUND, fOutputFlags, &rc);1106 true, VERR_FILE_NOT_FOUND, fOutputFlags, &rc); 1096 1107 } 1097 1108 … … 1120 1131 */ 1121 1132 static void toolboxMkTempReport(const char *pcszMessage, const char *pcszFile, 1122 int rc, uint32_t fOutputFlags, int *prc) 1123 { 1133 bool fActive, int rc, uint32_t fOutputFlags, 1134 int *prc) 1135 { 1136 if (!fActive) 1137 return; 1124 1138 if (!(fOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE)) 1125 { 1126 if (RT_FAILURE(rc)) 1139 if (RT_SUCCESS(rc)) 1140 RTPrintf(pcszMessage, pcszFile, rc); 1141 else 1127 1142 RTMsgError(pcszMessage, pcszFile, rc); 1128 }1129 1143 else 1130 1144 RTPrintf("name=%s%crc=%d%c", pcszFile, 0, rc, 0); … … 1161 1175 uint32_t fOutputFlags = 0; 1162 1176 int cNonOptions = 0; 1177 char *pszName; 1163 1178 1164 1179 while ( (ch = RTGetOpt(&GetState, &ValueUnion)) … … 1206 1221 if (RT_SUCCESS(rc) && cNonOptions != 1) 1207 1222 { 1208 toolboxMkTempReport("Please specify exactly one template.\n", 1209 "", VERR_INVALID_PARAMETER, fOutputFlags, &rc);1223 toolboxMkTempReport("Please specify exactly one template.\n", "", 1224 true, VERR_INVALID_PARAMETER, fOutputFlags, &rc); 1210 1225 return RTEXITCODE_FAILURE; 1211 1226 } 1212 if (RT_SUCCESS(rc) && !strchr(argv[argc - 1], 'X')) /* IPRT asserts this. */ 1227 pszName = argv[argc - 1]; 1228 if (RT_SUCCESS(rc) && !strchr(pszName, 'X')) /* IPRT asserts this. */ 1213 1229 { 1214 1230 toolboxMkTempReport("Template '%s' should contain at least one 'X' character.\n", 1215 argv[argc - 1], VERR_INVALID_PARAMETER,1231 pszName, true, VERR_INVALID_PARAMETER, 1216 1232 fOutputFlags, &rc); 1217 1233 return RTEXITCODE_FAILURE; … … 1220 1236 if (RT_SUCCESS(rc)) 1221 1237 { 1222 rc = RTDirCreateTemp(argv[argc - 1]); 1238 rc = RTDirCreateTemp(pszName); 1239 toolboxMkTempReport("Created temporary directory '%s'.\n", 1240 pszName, RT_SUCCESS(rc), rc, fOutputFlags, NULL); 1223 1241 toolboxMkTempReport("The following error occurred while creating a temporary directory with template '%s': %Rrc.\n", 1224 argv[argc - 1], rc, fOutputFlags, NULL); 1225 if ( RT_SUCCESS(rc) 1226 && !(fOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE)) 1227 RTPrintf("Created temporary directory '%s'.\n", argv[argc - 1]); 1242 pszName, RT_FAILURE(rc), rc, fOutputFlags, NULL); 1228 1243 if (fOutputFlags & VBOXSERVICETOOLBOXOUTPUTFLAG_PARSEABLE) /* Output termination. */ 1229 1244 VBoxServiceToolboxPrintStrmTermination();
Note:
See TracChangeset
for help on using the changeset viewer.