aboutsummaryrefslogtreecommitdiff
path: root/common/fs.cpp
diff options
context:
space:
mode:
authorMax Horn2008-03-29 21:12:36 +0000
committerMax Horn2008-03-29 21:12:36 +0000
commitdbe38029db40911cc82136820a771b2fc85454f2 (patch)
tree183991175713fe302a74e620bc639c218b231ab9 /common/fs.cpp
parente411ccc01f4d6e2071cb5d2d86590fa8041486a5 (diff)
downloadscummvm-rg350-dbe38029db40911cc82136820a771b2fc85454f2.tar.gz
scummvm-rg350-dbe38029db40911cc82136820a771b2fc85454f2.tar.bz2
scummvm-rg350-dbe38029db40911cc82136820a771b2fc85454f2.zip
Changed FilesystemNode to use a SharedPtr instead of implementing its own ref counting
svn-id: r31303
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;