aboutsummaryrefslogtreecommitdiff
path: root/common/fs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/fs.cpp')
-rw-r--r--common/fs.cpp50
1 files changed, 7 insertions, 43 deletions
diff --git a/common/fs.cpp b/common/fs.cpp
index bd35f0de53..7d803dacd4 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -28,46 +28,21 @@
#include "backends/fs/fs-factory.h"
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;
- if (_refCount)
- ++(*_refCount);
+FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode)
+ : _realNode(realNode) {
}
FilesystemNode::FilesystemNode(const Common::String &p) {
FilesystemFactory *factory = g_system->getFilesystemFactory();
-
+ AbstractFilesystemNode *tmp = 0;
+
if (p.empty() || p == ".")
- _realNode = factory->makeCurrentDirectoryFileNode();
+ tmp = factory->makeCurrentDirectoryFileNode();
else
- _realNode = factory->makeFileNodePath(p);
- _refCount = new int(1);
-}
-
-FilesystemNode::~FilesystemNode() {
- decRefCount();
-}
-
-FilesystemNode &FilesystemNode::operator= (const FilesystemNode &node) {
- if (node._refCount)
- ++(*node._refCount);
-
- decRefCount();
-
- _realNode = node._realNode;
- _refCount = node._refCount;
-
- return *this;
+ tmp = factory->makeFileNodePath(p);
+ _realNode = Common::SharedPtr<AbstractFilesystemNode>(tmp);
}
bool FilesystemNode::operator<(const FilesystemNode& node) const {
@@ -77,17 +52,6 @@ bool FilesystemNode::operator<(const FilesystemNode& node) const {
return scumm_stricmp(getDisplayName().c_str(), node.getDisplayName().c_str()) < 0;
}
-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;