[Scummvm-cvs-logs] SF.net SVN: scummvm:[39029] scummvm/trunk/backends/fs/palmos/palmos-fs.cpp

chrilith at users.sourceforge.net chrilith at users.sourceforge.net
Sun Mar 1 11:28:16 CET 2009


Revision: 39029
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39029&view=rev
Author:   chrilith
Date:     2009-03-01 10:28:15 +0000 (Sun, 01 Mar 2009)

Log Message:
-----------
Fixed PalmOS FSNode which was failing in some cases

Modified Paths:
--------------
    scummvm/trunk/backends/fs/palmos/palmos-fs.cpp

Modified: scummvm/trunk/backends/fs/palmos/palmos-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/palmos/palmos-fs.cpp	2009-03-01 10:25:33 UTC (rev 39028)
+++ scummvm/trunk/backends/fs/palmos/palmos-fs.cpp	2009-03-01 10:28:15 UTC (rev 39029)
@@ -41,7 +41,7 @@
 	Common::String _path;
 	bool _isDirectory;
 	bool _isValid;
-	bool _isPseudoRoot;
+	bool _isPseudoRoot;	// TODO: get rid of this
 
 public:
 	/**
@@ -50,7 +50,7 @@
 	PalmOSFilesystemNode();
 
 	/**
-	 * Creates a POSIXFilesystemNode for a given path.
+	 * Creates a PalmOSFilesystemNode for a given path.
 	 *
 	 * @param path Common::String with the path the new node should point to.
 	 */
@@ -73,7 +73,7 @@
 
 private:
 	/**
-	 * Adds a single WindowsFilesystemNode to a given list.
+	 * Adds a single PalmOSFilesystemNode to a given list.
 	 * This method is used by getChildren() to populate the directory entries list.
 	 *
 	 * @param list List to put the file entry node in.
@@ -117,6 +117,8 @@
 }
 
 PalmOSFilesystemNode::PalmOSFilesystemNode(const Common::String &p) {
+	assert(p.size() > 0);
+
 	_path = p;
 	_displayName = lastPathComponent(_path, '/');
 
@@ -136,10 +138,13 @@
 		_isValid = true;
 		_isDirectory = (attr & vfsFileAttrDirectory);
 	}
+
 	_isPseudoRoot = false;
 }
 
 AbstractFSNode *PalmOSFilesystemNode::getChild(const Common::String &n) const {
+	// FIXME: Pretty lame implementation! We do no error checking to speak
+	// of, do not check if this is a special node, etc.
 	assert(_isDirectory);
 
 	Common::String newPath(_path);
@@ -147,22 +152,12 @@
 		newPath += '/';
 	newPath += n;
 
-	FileRef handle;
-	UInt32 attr;
-	Err error = VFSFileOpen(gVars->VFS.volRefNum, newPath.c_str(), vfsModeRead, &handle);
-	if (error)
-		return 0;
-
-	error = VFSFileGetAttributes(handle, &attr);
-	VFSFileClose(handle);
-
-	if (error || !(attr & vfsFileAttrDirectory))
-		return 0;
-
 	return new PalmOSFilesystemNode(newPath);
 }
 
 bool PalmOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
+	assert(_isDirectory);
+
 	//TODO: honor the hidden flag
 
 	Err error;
@@ -173,20 +168,18 @@
 
 	desc.nameP = nameP;
 	desc.nameBufLen = 256;
-	error = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
 
+	error = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
 	if (error)
 		return false;
 
 	while (dirIterator != expIteratorStop) {
 		error = VFSDirEntryEnumerate(handle, &dirIterator, &desc);
-		if (!error) {
+		if (!error)
 			addFile(myList, mode, _path.c_str(), &desc);
-		}
 	}
 
 	VFSFileClose(handle);
-
 	return true;
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list