OSSP CVS Repository

ossp - Check-in [4034]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4034
Date: 2003-Feb-13 22:32:36 (local)
2003-Feb-13 21:32:36 (UTC)
User:ms
Branch:
Comment: Fixed bug in class Simplefile, trying to save to non-open file.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/as_sfile.cpp      1.1 -> 1.2     10 inserted, 8 deleted

ossp-pkg/as/as-gui/as_sfile.cpp 1.1 -> 1.2

--- as_sfile.cpp 2003/02/08 18:10:09     1.1
+++ as_sfile.cpp 2003/02/13 21:32:36     1.2
@@ -48,14 +48,16 @@
         Q_ASSERT(!this->exists());          // Conditionally short circuit
         Fname = this->name();               // Copy filename from original
         Filein.setName(Fname);              // Set filename of original
-        Filein.open(IO_ReadOnly);           // Open original read-only
-        Filebak.setName(Fname + ".bak");    // Set filename of backup
-        Filebak.open(IO_WriteOnly);         // Open backup write-only
-        Streamin.setDevice(&Filein);        // Set incoming stream
-        Streambak.setDevice(&Filebak);      // Set outgoing stream
-        Streambak << Streamin.read();       // Do actual writing
-        Filein.close();                     // Close original
-        Filebak.close();                    // Close backup
+        if (Filein.exists()) {              // Can only backup an existing file
+            Filein.open(IO_ReadOnly);           // Open original read-only
+            Filebak.setName(Fname + ".bak");    // Set filename of backup
+            Filebak.open(IO_WriteOnly);         // Open backup write-only
+            Streamin.setDevice(&Filein);        // Set incoming stream
+            Streambak.setDevice(&Filebak);      // Set outgoing stream
+            Streambak << Streamin.read();       // Do actual writing
+            Filein.close();                     // Close original
+            Filebak.close();                    // Close backup
+        }
     }
     catch (Genexcept& Genex) {
         Genex.reportErr();

CVSTrac 2.0.1