KCoreAddons
kautosavefile.cpp
65 const QByteArray encodedDirectory = QUrl::toPercentEncoding(managedFile.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).path());
76 const int pathLengthLimit = maxNameLength - NamePadding - fileName.size() - protocol.size() - 16;
80 fileName += QStringView(junk).right(3) + protocol + QLatin1Char('_') + QStringView(directory).left(pathLengthLimit) + junk;
136 QString staleFilesDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/stalefiles/")
171 // So in that case, extractManagedFilePath will return an incorrect truncated path for original source
179 const QByteArray encodedPath = stale.mid(pathPos + 1, staleFileName.length() - pathPos - 1 - KAutoSaveFilePrivate::NamePadding).toLatin1();
180 managedFileName.setPath(QUrl::fromPercentEncoding(encodedPath) + QLatin1Char('/') + QFileInfo(QUrl::fromPercentEncoding(managedFilename)).fileName());
195 const QByteArray encodedPath = stale.mid(pathPos + 1, staleFileName.length() - pathPos - 1 - KAutoSaveFilePrivate::NamePadding).toLatin1();
199QList<KAutoSaveFile *> KAutoSaveFile::staleFiles(const QUrl &filename, const QString &applicationName)
213 if (file.endsWith(QLatin1String(".lock")) || (!filename.isEmpty() && !staleMatchesManaged(QFileInfo(file).fileName(), filename))) {
218 KAutoSaveFile *asFile = new KAutoSaveFile(filename.isEmpty() ? extractManagedFilePath(file) : filename);
bool open(OpenMode openmode) override
Opens the autosave file and locks it if it wasn't already locked.
Definition kautosavefile.cpp:128
virtual void releaseLock()
Closes the autosave file resource and removes the lock file.
Definition kautosavefile.cpp:117
~KAutoSaveFile() override
Destroys the KAutoSaveFile object, removes the autosave file and drops the lock being held (if any).
Definition kautosavefile.cpp:98
QUrl managedFile() const
Retrieves the URL of the file managed by KAutoSaveFile.
Definition kautosavefile.cpp:104
static QList< KAutoSaveFile * > allStaleFiles(const QString &applicationName=QString())
Returns all stale autosave files left behind by crashed or otherwise gone instances of this applicati...
Definition kautosavefile.cpp:227
KAutoSaveFile(const QUrl &filename, QObject *parent=nullptr)
Constructs a KAutoSaveFile for file filename.
Definition kautosavefile.cpp:85
void setManagedFile(const QUrl &filename)
Sets the URL of the file managed by KAutoSaveFile.
Definition kautosavefile.cpp:109
static QList< KAutoSaveFile * > staleFiles(const QUrl &url, const QString &applicationName=QString())
Checks for stale autosave files for the file url.
Definition kautosavefile.cpp:199
KCOREADDONS_EXPORT QString randomString(int length)
Generates a random string.
Definition krandom.cpp:30
QCA_EXPORT QString appName()
QByteArray left(qsizetype len) const const
QByteArray mid(qsizetype pos, qsizetype len) const const
bool startsWith(QByteArrayView bv) const const
QChar fromLatin1(char c)
applicationName
QCoreApplication * instance()
Files
virtual QString fileName() const const override
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
bool remove()
void setFileName(const QString &name)
virtual void close() override
OpenMode
void append(QList< T > &&value)
GenericDataLocation
QStringList standardLocations(StandardLocation type)
QString writableLocation(StandardLocation type)
QString fromLatin1(QByteArrayView str)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype length() const const
qsizetype size() const const
QStringView left(qsizetype length) const const
QStringView right(qsizetype length) const const
RemoveFilename
QUrl adjusted(FormattingOptions options) const const
QString fileName(ComponentFormattingOptions options) const const
QString fromPercentEncoding(const QByteArray &input)
bool isEmpty() const const
QString path(ComponentFormattingOptions options) const const
QString scheme() const const
void setPath(const QString &path, ParsingMode mode)
QByteArray toPercentEncoding(const QString &input, const QByteArray &exclude, const QByteArray &include)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.