all repos — fluxbox @ 95c20b15f90ae8b406b2c9a4e6eae4e3e8d0c77f

custom fork of the fluxbox windowmanager

added name and isExecutable, patch from Mathias Gumz
fluxgen fluxgen
commit

95c20b15f90ae8b406b2c9a4e6eae4e3e8d0c77f

parent

bb2f1c87136c930f1a91ec8864890a5edb2c04f2

2 files changed, 20 insertions(+), 2 deletions(-)

jump to
M src/FbTk/Directory.ccsrc/FbTk/Directory.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Directory.cc,v 1.2 2003/08/17 13:19:54 fluxgen Exp $ +// $Id: Directory.cc,v 1.3 2004/04/19 18:09:15 fluxgen Exp $ #include "Directory.hh"

@@ -60,6 +60,7 @@

void Directory::close() { if (m_dir != 0) { closedir(m_dir); + m_name.clear(); m_dir = 0; m_num_entries = 0; }

@@ -77,6 +78,8 @@ m_dir = opendir(dir);

if (m_dir == 0) // successfull loading? return false; + m_name= dir; + // get number of entries while (read()) m_num_entries++;

@@ -100,6 +103,16 @@ if (stat(filename.c_str(), &statbuf) != 0)

return false; return S_ISREG(statbuf.st_mode); +} + +bool Directory::isExecutable(const std::string &filename) { + struct stat statbuf; + if (stat(filename.c_str(), &statbuf) != 0) + return false; + + return statbuf.st_mode & S_IXUSR || + statbuf.st_mode & S_IXGRP || + statbuf.st_mode & S_IXOTH; } }; // end namespace FbTk
M src/FbTk/Directory.hhsrc/FbTk/Directory.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Directory.hh,v 1.3 2003/12/16 17:06:49 fluxgen Exp $ +// $Id: Directory.hh,v 1.4 2004/04/19 18:09:14 fluxgen Exp $ #ifndef FBTK_DIRECTORY_HH #define FBTK_DIRECTORY_HH

@@ -37,6 +37,7 @@ class Directory: private FbTk::NotCopyable {

public: explicit Directory(const char *dir = 0); ~Directory(); + const std::string &name() const { return m_name; } /// go to start of filelist void rewind(); /// gets next dirent info struct in directory and

@@ -55,7 +56,11 @@ /// @return true if file is a directory

static bool isDirectory(const std::string &filename); /// @return true if a file is a regular file static bool isRegularFile(const std::string &filename); + /// @return true if a file executable for user + static bool isExecutable(const std::string &filename); + private: + std::string m_name; DIR *m_dir; size_t m_num_entries; ///< number of file entries in directory };