VirtualBox

Changeset 34245 in vbox


Ignore:
Timestamp:
Nov 22, 2010 3:01:00 PM (14 years ago)
Author:
vboxsync
Message:

VBoxServiceToolBox.cpp: r=bird: A bunch of review comments. Only the VBoxServiceToolboxMain is critical. Btw., is it Toolbox like in the API or ToolBox like in the file name?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.cpp

    r34157 r34245  
    3939#include "VBoxServiceInternal.h"
    4040#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! */
    4147
    4248
     
    124130
    125131
     132/** @todo r=bird: Again, function headers like this are uslesss and better left
     133 *        out. */
    126134/**
    127135 *
     
    145153     RTGETOPTSTATE GetState;
    146154     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). */
    147158
    148159     int rc = VINF_SUCCESS;
     
    155166     RTFMODE fileMode = 0;
    156167#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? */
    158169#endif
    159170
     
    183194                 if (RT_FAILURE(rc))
    184195                     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.) */
    185204                 break;
    186205             }
     206             /** @todo r=bird: Missing handling of the standard options 'V' and
     207              *        'h'. */
    187208
    188209             default:
     
    207228
    208229         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. */
    210231         else if (RT_FAILURE(rc)) /** @todo Add a switch with more helpful error texts! */
    211232         {
     
    239260         { "--output",    'o', RTGETOPT_REQ_STRING },
    240261         { "--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. */
    241265     };
     266
    242267
    243268     int ch;
     
    250275
    251276     RTFILE hOutput = NIL_RTFILE;
    252      uint32_t ofFlags =  RTFILE_O_CREATE_REPLACE /* Output file flags. */
    253                         | RTFILE_O_WRITE
    254                         | RTFILE_O_DENY_WRITE;
     277     uint32_t fFlags = RTFILE_O_CREATE_REPLACE /* Output file flags. */
     278                     | RTFILE_O_WRITE
     279                     | RTFILE_O_DENY_WRITE;
    255280
    256281     while (   (ch = RTGetOpt(&GetState, &ValueUnion))
     
    260285         switch (ch)
    261286         {
     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
    262291             case 'f':
    263292                 /* Process flags; no fancy parsing here yet. */
    264293                 if (RTStrIStr(ValueUnion.psz, "noindex"))
    265                      ofFlags |= RTFILE_O_NOT_CONTENT_INDEXED;
     294                     fFlags |= RTFILE_O_NOT_CONTENT_INDEXED;
    266295                 else
    267296                 {
     
    272301
    273302             case 'o':
    274                  rc = RTFileOpen(&hOutput, ValueUnion.psz, ofFlags);
     303                 rc = RTFileOpen(&hOutput, ValueUnion.psz, fFlags);
    275304                 if (RT_FAILURE(rc))
    276305                     VBoxServiceError("cat: Could not create output file \"%s\"! rc=%Rrc\n",
    277306                                      ValueUnion.psz, rc);
    278307                 break;
     308
     309                 /** @todo r=bird: Again, there shall be no need for any -i
     310                  *        options since all non-options are input files. */
    279311
    280312             case 'i':
     
    289321             }
    290322
     323             /** @todo r=bird: Missing handling of the standard options 'V' and
     324              *        'h'. */
     325
    291326             default:
    292327                 return RTGetOptPrintError(ch, &ValueUnion);
     
    315350int VBoxServiceToolboxMain(int argc, char **argv)
    316351{
     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). */
    317359    int rc = VERR_NOT_FOUND;
    318360    if (argc > 0) /* Do we have at least a main command? */
     
    326368                 || !strcmp(argv[0], "vbox_mkdir"))
    327369        {
    328             rc = VBoxServiceToolboxMkDir(argc, argv);
     370            rc = VBoxServiceToolboxCat(argc, argv);
    329371        }
    330372    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette