summaryrefslogtreecommitdiff
path: root/library
authoralwin <alwin>2005-03-07 14:37:57 (UTC)
committer alwin <alwin>2005-03-07 14:37:57 (UTC)
commit61b9d5f646faa5bd84391318f6440bee6cbefcd8 (patch) (unidiff)
treeb05eba6d4f33dd501c8fe6af0579567de7f659ec /library
parent9ac0dc3c7b4e56f38c3cefce2e5699078aa3a357 (diff)
downloadopie-61b9d5f646faa5bd84391318f6440bee6cbefcd8.zip
opie-61b9d5f646faa5bd84391318f6440bee6cbefcd8.tar.gz
opie-61b9d5f646faa5bd84391318f6440bee6cbefcd8.tar.bz2
when copying a file to another storage it checks if the target-dir
(eg <storage>/Documents/<mime>/<mimesub>) exists and create it otherwise.
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/lnkproperties.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/library/lnkproperties.cpp b/library/lnkproperties.cpp
index f0f0bba..f05f398 100644
--- a/library/lnkproperties.cpp
+++ b/library/lnkproperties.cpp
@@ -46,2 +46,3 @@
46#include <qfile.h> 46#include <qfile.h>
47#include <qdir.h>
47#include <qfileinfo.h> 48#include <qfileinfo.h>
@@ -249,2 +250,35 @@ void LnkProperties::beamLnk()
249 250
251static bool createMimedir(const QString&base,const QString&mimetype)
252{
253 int pos = 0;
254 int stage = 0;
255 if (base.length()==0) return FALSE;
256 QString _tname = base+"/Documents";
257 QDir _dir(_tname+"/"+mimetype);
258 if (_dir.exists()) return TRUE;
259 pos = mimetype.find("/");
260 _dir.setPath(_tname);
261 while (stage<2) {
262 if (!_dir.exists()) {
263 if (!_dir.mkdir(_tname)) {
264 qDebug( QString("Creation of dir %1 failed\n").arg(_tname));
265 return FALSE;
266 }
267 }
268 switch(stage) {
269 case 0:
270 _tname+="/"+mimetype.left(pos);
271 break;
272 case 1:
273 _tname+="/"+mimetype.right(pos-1);
274 break;
275 default:
276 break;
277 }
278 _dir.setPath(_tname);
279 ++stage;
280 }
281 return TRUE;
282}
283
250bool LnkProperties::copyFile( DocLnk &newdoc ) 284bool LnkProperties::copyFile( DocLnk &newdoc )
@@ -260,4 +294,8 @@ bool LnkProperties::copyFile( DocLnk &newdoc )
260 294
261 QString fn = locations[ d->locationCombo->currentItem() ] 295 QString fn = locations[ d->locationCombo->currentItem() ]
262 + "/Documents/" + newdoc.type() + "/" + safename; 296 + "/Documents/" + newdoc.type();
297 if (!createMimedir(locations[ d->locationCombo->currentItem() ],newdoc.type())) {
298 return FALSE;
299 }
300 fn+="/"+safename;
263 if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) { 301 if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) {