KIO
Go to the documentation of this file.
22 #include <QtCore/QFile>
23 #include <QtCore/QMutableStringListIterator>
24 #include <QtCore/QTextIStream>
32 class KNFSShare::KNFSSharePrivate
37 void _k_slotFileChange(
const QString&);
39 bool readExportsFile();
40 bool findExportsFile();
47 KNFSShare::KNFSSharePrivate::KNFSSharePrivate(
KNFSShare *parent )
50 if (findExportsFile())
60 bool KNFSShare::KNFSSharePrivate::findExportsFile()
64 exportsFile =
config.readPathEntry(
"exportsFile", QString());
66 if ( QFile::exists(exportsFile) )
69 if ( QFile::exists(
"/etc/exports") )
70 exportsFile =
"/etc/exports";
72 kDebug(7000) <<
"Could not find exports file! /etc/exports doesn't exist. Configure it in share/config/knfsshare, [General], exportsFile=....";
76 config.writeEntry(
"exportsFile",exportsFile);
84 bool KNFSShare::KNFSSharePrivate::readExportsFile()
90 if (!
f.open(QIODevice::ReadOnly)) {
91 kError() <<
"KNFSShare: Could not open" << exportsFile;
99 bool continuedLine =
false;
100 QString completeLine;
104 QString currentLine = s.readLine().trimmed();
107 completeLine += currentLine;
108 continuedLine =
false;
111 completeLine = currentLine;
114 if ( completeLine.endsWith(QLatin1Char(
'\\')) )
116 continuedLine =
true;
118 completeLine.chop(1);
123 if (completeLine.startsWith(QLatin1Char(
'#')) || completeLine.isEmpty())
131 if ( completeLine[0] == QLatin1Char(
'\"') ) {
132 int i = completeLine.indexOf(QLatin1Char(
'"'), 1);
134 kError() <<
"KNFSShare: Parse error: Missing quotation mark:" << completeLine;
137 path = completeLine.mid(1,i-1);
140 int i = completeLine.indexOf(QLatin1Char(
' '));
142 i = completeLine.indexOf(QLatin1Char(
'\t'));
147 path = completeLine.left(i);
153 if (!path.isEmpty()) {
155 if ( !path.endsWith(QLatin1Char(
'/')) )
156 path += QLatin1Char(
'/');
158 sharedPaths.insert(path);
165 KNFSShare::KNFSShare()
166 : d(new KNFSSharePrivate(this))
168 if (QFile::exists(d->exportsFile)) {
171 SLOT(_k_slotFileChange(QString)));
189 QString fixedPath = path;
190 if ( path[path.length()-1] !=
'/' )
193 return d->sharedPaths.contains(fixedPath);
198 return d->sharedPaths.values();
203 return d->exportsFile;
208 void KNFSShare::KNFSSharePrivate::_k_slotFileChange(
const QString & path )
210 if (path == exportsFile)
223 #include "knfsshare.moc"
static KNFSShare * instance()
Returns the one and only instance of KNFSShare.
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
void addFile(const QString &file)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
bool isDirectoryShared(const QString &path) const
Whether or not the given path is shared by NFS.
virtual ~KNFSShare()
KNFSShare destructor.
KSharedConfigPtr config()
static KDirWatch * self()
static quint32 f(DES_KEY *key, quint32 r, char *subkey)
QString exportsPath() const
Returns the path to the used exports file, or null if no exports file was found.
#define K_GLOBAL_STATIC(TYPE, NAME)
QStringList sharedDirectories() const
Returns a list of all directories shared by NFS.
Similar functionality like KFileShare, but works only for NFS and do not need any suid script.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun Jan 19 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.