summaryrefslogtreecommitdiff
path: root/libs/IO/src
diff options
context:
space:
mode:
authorgeronimo <geronimo013@gmx.de>2012-07-29 18:22:58 +0200
committergeronimo <geronimo013@gmx.de>2012-07-29 18:22:58 +0200
commit570a18b0d0a9a00b240504ac949214d6cc96949b (patch)
treecdbcb38d64de20587c886609b4c6ced61dc9414e /libs/IO/src
parentaa714b0076c06d7133c625ab22c86114d4f17e23 (diff)
downloadcmp-570a18b0d0a9a00b240504ac949214d6cc96949b.tar.gz
cmp-570a18b0d0a9a00b240504ac949214d6cc96949b.tar.bz2
fixed bug on directory reading, if it contains an entry without access rights (reported by seahawk1986)
Diffstat (limited to 'libs/IO/src')
-rw-r--r--libs/IO/src/File.cc24
-rw-r--r--libs/IO/src/FileRepresentation.cc12
2 files changed, 16 insertions, 20 deletions
diff --git a/libs/IO/src/File.cc b/libs/IO/src/File.cc
index 6770ec8..9b92b55 100644
--- a/libs/IO/src/File.cc
+++ b/libs/IO/src/File.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: File.cc
* Created: 21. Juli 2012, 12
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: libIO: classes for files, filesystem and input/output
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <File.h>
@@ -30,10 +30,6 @@
#include <sys/dir.h>
cFileSystem *cFile::fs = NULL;
-static mode_t ReadMask = S_IRUSR | S_IRGRP | S_IROTH;
-static mode_t WriteMask = S_IWUSR | S_IWGRP | S_IWOTH;
-static mode_t ExecMask = S_IXUSR | S_IXGRP | S_IXOTH;
-
cFile::cFile(const char *Path)
: rep(NULL)
@@ -109,19 +105,19 @@ bool cFile::IsSymbolic(void) const
bool cFile::CanRead(void) const
{
- if (rep) return rep->mode & ReadMask;
+ if (rep) return access(rep->Path(), R_OK) == 0;
return false;
}
bool cFile::CanWrite(void) const
{
- if (rep) return rep->mode & WriteMask;
+ if (rep) return access(rep->Path(), W_OK) == 0;
return false;
}
bool cFile::CanExecute(void) const
{
- if (rep) return rep->mode & ExecMask;
+ if (rep) return access(rep->Path(), X_OK) == 0;
return false;
}
@@ -159,7 +155,7 @@ void cFile::Cleanup(void)
void cFile::VisitFiles(int (*cb)(void *, cFile *, const char *), void *opaque)
{
- if (!Exists() || !IsDirectory()) return;
+ if (!Exists() || !IsDirectory() || !CanExecute()) return;
const char *path = AbsolutePath();
if (!path) return;
diff --git a/libs/IO/src/FileRepresentation.cc b/libs/IO/src/FileRepresentation.cc
index f74d2c8..3366157 100644
--- a/libs/IO/src/FileRepresentation.cc
+++ b/libs/IO/src/FileRepresentation.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: FileRepresentation.cc
* Created: 21. Juli 2012, 12
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: libIO: classes for files, filesystem and input/output
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <FileRepresentation.h>