Slight improvements on Windows.
authorAkos Polster <akos@pipacs.com>
Tue, 28 Sep 2010 22:24:41 +0000 (00:24 +0200)
committerAkos Polster <akos@pipacs.com>
Tue, 28 Sep 2010 22:24:41 +0000 (00:24 +0200)
books/2 B R 0 2 B.epub [deleted file]
books/2BR02B.epub [new file with mode: 0644]
dorian.qrc
mainwindow.cpp
model/book.cpp

diff --git a/books/2 B R 0 2 B.epub b/books/2 B R 0 2 B.epub
deleted file mode 100644 (file)
index fb83a99..0000000
Binary files a/books/2 B R 0 2 B.epub and /dev/null differ
diff --git a/books/2BR02B.epub b/books/2BR02B.epub
new file mode 100644 (file)
index 0000000..fb83a99
Binary files /dev/null and b/books/2BR02B.epub differ
index 1668787..e6e0429 100644 (file)
@@ -22,7 +22,6 @@
         <file>icons/bookmark.png</file>
         <file>icons/bookmarks.png</file>
         <file>icons/mac/bookmarks.png</file>
-        <file>books/2 B R 0 2 B.epub</file>
         <file>styles/day.js</file>
         <file>styles/default.js</file>
         <file>styles/night.js</file>
@@ -42,5 +41,6 @@
         <file>icons/info.png</file>
         <file>icons/mac/info.png</file>
         <file>icons/mac/library.png</file>
+        <file>books/2BR02B.epub</file>
     </qresource>
 </RCC>
index 6a539b9..42fd7e0 100755 (executable)
@@ -131,7 +131,7 @@ MainWindow::MainWindow(QWidget *parent):
         }
         else {
             if (!library->rowCount()) {
-                library->add(":/books/2 B R 0 2 B.epub");
+                library->add(":/books/2BR02B.epub");
             }
             library->setNowReading(library->index(0));
         }
index 8b7bd4a..5303f9b 100644 (file)
@@ -97,7 +97,8 @@ void Book::close()
 QString Book::tmpDir() const
 {
     QString tmpName = QFileInfo(mTempFile.fileName()).fileName();
-    return QDir::tempPath() + "/dorian/" + tmpName;
+    return QDir(QDir::temp().absoluteFilePath("dorian")).
+            absoluteFilePath(tmpName);
 }
 
 bool Book::extract()
@@ -112,20 +113,22 @@ bool Book::extract()
         qCritical() << "Book::extract: Failed to remove" << tmp;
         return false;
     }
-    QDir d;
-    if (!d.mkpath(tmp)) {
-        qCritical() << "Book::extract: Could not create" << tmp;
-        return false;
+    QDir d(tmp);
+    if (!d.exists()) {
+        if (!d.mkpath(tmp)) {
+            qCritical() << "Book::extract: Could not create" << tmp;
+            return false;
+        }
     }
 
     // If book comes from resource, copy it to the temporary directory first
     QString bookPath = path();
     if (bookPath.startsWith(":/books/")) {
         QFile src(bookPath);
-        QString dst(tmp + "/book.epub");
+        QString dst(QDir(tmp).absoluteFilePath("book.epub"));
         if (!src.copy(dst)) {
-            qCritical() << "Book::extract: Failed to copy built-in book to"
-                    << dst;
+            qCritical() << "Book::extract: Failed to copy built-in book"
+                    << bookPath << "to" << dst;
             return false;
         }
         bookPath = dst;