author | tille <tille> | 2002-06-29 20:53:42 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-29 20:53:42 (UTC) |
commit | cbb1662a1c3bca476294100ce5e0d0eeb3655639 (patch) (unidiff) | |
tree | e7deb5afdba0d5fa843675669ae3e089c168d022 /noncore/apps/confedit/listviewitemconffile.cpp | |
parent | 5960b3a2823037c63afba09ca83dbcc0943cd082 (diff) | |
download | opie-cbb1662a1c3bca476294100ce5e0d0eeb3655639.zip opie-cbb1662a1c3bca476294100ce5e0d0eeb3655639.tar.gz opie-cbb1662a1c3bca476294100ce5e0d0eeb3655639.tar.bz2 |
makes backups, but does not save the file yet
Diffstat (limited to 'noncore/apps/confedit/listviewitemconffile.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/confedit/listviewitemconffile.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp index 5457384..a8fd770 100644 --- a/noncore/apps/confedit/listviewitemconffile.cpp +++ b/noncore/apps/confedit/listviewitemconffile.cpp | |||
@@ -23,3 +23,2 @@ ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent) | |||
23 | parseFile(); | 23 | parseFile(); |
24 | _changed = false; | ||
25 | displayText(); | 24 | displayText(); |
@@ -34,3 +33,3 @@ void ListViewItemConfFile::displayText() | |||
34 | { | 33 | { |
35 | setText(0,(_changed?"*":"*")+confFileInfo->fileName()); | 34 | setText(0,(_changed?"*":"")+confFileInfo->fileName()); |
36 | } | 35 | } |
@@ -44,6 +43,3 @@ void ListViewItemConfFile::parseFile() | |||
44 | { | 43 | { |
45 | qDebug( confFileInfo->absFilePath() ); | ||
46 | QFile confFile(confFileInfo->absFilePath()); | 44 | QFile confFile(confFileInfo->absFilePath()); |
47 | qDebug( confFileInfo->absFilePath() ); | ||
48 | // QString fileName = confFileInfo->fileName(); | ||
49 | if(! confFile.open(IO_ReadOnly)) | 45 | if(! confFile.open(IO_ReadOnly)) |
@@ -66,3 +62,3 @@ void ListViewItemConfFile::parseFile() | |||
66 | { | 62 | { |
67 | qDebug("got group"+s); | 63 | // qDebug("got group"+s); |
68 | group = s.mid(1,s.length()-2); | 64 | group = s.mid(1,s.length()-2); |
@@ -84,3 +80,18 @@ void ListViewItemConfFile::save() | |||
84 | { | 80 | { |
85 | qDebug("ListViewItemConfFile::save()"); | 81 | if (!_changed) return; |
82 | QString backup = confFileInfo->absFilePath()+"~"; | ||
83 | qDebug("make backup to "+backup); | ||
84 | QFile conf(confFileInfo->absFilePath()); | ||
85 | QFile back(backup); | ||
86 | |||
87 | if (!conf.open(IO_ReadOnly)) return; | ||
88 | if (!back.open(IO_WriteOnly)) return; | ||
89 | |||
90 | #define SIZE 124 | ||
91 | char buf[SIZE]; | ||
92 | while (int c = conf.readBlock(buf, SIZE) ) back.writeBlock(buf,c); | ||
93 | conf.close(); | ||
94 | back.close(); | ||
95 | |||
96 | |||
86 | qDebug("no saveing yet..."); | 97 | qDebug("no saveing yet..."); |