From 307f4e387b086095dc4241c64d95007ba534eb8b Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 23 Apr 2006 12:29:43 +0000 Subject: Fixed getNodeForPath on systems using POSIXFilesystemNode to again correctly check whether the given path exists, and whether it points to a directory svn-id: r22097 --- backends/fs/posix/posix-fs.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'backends/fs') diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index e5c8c71ae3..081325beba 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -49,7 +49,7 @@ protected: public: POSIXFilesystemNode(); - POSIXFilesystemNode(const String &path); + POSIXFilesystemNode(const String &path, bool useStat = false); virtual String displayName() const { return _displayName; } virtual bool isValid() const { return _isValid; } @@ -77,7 +77,7 @@ AbstractFilesystemNode *FilesystemNode::getRoot() { } AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) { - return new POSIXFilesystemNode(path); + return new POSIXFilesystemNode(path, true); } POSIXFilesystemNode::POSIXFilesystemNode() { @@ -103,13 +103,21 @@ POSIXFilesystemNode::POSIXFilesystemNode() { _isDirectory = true; } -POSIXFilesystemNode::POSIXFilesystemNode(const String &p) { +POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool useStat) { assert(p.size() > 0); _path = p; _displayName = lastPathComponent(_path); _isValid = true; _isDirectory = true; + +#ifndef __DC__ + if (useStat) { + struct stat st; + _isValid = (0 == stat(_path.c_str(), &st)); + _isDirectory = S_ISDIR(st.st_mode); + } +#endif } FSList POSIXFilesystemNode::listDir(ListMode mode) const { -- cgit v1.2.3