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

List:       kde-commits
Subject:    kdelibs/kio/kio
From:       David Faure <faure () kde ! org>
Date:       2004-08-29 18:18:03
Message-ID: 20040829181803.4755B9003 () office ! kde ! org
[Download RAW message or body]

CVS commit by faure: 

Added isWritable(), and used it from acceptDrops(). Fixes behavior of readonly directories.


  M +24 -7     kfileitem.cpp   1.160
  M +11 -1     kfileitem.h   1.92


--- kdelibs/kio/kio/kfileitem.cpp  #1.159:1.160
@@ -520,4 +520,25 @@ bool KFileItem::isReadable() const
 }
 
+bool KFileItem::isWritable() const
+{
+  /*
+  struct passwd * user = getpwuid( geteuid() );
+  bool isMyFile = (QString::fromLocal8Bit(user->pw_name) == m_user);
+  // This gets ugly for the group....
+  // Maybe we want a static QString for the user and a static QStringList
+  // for the groups... then we need to handle the deletion properly...
+  */
+
+  // No write permission at all
+  if ( !(S_IWUSR & m_permissions) && !(S_IWGRP & m_permissions) && !(S_IWOTH & m_permissions) )
+      return false;
+
+  // Or if we can't read it [using ::access()] - not network transparent
+  else if ( m_bIsLocalURL && ::access( QFile::encodeName(m_url.path()), W_OK ) == -1 )
+      return false;
+
+  return true;
+}
+
 bool KFileItem::isHidden() const
 {
@@ -549,10 +570,6 @@ bool KFileItem::acceptsDrops()
 {
   // A directory ?
-  if ( S_ISDIR( mode() ) )
-  {
-    if ( m_bIsLocalURL ) // local -> check if we can enter it
-       return (::access( QFile::encodeName(m_url.path()), X_OK ) == 0);
-    else
-       return true; // assume ok for remote urls
+  if ( S_ISDIR( mode() ) ) {
+      return isWritable();
   }
 

--- kdelibs/kio/kio/kfileitem.h  #1.91:1.92
@@ -30,4 +30,6 @@
 #include <kfilemetainfo.h>
 
+#define KFILEITEM_HAS_ISWRITABLE // only used in libkonq/konq_iconviewwidget.cc, will be removed for 3.4
+
 /**
  * A KFileItem is a generic class to handle a file, local or remote.
@@ -175,5 +177,5 @@ public:
 
   /**
-   * Checks whether the file is readable. In some cases
+   * Checks whether the file or directory is readable. In some cases
    * (remote files), we may return true even though it can't be read.
    * @return true if the file can be read - more precisely,
@@ -183,4 +185,12 @@ public:
 
   /**
+   * Checks whether the file or directory is writable. In some cases
+   * (remote files), we may return true even though it can't be written to.
+   * @return true if the file or directory can be written to - more precisely,
+   *         false if we know for sure it can't
+   */
+  bool isWritable() const;
+
+    /**
    * Checks whether the file is hidden.
    * @return true if the file is hidden.


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

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