From 5d9b35510d7d6aad9408e12aaebed2a79e3ed826 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 20 Nov 2004 21:35:49 +0000 Subject: Changed the FilesystemNode implementation to make it easier to use (client code doesn't have to worry about the memory managment anymore, it's all 'automatic' now). May have introduced a mem leak or two, please check :-) svn-id: r15848 --- backends/fs/palmos/palmos-fs.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'backends/fs/palmos') diff --git a/backends/fs/palmos/palmos-fs.cpp b/backends/fs/palmos/palmos-fs.cpp index 2a5c599e6c..aeecb38d43 100644 --- a/backends/fs/palmos/palmos-fs.cpp +++ b/backends/fs/palmos/palmos-fs.cpp @@ -29,7 +29,7 @@ * Implementation of the ScummVM file system API based on PalmOS VFS API. */ -class PalmOSFilesystemNode : public FilesystemNode { +class PalmOSFilesystemNode : public AbstractFilesystemNode { protected: String _displayName; bool _isDirectory; @@ -47,15 +47,14 @@ public: virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual FSList *listDir(ListMode) const; - virtual FilesystemNode *parent() const; - virtual FilesystemNode *clone() const { return new PalmOSFilesystemNode(this); } + virtual FSList listDir(ListMode) const; + virtual AbstractFilesystemNode *parent() const; private: - static void addFile (FSList* list, ListMode mode, const Char *base, FileInfoType* find_data); + static void addFile (FSList &list, ListMode mode, const Char *base, FileInfoType* find_data); }; -void PalmOSFilesystemNode::addFile(FSList* list, ListMode mode, const char *base, FileInfoType* find_data) { +void PalmOSFilesystemNode::addFile(FSList &list, ListMode mode, const char *base, FileInfoType* find_data) { PalmOSFilesystemNode entry; bool isDirectory; @@ -74,10 +73,10 @@ void PalmOSFilesystemNode::addFile(FSList* list, ListMode mode, const char *base entry._isValid = true; entry._isPseudoRoot = false; - list->push_back(entry); + list.push_back(wrap(new PalmOSFilesystemNode(&entry))); } -FilesystemNode *FilesystemNode::getRoot() { +AbstractFilesystemNode *FilesystemNode::getRoot() { return new PalmOSFilesystemNode(); } @@ -97,9 +96,9 @@ PalmOSFilesystemNode::PalmOSFilesystemNode(const PalmOSFilesystemNode *node) { _path = node->_path; } -FSList *PalmOSFilesystemNode::listDir(ListMode mode) const { +FSList PalmOSFilesystemNode::listDir(ListMode mode) const { - FSList *myList = new FSList(); + FSList myList; Err e; Char nameP[256]; FileInfoType desc; @@ -136,7 +135,7 @@ const char *lastPathComponent(const Common::String &str) { return cur+1; } -FilesystemNode *PalmOSFilesystemNode::parent() const { +AbstractFilesystemNode *PalmOSFilesystemNode::parent() const { PalmOSFilesystemNode *p = new PalmOSFilesystemNode(); -- cgit v1.2.3