Changeset 1639


Ignore:
Timestamp:
2000-11-01T08:58:25+13:00 (23 years ago)
Author:
cs025
Message:

Further fixes to get around bloopers in Visual C++; it wasn't resetting the
status flags for a stream on the reopening of a file, also had forgotten to read
the old log file when doing an additional installation.

Location:
trunk/gsinstaller
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsinstaller/gsinstall.cpp

    r1638 r1639  
    353353  FilePath *logPath = new FilePath(this->destinationPath->pathString(), "install.log");
    354354  this->setLogFile(logPath->pathString());
    355   delete logPath;}
     355  this->readLog();
     356  delete logPath;
     357}
    356358
    357359bool GSInstall::setUninstall()
  • trunk/gsinstaller/unInstall.cpp

    r1638 r1639  
    55#include "File.h"
    66
    7 bool installManager::ensureLog()
     7bool installManager::logExists()
    88{
    99    HANDLE fHandle;
     
    1313                         FILE_ATTRIBUTE_NORMAL, NULL);
    1414    if (fHandle == INVALID_HANDLE_VALUE)
    15     {
    16         fHandle = CreateFile(this->logfileName.c_str(), GENERIC_READ | GENERIC_WRITE,
     15    {   return false;
     16    }
     17    CloseHandle(fHandle);
     18    return true;
     19}
     20
     21bool installManager::ensureLog()
     22{
     23    if (this->logExists() == false)
     24    {   HANDLE fHandle;
     25
     26        fHandle = CreateFile(this->logfileName.c_str(), GENERIC_READ | GENERIC_WRITE,
    1727                         FILE_SHARE_WRITE, NULL, CREATE_NEW,
    1828                             FILE_ATTRIBUTE_NORMAL, NULL);
     
    2434        return false;
    2535    }
    26     else
    27     {   CloseHandle(fHandle);
    28     }
    2936    return true;
    3037}
     
    4047    stringArray params;
    4148
    42   // open the log file
     49    // don't try to open an non-existing log; this has serious
     50    // repercussions with bad old VC++
     51    if (!this->logExists())
     52    {   this->setModule("default");
     53        this->changed = false;
     54        return true;
     55    }
     56
     57    // open the log file
    4358    this->logfile.open(this->logfileName.c_str(), ios::in);
    44 
    45     // Get the commands into this object from the existing log file
    46     while ((command = this->readCommand(params)) != "")
    47     {   if (command[0] == '[' && command[command.length()-1] == ']')
    48         { this->setModule(command.substr(1, command.length() - 2));
     59    if (this->logfile.is_open())
     60    {
     61        // Get the commands into this object from the existing log file
     62        while ((command = this->readCommand(params)) != "")
     63        {   if (command[0] == '[' && command[command.length()-1] == ']')
     64            { this->setModule(command.substr(1, command.length() - 2));
     65            }
     66            else
     67            {   unInstallCommand action(command, params);
     68                this->storeCommand(action);
     69            }
    4970        }
    50         else
    51         {   unInstallCommand action(command, params);
    52             this->storeCommand(action);
    53         }
     71
     72        // close the logfile
     73        this->logfile.close();
     74
     75        // and clear the status bits, 'cos VC++ doesn't clear them when
     76        // we reopen the file later.
     77        this->logfile.clear();
    5478    }
    5579    this->changed = false;
    56 
    57     // close the logfile
    58     this->logfile.close();
    5980 
    6081  // set to the default module
     
    216237    this->ensureLog();
    217238    this->logfile.open(this->logfileName.c_str(), ios::out);
    218    
     239    if (!this->logfile.is_open())
     240    {   MessageBox(0, "Unable to open log file", "Test", MB_OK);
     241    }
     242
    219243    unInstallCommandMap::iterator here = this->modules.begin();
    220244    unInstallCommandMap::iterator end  = this->modules.end();
  • trunk/gsinstaller/unInstall.h

    r1638 r1639  
    6565public:
    6666  installManager() { this->changed = false; }
     67  bool logExists();
    6768  bool setLogFile(string filename);
    6869  bool ensureLog();
Note: See TracChangeset for help on using the changeset viewer.