Ignore:
Timestamp:
2000-09-12T13:36:44+12:00 (24 years ago)
Author:
sjboddie
Message:

Got compiling on VC++ 4.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsinstaller/gsManifest.cpp

    r1536 r1539  
    88gsManifest::gsManifest(installManager &manager)
    99  : installAgent(manager)
    10 {   // do nothing!
     10{   
     11  // do nothing!
    1112}
    1213
    1314gsManifest::gsManifest(installManager &manager, FilePath &root)
    1415  : installAgent(manager), fileCopyMonitor()
    15 {   this->getManifest(root);
    16     this->expandGroups();
     16{   
     17  this->getManifest(root);
     18  this->expandGroups();
    1719}
    1820
    1921bool gsManifest::getManifest(FilePath &root)
    20 { FilePath *manifestPath = new FilePath((char *) root.cString(), "manifest.cfg");
    21     FILE *    file;
    22   DWORD         fileSize;
    23   string        currentgroup;
    24   char *        buffer;
    25   char *        line;
    26   char *        eol;
    27 
    28     // open file handle for read access
     22{
     23  FilePath *manifestPath = new FilePath((char *) root.cString(), "manifest.cfg");
     24  FILE *file;
     25  DWORD fileSize;
     26  string currentgroup;
     27  char *buffer;
     28  char *line;
     29  char *eol;
     30
     31  // open file handle for read access
    2932  file = fopen(manifestPath->cString(), "rb");
    30     if (file == NULL)
    31   { return false;
    32   }
     33  if (file == NULL)
     34    {
     35      return false;
     36    }
    3337
    3438  // get size of file
    3539  File f(manifestPath->cString());
    36   fileSize  = f.getFileSize();
     40  fileSize = f.getFileSize();
    3741
    3842  // allocate buffer for whole file and read it in
    39     buffer  = new char[fileSize];
     43  buffer = new char[fileSize];
    4044  if (fread(buffer, 1, fileSize, file) < fileSize)
    41   { // TODO: error handling
    42   }
     45    {   
     46      // TODO: error handling
     47    }
    4348  fclose(file);
    4449
    4550  //parse file into lines and send to the line fn
    4651  line  = buffer;
    47   while ((eol = strchr(line, '\x0a')) != NULL)  // use 0a for the eol to remove
    48                                                 // dependency on dos 0d,0a eol
    49   { *eol = '\0';
    50 
    51     this->getManifestLine(line, currentgroup);
    52 
    53     line = eol + 1;
    54   }
     52  while ((eol = strchr(line, '\x0a')) != NULL) 
     53    // use 0a for the eol to remove
     54    // dependency on dos 0d,0a eol
     55    {   
     56      *eol = '\0';
     57
     58      this->getManifestLine(line, currentgroup);
     59
     60      line = eol + 1;
     61    }
    5562  this->getManifestLine(line, currentgroup);
    5663
    57     delete buffer;
     64  delete buffer;
    5865  return true;
    5966}
    6067
    6168bool gsManifest::getManifestLine(char *line, string &group)
    62 { char *eol;    // we (potentially) need to clean up the end of
    63               // line, and we won't use the eol from the main
    64               // getManifest fn. as for the last line it'd be
    65               // null.
    66 
    67     // clean up the start of the line
    68     while (*line <= ' ' && *line != '\0')
    69     { line ++;
    70   }
     69{
     70  char *eol; // we (potentially) need to clean up the end of
     71             // line, and we won't use the eol from the main
     72             // getManifest fn. as for the last line it'd be
     73             // null.
     74
     75  // clean up the start of the line
     76  while (*line <= ' ' && *line != '\0')
     77    {
     78      line ++;
     79    }
    7180
    7281  // it's a blank line - don't bother!
    73   if (line == '\0')
    74   { return true;
    75   }
     82  if (*line == '\0')
     83    {
     84      return true;
     85    }
    7686
    7787  // clean up the end of line
    78   eol   = line + strlen(line) - 1;
     88  eol = line + strlen(line) - 1;
    7989  while (*eol <= ' ' && eol >= line)
    80   { *eol = '\0';
    81     eol --;
    82   }
     90    {   
     91      *eol = '\0';
     92      eol --;
     93    }
    8394
    8495  // does the line end with a colon?; if so take it as a group definition
    8596  if (*eol == ':')
    86   { if (eol == line) // if it's literally just a colon do nothing
    87     {   return true;
    88     }
    89 
    90     // note the new group name
    91     string newgroup(line, 0, eol - line);
    92     group = newgroup;
    93   }
     97    {
     98      if (eol == line) // if it's literally just a colon do nothing
     99    {
     100      return true;
     101    }
     102
     103      // note the new group name
     104      string newgroup(line, 0, eol - line);
     105      group = newgroup;
     106    }
    94107  // if it starts with a hash it's just a comment line; skip it
    95108  else if (*line == '#')
    96   { // do nothing!
    97   }
     109    {   
     110      // do nothing!
     111    }
    98112  // an actual line of member items; read them in
    99113  else
    100   { stringArray array;
    101     array   =   stringArray::words(line);
    102 
    103     if (group.length() == 0)
    104     {   this->manifests["all"].add(array);
    105     }
    106     else
    107     {   this->manifests[group].add(array);
    108     }
    109   }
     114    {   
     115      stringArray array;
     116      array = stringArray::words(line);
     117
     118      if (group.length() == 0)
     119    {   
     120      this->manifests["all"].add(array);
     121    }
     122      else
     123    {   
     124      this->manifests[group].add(array);
     125    }
     126    }
    110127  return true;
    111128}
     
    209226
    210227void gsManifest::clearSelection()
    211 {   this->selected.empty();
     228{   
     229  this->selected.empty();
    212230}
    213231
     
    226244 */
    227245bool gsManifest::copy(FilePath *source)
    228 { fileCopier    copy(this);
    229 
    230     pathStringArrayMap::iterator here = this->selected.begin();
    231   pathStringArrayMap::iterator end  = this->selected.end();
     246{
     247  fileCopier copy(this);
     248
     249  pathStringArrayMap::iterator here = this->selected.begin();
     250  pathStringArrayMap::iterator end = this->selected.end();
    232251
    233252  // add all the sets to copy to the manifest
    234253  while (here != end)
    235   { FileVector *fileList;
    236     stringArray &array = (*here).second;
    237     FilePath path((*here).first);
    238 
    239     // TODO: eliminate inefficiency; we're doing FilePath->string->FilePath in
    240     // effect between constructing the copy lists, and then the sets, as far
    241     // as the destinations go
    242     fileList = this->selection(*source, array);
    243     fileCopySet copySet(*fileList, *source, path);
    244     copy.addSet(copySet);
    245         delete fileList;
    246     here ++;
    247   }
     254    {
     255      FileVector *fileList;
     256      stringArray &array = (*here).second;
     257      FilePath path((*here).first);
     258
     259      // TODO: eliminate inefficiency; we're doing FilePath->string->FilePath in
     260      // effect between constructing the copy lists, and then the sets, as far
     261      // as the destinations go
     262      fileList = this->selection(*source, array);
     263      fileCopySet copySet(*fileList, *source, path);
     264      copy.addSet(copySet);
     265      delete fileList;
     266      here ++;
     267    }
    248268
    249269  // check that we've got enough space @ the destination(s)
    250270  if (!copy.checkSpace())
    251   { return false;
    252   }
     271    {   
     272      return false;
     273    }
    253274
    254275  // do the actual copying
     
    258279
    259280void gsManifest::copied(string from, string to, bool isDir)
    260 { if (isDir)
    261     {   this->logAction("Manifest.CreateDir", to);
    262     }
     281{
     282  if (isDir)
     283    {
     284      this->logAction("Manifest.CreateDir", to);
     285    }
    263286  else
    264   { this->logAction("Manifest.CopyFile", from, to);
    265   }
     287    {   
     288      this->logAction("Manifest.CopyFile", from, to);
     289    }
    266290}
    267291
    268292void gsManifest::logAction(string actionName, string file)
    269 { unInstallCommand command(actionName);
    270     command.addParameter(file);
     293{
     294  unInstallCommand command(actionName);
     295  command.addParameter(file);
    271296  manager->storeCommand(command);
    272297}
    273298
    274299void gsManifest::logAction(string actionName, string source, string dest)
    275 {   unInstallCommand command(actionName);
    276     command.addParameter(source);
     300{
     301  unInstallCommand command(actionName);
     302  command.addParameter(source);
    277303  command.addParameter(dest);
    278304  manager->storeCommand(command);
     
    280306
    281307bool gsManifest::undoAction(string actionName, stringArray &params)
    282 {   if (actionName == "Manifest.CreateDir" || actionName == "CreateDir")
    283     {   RemoveDirectory(params[0].c_str());
    284       return true;
    285   }
     308{   
     309  if (actionName == "Manifest.CreateDir" || actionName == "CreateDir")
     310    {
     311      RemoveDirectory(params[0].c_str());
     312      return true;
     313    }
    286314  else if (actionName == "Manifest.CopyFile" || actionName == "CopyFile")
    287     {   DeleteFile(params[1].c_str());
    288     return true;
    289   }
     315    {
     316      DeleteFile(params[1].c_str());
     317      return true;
     318    }
    290319  return false;
    291320}
    292321
    293322FileVector *gsManifest::selection(FilePath &root, stringArray &array)
    294 {   FileVector *reply = new FileVector();
     323{
     324  FileVector *reply = new FileVector();
    295325
    296326  for (unsigned int i = 0; i < array.size(); i++)
    297   { FilePath    fileName(root.pathString(), array[i]);
    298     File file(fileName.pathString());
    299     reply->push_back(file);
     327  {
     328    FilePath fileName(root.pathString(), array[i]);
     329    File file(fileName.pathString());
     330    reply->push_back(file);
    300331  }
    301332  return reply;
     
    303334
    304335FileVector *gsManifest::selection(FilePath &source, FilePath &destination)
    305 {   return this->selection(source, this->selected[destination]);
    306 }
    307 
     336{
     337  return this->selection(source, this->selected[destination]);
     338}
     339
Note: See TracChangeset for help on using the changeset viewer.