Changeset 34245 in vbox
- Timestamp:
- Nov 22, 2010 3:01:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp
r34157 r34245 39 39 #include "VBoxServiceInternal.h" 40 40 #include "VBoxServiceUtils.h" 41 42 /** @todo r=bird: Don't use VBoxServiceError here, just use RTMsg**. */ 43 /** @todo r=bird: 'static' is a wonderful keyword, please use it as much as 44 * possible like I've said in the coding guidelines. Not only does it 45 * help wrt to linking, but it also helps understanding what's 46 * internal and external interfaces in a source file! */ 41 47 42 48 … … 124 130 125 131 132 /** @todo r=bird: Again, function headers like this are uslesss and better left 133 * out. */ 126 134 /** 127 135 * … … 145 153 RTGETOPTSTATE GetState; 146 154 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 0); 155 /** @todo r=bird: Pass RTGETOPTINIT_FLAGS_OPTS_FIRST, our mkdir shall be 156 * like the GNU one wrt to option (dash-something) and argument 157 * order (dirs). */ 147 158 148 159 int rc = VINF_SUCCESS; … … 155 166 RTFMODE fileMode = 0; 156 167 #else 157 RTFMODE fileMode = S_IRWXU | S_IRWXG | S_IRWXO; 168 RTFMODE fileMode = S_IRWXU | S_IRWXG | S_IRWXO; /** @todo r=bird: We've got RTFS_ defines for these, they are x-platform. Why 'file' when we're creating directories? */ 158 169 #endif 159 170 … … 183 194 if (RT_FAILURE(rc)) 184 195 VBoxServiceError("mkdir: Could not build absolute directory!\n"); 196 /** @todo r=bird: you can make multiple directories just by 197 * adding them to the mkdir command line: 198 * "mkdir foo/ foo/bar foo/bar/wiz" 199 * This will now only create foo/bar/wiz, which will fail 200 * because the two previous steps weren't executed. It 201 * will also leak memory, but that's not important. (Also, 202 * I don't get why we need to call RTPathAbs here as nobody 203 * is going to change the current directory.) */ 185 204 break; 186 205 } 206 /** @todo r=bird: Missing handling of the standard options 'V' and 207 * 'h'. */ 187 208 188 209 default: … … 207 228 208 229 if (RT_SUCCESS(rc) && fVerbose) 209 VBoxServiceVerbose(0, "mkdir: Created directory '%s', mode 0x%RTfmode\n", szDir, fileMode); 230 VBoxServiceVerbose(0, "mkdir: Created directory '%s', mode 0x%RTfmode\n", szDir, fileMode); /** @todo r=bird: drop the 0x here, use %#RTfmode instead. */ 210 231 else if (RT_FAILURE(rc)) /** @todo Add a switch with more helpful error texts! */ 211 232 { … … 239 260 { "--output", 'o', RTGETOPT_REQ_STRING }, 240 261 { "--flags", 'f', RTGETOPT_REQ_STRING } 262 /** @todo r=bird: Missing options 'A', 'b', 'e', 'E', 'n', 's', 'T', 263 * 'u', 'v' as found on 'man cat' on a linux system. They must 264 * not be implemented, just return an apologetic error message. */ 241 265 }; 266 242 267 243 268 int ch; … … 250 275 251 276 RTFILE hOutput = NIL_RTFILE; 252 uint32_t ofFlags =RTFILE_O_CREATE_REPLACE /* Output file flags. */253 254 277 uint32_t fFlags = RTFILE_O_CREATE_REPLACE /* Output file flags. */ 278 | RTFILE_O_WRITE 279 | RTFILE_O_DENY_WRITE; 255 280 256 281 while ( (ch = RTGetOpt(&GetState, &ValueUnion)) … … 260 285 switch (ch) 261 286 { 287 /** @todo r=bird: You add a flag --no-content-indexed without a 288 * short form (use a #define CAT_OPT_NO_CONTENT_INDEXED 1000 for 289 * iShort). */ 290 262 291 case 'f': 263 292 /* Process flags; no fancy parsing here yet. */ 264 293 if (RTStrIStr(ValueUnion.psz, "noindex")) 265 ofFlags |= RTFILE_O_NOT_CONTENT_INDEXED;294 fFlags |= RTFILE_O_NOT_CONTENT_INDEXED; 266 295 else 267 296 { … … 272 301 273 302 case 'o': 274 rc = RTFileOpen(&hOutput, ValueUnion.psz, ofFlags);303 rc = RTFileOpen(&hOutput, ValueUnion.psz, fFlags); 275 304 if (RT_FAILURE(rc)) 276 305 VBoxServiceError("cat: Could not create output file \"%s\"! rc=%Rrc\n", 277 306 ValueUnion.psz, rc); 278 307 break; 308 309 /** @todo r=bird: Again, there shall be no need for any -i 310 * options since all non-options are input files. */ 279 311 280 312 case 'i': … … 289 321 } 290 322 323 /** @todo r=bird: Missing handling of the standard options 'V' and 324 * 'h'. */ 325 291 326 default: 292 327 return RTGetOptPrintError(ch, &ValueUnion); … … 315 350 int VBoxServiceToolboxMain(int argc, char **argv) 316 351 { 352 /** @todo r=bird: The return type of this function is mixed; both RTEXITCODE 353 * and IPRT status code. That doesn't cut it. The RTEXITCODE part should 354 * be returned separately from the handled-or-unhandled bit. 355 * 356 * Also, please change VBoxServiceToolboxCat and VBoxServiceToolboxCat to 357 * return RTEXITCODE and use RTMsg* like RTZipTarCmd (and later 358 * RTZipGzipCmd). */ 317 359 int rc = VERR_NOT_FOUND; 318 360 if (argc > 0) /* Do we have at least a main command? */ … … 326 368 || !strcmp(argv[0], "vbox_mkdir")) 327 369 { 328 rc = VBoxServiceToolbox MkDir(argc, argv);370 rc = VBoxServiceToolboxCat(argc, argv); 329 371 } 330 372 }
Note:
See TracChangeset
for help on using the changeset viewer.