diff options
| author | Max Horn | 2006-04-30 22:52:10 +0000 |
|---|---|---|
| committer | Max Horn | 2006-04-30 22:52:10 +0000 |
| commit | 8300d1d2a921dc5aebb855ebc404ba0957e4435a (patch) | |
| tree | 47818b2494d6a2013f4745bf47334852ed4c3eaf /backends/fs/posix | |
| parent | 8542e92ed37af3383123b19edd930db65cd81c56 (diff) | |
| download | scummvm-rg350-8300d1d2a921dc5aebb855ebc404ba0957e4435a.tar.gz scummvm-rg350-8300d1d2a921dc5aebb855ebc404ba0957e4435a.tar.bz2 scummvm-rg350-8300d1d2a921dc5aebb855ebc404ba0957e4435a.zip | |
Added new AbstractFilesystemNode::child() resp. FilesystemNode::getChild() methods
svn-id: r22249
Diffstat (limited to 'backends/fs/posix')
| -rw-r--r-- | backends/fs/posix/posix-fs.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 081325beba..e4b6b9ffa1 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, bool useStat = false); + POSIXFilesystemNode(const String &path, bool verify = false); virtual String displayName() const { return _displayName; } virtual bool isValid() const { return _isValid; } @@ -58,6 +58,7 @@ public: virtual FSList listDir(ListMode mode = kListDirectoriesOnly) const; virtual AbstractFilesystemNode *parent() const; + virtual AbstractFilesystemNode *child(const String &name) const; }; @@ -103,7 +104,7 @@ POSIXFilesystemNode::POSIXFilesystemNode() { _isDirectory = true; } -POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool useStat) { +POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool verify) { assert(p.size() > 0); _path = p; @@ -111,13 +112,21 @@ POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool useStat) { _isValid = true; _isDirectory = true; -#ifndef __DC__ - if (useStat) { + if (verify) { +#ifdef __DC__ + FIXME; + /* + FIXME: Is there really no way to at least verify the path is valid? + Or is it too slow, or what? Please clarify with a comment here. + (Of course we could just fopen here, but that wouldn't be able to deal + with directories... + */ +#else struct stat st; _isValid = (0 == stat(_path.c_str(), &st)); _isDirectory = S_ISDIR(st.st_mode); - } #endif + } } FSList POSIXFilesystemNode::listDir(ListMode mode) const { @@ -200,4 +209,17 @@ AbstractFilesystemNode *POSIXFilesystemNode::parent() const { return p; } +AbstractFilesystemNode *POSIXFilesystemNode::child(const String &name) const { + // FIXME: Pretty lame implementation! We do no error checking to speak + // of, do not check if this is a special node, etc. + assert(_isDirectory); + String newPath(_path); + if (_path.lastChar() != '/') + newPath += '/'; + newPath += name; + POSIXFilesystemNode *p = new POSIXFilesystemNode(newPath, true); + + return p; +} + #endif // defined(UNIX) |
