aboutsummaryrefslogtreecommitdiff
path: root/common/fs.cpp
diff options
context:
space:
mode:
authorDavid Corrales2007-06-05 21:02:35 +0000
committerDavid Corrales2007-06-05 21:02:35 +0000
commit3b96c7fad54ff7f5000667be494e50e7ca11e69a (patch)
tree265263a7fc44ca51c2391e929e7c4fd0da676315 /common/fs.cpp
parent716bcd0b2bcd4d04489bc2fc23a948fad3e2c02a (diff)
downloadscummvm-rg350-3b96c7fad54ff7f5000667be494e50e7ca11e69a.tar.gz
scummvm-rg350-3b96c7fad54ff7f5000667be494e50e7ca11e69a.tar.bz2
scummvm-rg350-3b96c7fad54ff7f5000667be494e50e7ca11e69a.zip
Renamed methods in the FilesystemNode class to match the AbstractFSNode implementations.
Also exposed the new methods (exists, isReadable and isWritable) in FilesystemNode. svn-id: r27113
Diffstat (limited to 'common/fs.cpp')
-rw-r--r--common/fs.cpp106
1 files changed, 62 insertions, 44 deletions
diff --git a/common/fs.cpp b/common/fs.cpp
index ef106c2488..fdc485a06f 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -27,16 +27,16 @@
#include "backends/fs/abstract-fs.h"
#include "backends/fs/fs-factory-maker.cpp"
-FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
- _realNode = realNode;
- _refCount = new int(1);
-}
-
FilesystemNode::FilesystemNode() {
_realNode = 0;
_refCount = 0;
}
+FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
+ _realNode = realNode;
+ _refCount = new int(1);
+}
+
FilesystemNode::FilesystemNode(const FilesystemNode &node) {
_realNode = node._realNode;
_refCount = node._refCount;
@@ -58,17 +58,6 @@ FilesystemNode::~FilesystemNode() {
decRefCount();
}
-void FilesystemNode::decRefCount() {
- if (_refCount) {
- assert(*_refCount > 0);
- --(*_refCount);
- if (*_refCount == 0) {
- delete _refCount;
- delete _realNode;
- }
- }
-}
-
FilesystemNode &FilesystemNode::operator= (const FilesystemNode &node) {
if (node._refCount)
++(*node._refCount);
@@ -81,24 +70,32 @@ FilesystemNode &FilesystemNode::operator= (const FilesystemNode &node) {
return *this;
}
-bool FilesystemNode::isValid() const {
- if (_realNode == 0)
+bool FilesystemNode::operator< (const FilesystemNode& node) const
+{
+ if (isDirectory() && !node.isDirectory())
+ return true;
+ if (!isDirectory() && node.isDirectory())
return false;
- return _realNode->isValid();
+ return scumm_stricmp(getDisplayName().c_str(), node.getDisplayName().c_str()) < 0;
}
-FilesystemNode FilesystemNode::getParent() const {
- if (_realNode == 0)
- return *this;
-
- AbstractFilesystemNode *node = _realNode->getParent();
- if (node == 0) {
- return *this;
- } else {
- return FilesystemNode(node);
+void FilesystemNode::decRefCount() {
+ if (_refCount) {
+ assert(*_refCount > 0);
+ --(*_refCount);
+ if (*_refCount == 0) {
+ delete _refCount;
+ delete _realNode;
+ }
}
}
+bool FilesystemNode::exists() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->exists();
+}
+
FilesystemNode FilesystemNode::getChild(const Common::String &n) const {
if (_realNode == 0)
return *this;
@@ -108,7 +105,7 @@ FilesystemNode FilesystemNode::getChild(const Common::String &n) const {
return FilesystemNode(node);
}
-bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
+bool FilesystemNode::getChildren(FSList &fslist, ListMode mode) const {
if (!_realNode || !_realNode->isDirectory())
return false;
@@ -125,32 +122,53 @@ bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
return true;
}
-bool FilesystemNode::isDirectory() const {
- if (_realNode == 0)
- return false;
- return _realNode->isDirectory();
-}
-
-Common::String FilesystemNode::displayName() const {
+Common::String FilesystemNode::getDisplayName() const {
assert(_realNode);
return _realNode->getDisplayName();
}
-Common::String FilesystemNode::name() const {
+Common::String FilesystemNode::getName() const {
assert(_realNode);
return _realNode->getName();
}
-Common::String FilesystemNode::path() const {
+FilesystemNode FilesystemNode::getParent() const {
+ if (_realNode == 0)
+ return *this;
+
+ AbstractFilesystemNode *node = _realNode->getParent();
+ if (node == 0) {
+ return *this;
+ } else {
+ return FilesystemNode(node);
+ }
+}
+
+Common::String FilesystemNode::getPath() const {
assert(_realNode);
return _realNode->getPath();
}
-bool FilesystemNode::operator< (const FilesystemNode& node) const
-{
- if (isDirectory() && !node.isDirectory())
- return true;
- if (!isDirectory() && node.isDirectory())
+bool FilesystemNode::isDirectory() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->isDirectory();
+}
+
+bool FilesystemNode::isReadable() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->isReadable();
+}
+
+bool FilesystemNode::isValid() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->isValid();
+}
+
+bool FilesystemNode::isWritable() const {
+ if (_realNode == 0)
return false;
- return scumm_stricmp(displayName().c_str(), node.displayName().c_str()) < 0;
+ return _realNode->isWritable();
}