summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (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
@@ -45,4 +45,5 @@
#include <qlayout.h>
#include <qfile.h>
+#include <qdir.h>
#include <qfileinfo.h>
#include <qmessagebox.h>
@@ -248,4 +249,37 @@ void LnkProperties::beamLnk()
}
+static bool createMimedir(const QString&base,const QString&mimetype)
+{
+ int pos = 0;
+ int stage = 0;
+ if (base.length()==0) return FALSE;
+ QString _tname = base+"/Documents";
+ QDir _dir(_tname+"/"+mimetype);
+ if (_dir.exists()) return TRUE;
+ pos = mimetype.find("/");
+ _dir.setPath(_tname);
+ while (stage<2) {
+ if (!_dir.exists()) {
+ if (!_dir.mkdir(_tname)) {
+ qDebug( QString("Creation of dir %1 failed\n").arg(_tname));
+ return FALSE;
+ }
+ }
+ switch(stage) {
+ case 0:
+ _tname+="/"+mimetype.left(pos);
+ break;
+ case 1:
+ _tname+="/"+mimetype.right(pos-1);
+ break;
+ default:
+ break;
+ }
+ _dir.setPath(_tname);
+ ++stage;
+ }
+ return TRUE;
+}
+
bool LnkProperties::copyFile( DocLnk &newdoc )
{
@@ -259,6 +293,10 @@ bool LnkProperties::copyFile( DocLnk &newdoc )
safename.replace(QRegExp("/"),"_");
- QString fn = locations[ d->locationCombo->currentItem() ]
- + "/Documents/" + newdoc.type() + "/" + safename;
+ QString fn = locations[ d->locationCombo->currentItem() ]
+ + "/Documents/" + newdoc.type();
+ if (!createMimedir(locations[ d->locationCombo->currentItem() ],newdoc.type())) {
+ return FALSE;
+ }
+ fn+="/"+safename;
if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) {
int n=1;