[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kbibtex] src/io: Create subdirectory to cache text extracted from PDF files
From:       Thomas Fischer <null () kde ! org>
Date:       2017-03-31 21:56:22
Message-ID: E1cu4Ws-0004Se-NF () code ! kde ! org
[Download RAW message or body]

Git commit 4c957b01663bd6155913d443ae4c3859297d134f by Thomas Fischer.
Committed on 31/03/2017 at 21:43.
Pushed by thomasfischer into branch 'master'.

Create subdirectory to cache text extracted from PDF files

M  +6    -2    src/io/fileinfo.cpp

https://commits.kde.org/kbibtex/4c957b01663bd6155913d443ae4c3859297d134f

diff --git a/src/io/fileinfo.cpp b/src/io/fileinfo.cpp
index 4710310d..85867467 100644
--- a/src/io/fileinfo.cpp
+++ b/src/io/fileinfo.cpp
@@ -284,8 +284,12 @@ QList<QUrl> FileInfo::entryUrls(const QSharedPointer<const \
Entry> &entry, const  QString FileInfo::pdfToText(const QString &pdfFilename)
 {
     /// Build filename for text file where PDF file's plain text is cached
-    static const QRegExp invalidChars("[^-a-z0-9_]", Qt::CaseInsensitive);
-    QString textFilename = \
QString(pdfFilename).remove(invalidChars).append(QStringLiteral(".txt")).prepend(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) \
+ QLatin1Char('/') + "pdftotext/"); +    static const QRegExp \
invalidChars(QStringLiteral("[^-a-z0-9_]"), Qt::CaseInsensitive); +    const QString \
cacheDirectory = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + \
QStringLiteral("/pdftotext"); +    if (!QDir(cacheDirectory).exists() && \
!QDir::home().mkdir(cacheDirectory)) +        /// Could not create cache directory
+        return QString();
+    const QString textFilename = \
QString(pdfFilename).remove(invalidChars).append(QStringLiteral(".txt")).prepend(QStringLiteral("/")).prepend(cacheDirectory);
  
     /// First, check if there is a cache text file
     if (QFileInfo::exists(textFilename)) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic