Commit e3ff89b4 authored by Michal Humpula's avatar Michal Humpula

port away from kde_file.h

parent fd7a8dad
......@@ -29,8 +29,9 @@
#include "katepartdebug.h"
// fdatasync
#include <kde_file.h>
#if HAVE_FDATASYNC
#include <unistd.h>
#endif
#include <KSaveFile>
#include <kdeversion.h>
......
......@@ -25,30 +25,26 @@
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include "katedocument.h"
#include "katehighlight.h"
#include "kateconfig.h"
#include "kateglobal.h"
#include "kateautoindent.h"
#include "katepartdebug.h"
#include <klocalizedstring.h>
#include "katepartdebug.h"
#include <kglobal.h>
#include <kcharsets.h>
#include <kde_file.h>
// on the fly compression
#include <kfilterdev.h>
#include <kde_file.h>
#include <QtCore/QDate>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QTextCodec>
#include <QtCore/QTextStream>
#include <QtCore/QTimer>
#include <QtCore/QTextCodec>
#include <QtCore/QDate>
#include <limits.h>
/**
* Initial value for m_maxDynamicContexts
......@@ -202,8 +198,7 @@ bool KateBuffer::openFile (const QString &m_file, bool enforceTextCodec)
* check if this is a normal file or not, avoids to open char devices or directories!
* else clear buffer and break out with error
*/
KDE_struct_stat sbuf;
if (KDE::stat(m_file, &sbuf) != 0 || !S_ISREG(sbuf.st_mode)) {
if (!QFileInfo(m_file).isFile()) {
clear ();
return false;
}
......
......@@ -35,7 +35,6 @@
#include <klocalizedstring.h>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <kde_file.h>
#include "kateglobal.h"
#include "katecmd.h"
......@@ -137,18 +136,16 @@ void KateScriptManager::collect(bool force)
const QString baseName = fi.baseName ();
// each file has a group
const QString group = "Cache "+ fileName;
const QString group(QLatin1String("Cache ") + fileName);
KConfigGroup config(&cfgFile, group);
// stat the file to get the last-modified-time
KDE_struct_stat sbuf;
memset(&sbuf, 0, sizeof(sbuf));
KDE::stat(fileName, &sbuf);
const int lastModified = QFileInfo(fileName).lastModified().toTime_t();
// check whether file is already cached
bool useCache = false;
if(!force && cfgFile.hasGroup(group)) {
useCache = (sbuf.st_mtime == config.readEntry("last-modified", 0));
useCache = (lastModified == config.readEntry("last-modified", 0));
}
// read key/value pairs from the cached file if possible
......@@ -162,7 +159,7 @@ void KateScriptManager::collect(bool force)
pairs[entry.key()] = entry.value();
}
else if(parseMetaInformation(fileName, pairs)) {
config.writeEntry("last-modified", int(sbuf.st_mtime));
config.writeEntry("last-modified", lastModified);
// iterate keys and save cache
for(QHash<QString, QString>::ConstIterator item = pairs.constBegin();
item != pairs.constEnd();
......
......@@ -30,9 +30,7 @@
#include <ktexteditor/view.h>
#include <kde_file.h>
#include <klocale.h>
#include <kicon.h>
#include <klocalizedstring.h>
#include <kstandardguiitem.h>
......@@ -40,6 +38,9 @@
#include <QDir>
#include <QApplication>
#ifdef HAVE_FDATASYNC
#include <unistd.h>
#endif
// swap file version header
const static char * const swapFileVersionString = "Kate Swap File 2.0";
......
......@@ -30,7 +30,6 @@
#include <klocale.h>
#include <kmessagebox.h>
#include <kconfiggroup.h>
#include <kde_file.h>
#include <QtWidgets/QApplication>
#include <QtCore/QFile>
......@@ -386,18 +385,15 @@ void KateSyntaxDocument::setupModeList (bool force)
for ( QStringList::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it )
{
// Each file has a group called:
QString Group="Cache "+ *it;
QString group(QLatin1String("Cache ") + *it);
// Let's go to this group
KConfigGroup config(m_config, Group);
KConfigGroup config(m_config, group);
// stat the file
KDE_struct_stat sbuf;
memset (&sbuf, 0, sizeof(sbuf));
KDE::stat(*it, &sbuf);
const int lastModified = QFileInfo(group).lastModified().toTime_t();
// If the group exist and we're not forced to read the xml file, let's build myModeList for katesyntax..rc
if (!force && config.exists() && (sbuf.st_mtime == config.readEntry("lastModified",0)))
if (!force && config.exists() && (lastModified == config.readEntry("lastModified",0)))
{
// Let's make a new KateSyntaxModeListItem to instert in myModeList from the information in katesyntax..rc
KateSyntaxModeListItem *mli=new KateSyntaxModeListItem;
......@@ -467,7 +463,7 @@ void KateSyntaxDocument::setupModeList (bool force)
mli->identifier = *it;
// Now let's write or overwrite (if force==true) the entry in katesyntax...rc
config = KConfigGroup(m_config, Group);
config = KConfigGroup(m_config, group);
config.writeEntry("name",mli->name);
config.writeEntry("section",mli->section);
config.writeEntry("mimetype",mli->mimetype);
......@@ -481,7 +477,7 @@ void KateSyntaxDocument::setupModeList (bool force)
config.writeEntry("hidden",mli->hidden);
// modified time to keep cache in sync
config.writeEntry("lastModified", int(sbuf.st_mtime));
config.writeEntry("lastModified", lastModified);
// Now that the data is in the config file, translate section
mli->section = i18nc("Language Section",mli->section.toUtf8().data());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment