1 // |
1 // |
2 // OSSP asgui - Accounting system graphical user interface |
2 // OSSP asgui - Accounting system graphical user interface |
3 // Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) |
3 // Copyright (c) 2002-2008 The OSSP Project (http://www.ossp.org/) |
4 // Copyright (c) 2002-2004 Ralf S. Engelschall <rse@engelschall.com> |
4 // Copyright (c) 2002-2008 Ralf S. Engelschall <rse@engelschall.com> |
5 // Copyright (c) 2002-2004 Michael Schloh von Bennewitz <michael@schloh.com> |
5 // Copyright (c) 2002-2008 Michael Schloh von Bennewitz <michael@schloh.com> |
6 // Copyright (c) 2002-2004 Cable & Wireless Telecommunications Services GmbH |
6 // Copyright (c) 2002-2008 Cable & Wireless Telecommunications Services GmbH |
7 // |
7 // |
8 // This file is part of OSSP asgui, an accounting system graphical user |
8 // This file is part of OSSP asgui, an accounting system graphical user |
9 // interface which can be found at http://www.ossp.org/pkg/tool/asgui/. |
9 // interface which can be found at http://asgui.europalab.com/. |
10 // |
10 // |
11 // Permission to use, copy, modify, and distribute this software for |
11 // Permission to use, copy, modify, and distribute this software for |
12 // any purpose with or without fee is hereby granted, provided that |
12 // any purpose with or without fee is hereby granted, provided that |
13 // the above copyright notice and this permission notice appear in all |
13 // the above copyright notice and this permission notice appear in all |
14 // copies. |
14 // copies. |
30 // |
30 // |
31 |
31 |
32 #include "as_sfile.h" |
32 #include "as_sfile.h" |
33 #include "as_except.h" |
33 #include "as_except.h" |
34 |
34 |
|
35 //Added by qt3to4: |
|
36 #include <Q3TextStream> |
|
37 |
35 |
38 |
36 // |
39 // |
37 // Serialize a backup of an incoming file object |
40 // Serialize a backup of an incoming file object |
38 // |
41 // |
39 void Simplefile::makeBackup(void) |
42 void Simplefile::makeBackup(void) |
40 { |
43 { |
41 QFile Filein; // Input readonly file |
44 QFile Filein; // Input readonly file |
42 QFile Filebak; // Backup writeonly file |
45 QFile Filebak; // Backup writeonly file |
43 QString Fname; // Filename of input file |
46 QString Fname; // Filename of input file |
44 QTextStream Streamin; // Stream to read from (Filein) |
47 Q3TextStream Streamin; // Stream to read from (Filein) |
45 QTextStream Streambak; // Stream to write to (Filebak) |
48 Q3TextStream Streambak; // Stream to write to (Filebak) |
46 |
49 |
47 try { |
50 try { |
48 if(!this->exists()) // Conditionally short circuit if |
51 if(!this->exists()) // Conditionally short circuit if |
49 return; // file to backup does not exist |
52 return; // file to backup does not exist |
50 Fname = this->name(); // Copy filename from original |
53 Fname = this->name(); // Copy filename from original |
51 Filein.setName(Fname); // Set filename of original |
54 Filein.setName(Fname); // Set filename of original |
52 Filein.open(IO_ReadOnly); // Open original read-only |
55 Filein.open(QIODevice::ReadOnly); // Open original read-only |
53 Filebak.setName(Fname + ".bak"); // Set filename of backup |
56 Filebak.setName(Fname + ".bak"); // Set filename of backup |
54 Filebak.open(IO_WriteOnly); // Open backup write-only |
57 Filebak.open(QIODevice::WriteOnly); // Open backup write-only |
55 Streamin.setDevice(&Filein); // Set incoming stream |
58 Streamin.setDevice(&Filein); // Set incoming stream |
56 Streambak.setDevice(&Filebak); // Set outgoing stream |
59 Streambak.setDevice(&Filebak); // Set outgoing stream |
57 Streambak << Streamin.read(); // Do actual writing |
60 Streambak << Streamin.read(); // Do actual writing |
58 Filein.close(); // Close original |
61 Filein.close(); // Close original |
59 Filebak.close(); // Close backup |
62 Filebak.close(); // Close backup |