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

david_corrales at users.sourceforge.net david_corrales at users.sourceforge.net
Wed Oct 31 18:43:40 CET 2007


Revision: 29339
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29339&view=rev
Author:   david_corrales
Date:     2007-10-31 10:43:40 -0700 (Wed, 31 Oct 2007)

Log Message:
-----------
Properly implemented the isReadable() and isWritable() methods for the AmigaOSFilesystemNode backend.
Thanks a lot to Raziel_One on this one :)

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

Modified: scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp	2007-10-31 17:15:51 UTC (rev 29338)
+++ scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp	2007-10-31 17:43:40 UTC (rev 29339)
@@ -92,8 +92,8 @@
 	virtual String getName() const { return _sDisplayName; };
 	virtual String getPath() const { return _sPath; };
 	virtual bool isDirectory() const { return _bIsDirectory; };
-	virtual bool isReadable() const { return true; }	//FIXME: this is just a stub
-	virtual bool isWritable() const { return true; }	//FIXME: this is just a stub
+	virtual bool isReadable() const;
+	virtual bool isWritable() const;
 	
 	virtual AbstractFilesystemNode *getChild(const String &n) const;
 	virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
@@ -428,6 +428,68 @@
 	return node;
 }
 
+bool AmigaOSFilesystemNode::isReadable() const {
+	ENTER();
+	
+	bool readable = false;	
+	struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
+	if (!fib) {
+		debug(6, "FileInfoBlock is NULL");
+		LEAVE();
+		return false;
+	}
+	
+	BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK);
+	if (pLock) {
+		if (IDOS->Examine(pLock, fib) != DOSFALSE) {
+			/* The fib_Protection flag is low-active or inverted, thus the negation.
+			 * 
+			 * For more information, consult the compiler/include/dos/dos.h
+			 * file from the AROS source (http://aros.sourceforge.net/).
+			 */
+			if (!(fib->fib_Protection & FIBF_READ)) {
+				readable = true;
+			}
+		}
+		IDOS->UnLock(pLock);
+	}
+	
+	IDOS->FreeDosObject(DOS_FIB, fib);
+	LEAVE();
+	return readable;
+}
+
+bool AmigaOSFilesystemNode::isWritable() const {
+	ENTER();
+	
+	bool writable = false;	
+	struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
+	if (!fib) {
+		debug(6, "FileInfoBlock is NULL");
+		LEAVE();
+		return false;
+	}
+	
+	BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK);
+	if (pLock) {
+		if (IDOS->Examine(pLock, fib) != DOSFALSE) {
+			/* The fib_Protection flag is low-active or inverted, thus the negation.
+			 * 
+			 * For more information, consult the compiler/include/dos/dos.h
+			 * file from the AROS source (http://aros.sourceforge.net/).
+			 */
+			if (!(fib->fib_Protection & FIBF_WRITE)) {
+				writable = true;
+			}
+		}
+		IDOS->UnLock(pLock);
+	}
+	
+	IDOS->FreeDosObject(DOS_FIB, fib);
+	LEAVE();
+	return writable;
+}
+
 AbstractFSList AmigaOSFilesystemNode::listVolumes()	const {
 	ENTER();
 


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