Moved static methods getRoot / getNodeForPath from class FilesystemNode to class AbstractFilesystemNode

svn-id: r22298
This commit is contained in:
Max Horn 2006-05-03 10:19:05 +00:00
parent d404b6150a
commit 8c452daac2
10 changed files with 38 additions and 38 deletions

View file

@ -59,6 +59,29 @@ protected:
*/ */
static FilesystemNode wrap(AbstractFilesystemNode *node); static FilesystemNode wrap(AbstractFilesystemNode *node);
/**
* Returns a special node representing the FS root. The starting point for
* any file system browsing.
* On Unix, this will be simply the node for / (the root directory).
* On Windows, it will be a special node which "contains" all drives (C:, D:, E:).
*/
static AbstractFilesystemNode *getRoot();
/**
* Construct a node based on a path; the path is in the same format as it
* would be for calls to fopen().
*
* I.e. getNodeForPath(oldNode.path()) should create a new node identical to oldNode.
*
* @TODO: This is of course a place where non-portable code easily will sneak
* in, because the format of the path used here is not well-defined.
* So we really should reconsider this API and try to come up with
* something which is more portable but still flexible enough for our
* purposes.
*/
static AbstractFilesystemNode *getNodeForPath(const String &path);
public: public:
virtual ~AbstractFilesystemNode() {} virtual ~AbstractFilesystemNode() {}

View file

@ -75,11 +75,11 @@ class AmigaOSFilesystemNode : public AbstractFilesystemNode {
virtual AbstractFilesystemNode *child(const String &name) const; virtual AbstractFilesystemNode *child(const String &name) const;
}; };
AbstractFilesystemNode *FilesystemNode::getRoot() { AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
return new AmigaOSFilesystemNode(); return new AmigaOSFilesystemNode();
} }
AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) { AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
return new AmigaOSFilesystemNode(path); return new AmigaOSFilesystemNode(path);
} }

View file

@ -41,7 +41,7 @@ FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
FilesystemNode::FilesystemNode() { FilesystemNode::FilesystemNode() {
if (_rootNode == 0) { if (_rootNode == 0) {
_rootNode = getRoot(); _rootNode = AbstractFilesystemNode::getRoot();
_rootRefCount = new int(1); _rootRefCount = new int(1);
} }
_realNode = _rootNode; _realNode = _rootNode;
@ -56,7 +56,7 @@ FilesystemNode::FilesystemNode(const FilesystemNode &node) {
} }
FilesystemNode::FilesystemNode(const Common::String &p) { FilesystemNode::FilesystemNode(const Common::String &p) {
_realNode = getNodeForPath(p); _realNode = AbstractFilesystemNode::getNodeForPath(p);
_refCount = new int(1); _refCount = new int(1);
} }

View file

@ -77,29 +77,6 @@ private:
FilesystemNode(AbstractFilesystemNode *realNode); FilesystemNode(AbstractFilesystemNode *realNode);
/**
* Returns a special node representing the FS root. The starting point for
* any file system browsing.
* On Unix, this will be simply the node for / (the root directory).
* On Windows, it will be a special node which "contains" all drives (C:, D:, E:).
*/
static AbstractFilesystemNode *getRoot();
/**
* Construct a node based on a path; the path is in the same format as it
* would be for calls to fopen().
*
* I.e. getNodeForPath(oldNode.path()) should create a new node identical to oldNode.
*
* @TODO: This is of course a place where non-portable code easily will sneak
* in, because the format of the path used here is not well-defined.
* So we really should reconsider this API and try to come up with
* something which is more portable but still flexible enough for our
* purposes.
*/
static AbstractFilesystemNode *getNodeForPath(const String &path);
public: public:
/** /**
* Flag to tell listDir() which kind of files to list. * Flag to tell listDir() which kind of files to list.

View file

@ -58,7 +58,7 @@ class ABoxFilesystemNode : public AbstractFilesystemNode {
}; };
AbstractFilesystemNode *FilesystemNode::getRoot() AbstractFilesystemNode *AbstractFilesystemNode::getRoot()
{ {
return new ABoxFilesystemNode(); return new ABoxFilesystemNode();
} }

View file

@ -78,11 +78,11 @@ void PalmOSFilesystemNode::addFile(FSList &list, ListMode mode, const char *base
list.push_back(wrap(new PalmOSFilesystemNode(entry))); list.push_back(wrap(new PalmOSFilesystemNode(entry)));
} }
AbstractFilesystemNode *FilesystemNode::getRoot() { AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
return new PalmOSFilesystemNode(); return new PalmOSFilesystemNode();
} }
AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) { AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
return new PalmOSFilesystemNode(path); return new PalmOSFilesystemNode(path);
} }

View file

@ -74,11 +74,11 @@ static const char *lastPathComponent(const Common::String &str) {
return cur + 1; return cur + 1;
} }
AbstractFilesystemNode *FilesystemNode::getRoot() { AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
return new POSIXFilesystemNode(); return new POSIXFilesystemNode();
} }
AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) { AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
return new POSIXFilesystemNode(path, true); return new POSIXFilesystemNode(path, true);
} }

View file

@ -52,11 +52,11 @@ public:
virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); } virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); }
}; };
AbstractFilesystemNode *FilesystemNode::getRoot(void) { AbstractFilesystemNode *AbstractFilesystemNode::getRoot(void) {
return new Ps2FilesystemNode(); return new Ps2FilesystemNode();
} }
AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) { AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
return new Ps2FilesystemNode(path); return new Ps2FilesystemNode(path);
} }

View file

@ -69,11 +69,11 @@ static const char *lastPathComponent(const Common::String &str) {
return cur + 1; return cur + 1;
} }
AbstractFilesystemNode *FilesystemNode::getRoot() { AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
return new SymbianFilesystemNode(true); return new SymbianFilesystemNode(true);
} }
AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) { AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
return new SymbianFilesystemNode(path); return new SymbianFilesystemNode(path);
} }

View file

@ -120,11 +120,11 @@ void WindowsFilesystemNode::addFile(FSList &list, ListMode mode, const char *bas
list.push_back(wrap(new WindowsFilesystemNode(entry))); list.push_back(wrap(new WindowsFilesystemNode(entry)));
} }
AbstractFilesystemNode *FilesystemNode::getRoot() { AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
return new WindowsFilesystemNode(); return new WindowsFilesystemNode();
} }
AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) { AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
return new WindowsFilesystemNode(path); return new WindowsFilesystemNode(path);
} }