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()
 
   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; 
 
  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)));
 
  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 KDirWatch * self()
void addFile(const QString &file)
#define K_GLOBAL_STATIC(TYPE, NAME)
static QDebug kError(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
static quint32 f(DES_KEY *key, quint32 r, char *subkey)
virtual ~KNFSShare()
KNFSShare destructor. 
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KSharedConfigPtr config()
bool isDirectoryShared(const QString &path) const 
Whether or not the given path is shared by NFS. 
static KNFSShare * instance()
Returns the one and only instance of KNFSShare. 
Similar functionality like KFileShare, but works only for NFS and do not need any suid script...
QStringList sharedDirectories() const 
Returns a list of all directories shared by NFS. 
QString exportsPath() const 
Returns the path to the used exports file, or null if no exports file was found.