[Scummvm-cvs-logs] SF.net SVN: scummvm: [21691] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Apr 8 05:40:08 CEST 2006


Revision: 21691
Author:   fingolfin
Date:     2006-04-08 05:39:27 -0700 (Sat, 08 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21691&view=rev

Log Message:
-----------
AmigaOS4 changes from tracker #1416370

Modified Paths:
--------------
    scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp
    scummvm/trunk/common/scummsys.h
    scummvm/trunk/common/util.h
    scummvm/trunk/configure
Modified: scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp	2006-04-08 12:06:52 UTC (rev 21690)
+++ scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp	2006-04-08 12:39:27 UTC (rev 21691)
@@ -34,7 +34,7 @@
 
 #include <common/stdafx.h>
 
-//#include "util.h"
+#include "common/util.h"
 
 #include "base/engine.h"
 #include "backends/fs/fs.h"
@@ -43,7 +43,7 @@
 #define LEAVE() /* debug(6, "Leave\n") */
 
 
-const uint32 ExAllBufferSize = 40960;
+const uint32 kExAllBufferSize = 40960; // TODO: is this okay for sure?
 
 class AmigaOSFilesystemNode : public AbstractFilesystemNode {
 	protected:
@@ -58,7 +58,10 @@
 		AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0);
 		AmigaOSFilesystemNode(const String &p);
 
-		~AmigaOSFilesystemNode();
+	    // Note: Copy constructor is needed because it duplicates the file lock
+		AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node);
+		
+		virtual ~AmigaOSFilesystemNode();
 
 		virtual String displayName() const { return _sDisplayName; };
 		virtual bool isValid() const { return _bIsValid; };
@@ -111,11 +114,13 @@
 
 	_sDisplayName = String(str + offset, len);
 
+	_pFileLock = 0;
+
 	// Check whether it is a directory, and whether the file actually exists
 
 	struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
 	if (!fib) {
-		//debug(6, "fib == 0\n");
+		debug(6, "fib == 0\n");
 		LEAVE();
 		return;
 	}
@@ -145,12 +150,12 @@
 
 AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName) {
 	ENTER();
-	int bufsize = 256;
+	int bufSize = MAXPATHLEN;
 	_pFileLock = 0;
 
 	while (1) {
-		char *name = new char[bufsize];
-		if (IDOS->NameFromLock(pLock, name, bufsize) != DOSFALSE) {
+		char *name = new char[bufSize];
+		if (IDOS->NameFromLock(pLock, name, bufSize) != DOSFALSE) {
 			_sPath = name;
 			_sDisplayName = pDisplayName ? pDisplayName : IDOS->FilePart(name);
 			delete [] name;
@@ -159,12 +164,12 @@
 
 		if (IDOS->IoErr() != ERROR_LINE_TOO_LONG) {
 			_bIsValid = false;
-			//debug(6, "Error\n");
+			debug(6, "Error\n");
 			LEAVE();
 			delete [] name;
 			return;
 		}
-		bufsize *= 2;
+		bufSize *= 2;
 		delete [] name;
 	}
 
@@ -172,7 +177,7 @@
 
 	struct FileInfoBlock *fib = (struct	FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
 	if (!fib) {
-		//debug(6, "fib == 0\n");
+		debug(6, "fib == 0\n");
 		LEAVE();
 		return;
 	}
@@ -197,13 +202,14 @@
 	LEAVE();
 }
 
-AmigaOSFilesystemNode::AmigaOSFilesystemNode(const AmigaOSFilesystemNode *node) {
+// We need the custom copy constructor because of DupLock()
+AmigaOSFilesystemNode::AmigaOSFilesystemNode(const AmigaOSFilesystemNode& node) {
 	ENTER();
-	_sDisplayName = node->_sDisplayName;
-	_bIsValid = node->_bIsValid;
-	_bIsDirectory = node->_bIsDirectory;
-	_sPath = node->_sPath;
-	_pFileLock = IDOS->DupLock(node->_pFileLock);
+	_sDisplayName = node._sDisplayName;
+	_bIsValid = node._bIsValid;
+	_bIsDirectory = node._bIsDirectory;
+	_sPath = node._sPath;
+	_pFileLock = IDOS->DupLock(node._pFileLock);
 	LEAVE();
 }
 
@@ -217,39 +223,36 @@
 FSList AmigaOSFilesystemNode::listDir(ListMode mode) const {
 	ENTER();
 
+	FSList myList;
+
 	if (!_bIsValid) {
-		//debug(6, "Invalid node\n");
+		debug(6, "Invalid node\n");
 		LEAVE();
-		//return 0;
+		return myList; // Empty list
 	}
 
 	if (!_bIsDirectory) {
-		//debug(6, "Not a directory\n");
+		debug(6, "Not a directory\n");
 		LEAVE();
-		//return 0;
+		return myList; // Empty list
 	}
 
 	if (_pFileLock == 0) {
-		//debug(6, "Root node\n");
+		debug(6, "Root node\n");
 		LEAVE();
 		return listVolumes();
 	}
 
 	//FSList *myList = new FSList();
-	FSList myList;
 
-	struct ExAllControl *eac;
-	struct ExAllData *data, *ead;
-	BOOL bExMore;
-
-	eac = (struct ExAllControl *)IDOS->AllocDosObject(DOS_EXALLCONTROL, 0);
+	struct ExAllControl *eac = (struct ExAllControl *)IDOS->AllocDosObject(DOS_EXALLCONTROL, 0);
 	if (eac) {
-		data = (struct ExAllData *)IExec->AllocVec(ExAllBufferSize, MEMF_ANY);
+		struct ExAllData *data = (struct ExAllData *)IExec->AllocVec(kExAllBufferSize, MEMF_ANY);
 		if (data) {
+			BOOL bExMore;
 			eac->eac_LastKey = 0;
 			do {
-				bExMore = IDOS->ExAll(_pFileLock, data,	ExAllBufferSize,
-					ED_TYPE, eac);
+				bExMore = IDOS->ExAll(_pFileLock, data,	kExAllBufferSize, ED_TYPE, eac);
 
 				LONG error = IDOS->IoErr();
 				if (!bExMore && error != ERROR_NO_MORE_ENTRIES)
@@ -258,22 +261,19 @@
 				if (eac->eac_Entries ==	0)
 					continue;
 
-				ead	= data;
+				struct ExAllData *ead = data;
 				do {
-					AmigaOSFilesystemNode *entry;
-					String full_path;
-					BPTR lock;
-
-					if ((ead->ed_Type > 0 && (mode & kListDirectoriesOnly)) ||
-						(ead->ed_Type < 0 && (mode & kListFilesOnly))) {
-						full_path = _sPath;
+					if ((mode == kListAll) || (EAD_IS_DRAWER(ead) && (mode == kListDirectoriesOnly)) ||
+						(EAD_IS_FILE(ead) && (mode == kListFilesOnly))) {
+						String full_path = _sPath;
 						full_path += (char*)ead->ed_Name;
-						lock = IDOS->Lock((char *)full_path.c_str(), SHARED_LOCK);
+
+						BPTR lock = IDOS->Lock((char *)full_path.c_str(), SHARED_LOCK);
 						if (lock) {
-							entry = new AmigaOSFilesystemNode(lock, (char *)ead->ed_Name);
+							AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(lock, (char *)ead->ed_Name);
 							if (entry) {
 								if (entry->isValid())
-									myList.push_back(wrap(entry));
+								    myList.push_back(wrap(entry));
 								else
 									delete entry;
 							}
@@ -289,26 +289,28 @@
 
 		IDOS->FreeDosObject(DOS_EXALLCONTROL, eac);
 	}
+
 	LEAVE();
 	return myList;
 }
 
 AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const {
 	ENTER();
-	AmigaOSFilesystemNode *node;
 
 	if (!_bIsDirectory) {
-		//debug(6, "No directory\n");
+		debug(6, "No directory\n");
 		LEAVE();
 		return 0;
 	}
 
 	if (_pFileLock == 0) {
-		//debug(6, "Root node\n");
+		debug(6, "Root node\n");
 		LEAVE();
 		return new AmigaOSFilesystemNode(*this);
 	}
 
+	AmigaOSFilesystemNode *node;
+
 	BPTR parentDir = IDOS->ParentDir( _pFileLock );
 	if (parentDir) {
 		node = new AmigaOSFilesystemNode(parentDir);
@@ -326,14 +328,12 @@
 	//FSList *myList = new FSList();
 	FSList myList;
 
-	struct DosList *dosList;
+	const uint32 kLockFlags = LDF_READ | LDF_VOLUMES;
+	char name[MAXPATHLEN];
 
-	const uint32 lockFlags = LDF_READ | LDF_VOLUMES;
-	char name[256];
-
-	dosList = IDOS->LockDosList(lockFlags);
+	struct DosList *dosList = IDOS->LockDosList(kLockFlags);
 	if (!dosList) {
-		//debug(6, "Cannot lock dos list\n");
+		debug(6, "Cannot lock dos list\n");
 		LEAVE();
 		return myList;
 	}
@@ -344,30 +344,29 @@
 		if (dosList->dol_Type == DLT_VOLUME &&
 			dosList->dol_Name &&
 			dosList->dol_Task) {
-			AmigaOSFilesystemNode *entry;
-			const char *volname = (const char *)BADDR(dosList->dol_Name)+1;
-			const char *devname = (const char *)((struct Task *)dosList->dol_Task->mp_SigTask)->tc_Node.ln_Name;
+			const char *volName = (const char *)BADDR(dosList->dol_Name)+1;
+			const char *devName = (const char *)((struct Task *)dosList->dol_Task->mp_SigTask)->tc_Node.ln_Name;
 
-			strcpy(name, volname);
+			strcpy(name, volName);
 			strcat(name, ":");
 
-			BPTR volume_lock = IDOS->Lock(name,	SHARED_LOCK);
-			if (volume_lock) {
-				sprintf(name, "%s (%s)", volname, devname);
-				entry = new AmigaOSFilesystemNode(volume_lock, name);
+			BPTR volumeLock = IDOS->Lock(name, SHARED_LOCK);
+			if (volumeLock) {
+				sprintf(name, "%s (%s)", volName, devName);
+				AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, name);
 				if (entry) {
 					if (entry->isValid())
 						myList.push_back(wrap(entry));
 					else
 						delete entry;
 				}
-				IDOS->UnLock(volume_lock);
+				IDOS->UnLock(volumeLock);
 			}
 		}
 		dosList	= IDOS->NextDosEntry(dosList, LDF_VOLUMES);
 	}
 
-	IDOS->UnLockDosList(lockFlags);
+	IDOS->UnLockDosList(kLockFlags);
 
 	LEAVE();
 	return myList;

Modified: scummvm/trunk/common/scummsys.h
===================================================================
--- scummvm/trunk/common/scummsys.h	2006-04-08 12:06:52 UTC (rev 21690)
+++ scummvm/trunk/common/scummsys.h	2006-04-08 12:39:27 UTC (rev 21691)
@@ -294,12 +294,6 @@
 	#define	SCUMM_BIG_ENDIAN
 	#define	SCUMM_NEED_ALIGNMENT
 
-	// FIXME: Why is this here? If it does declare types int8 etc., and they
-	// are not compatible with our typedefs below, we need a proper fix.
-	// In general, though, you should avoid port specific includes in this
-	// header file, if possible.
-	#include <exec/types.h>
-
 #elif defined(__SYMBIAN32__)
 
 	#define scumm_stricmp strcasecmp

Modified: scummvm/trunk/common/util.h
===================================================================
--- scummvm/trunk/common/util.h	2006-04-08 12:06:52 UTC (rev 21690)
+++ scummvm/trunk/common/util.h	2006-04-08 12:39:27 UTC (rev 21691)
@@ -26,7 +26,7 @@
 #include "common/str.h"
 #include "common/array.h"
 
-#if defined (__INNOTEK_LIBC__)
+#if defined (__INNOTEK_LIBC__) || (defined (__amigaos4__) && defined(__NEWLIB__))
 #undef MIN
 #undef MAX
 #endif

Modified: scummvm/trunk/configure
===================================================================
--- scummvm/trunk/configure	2006-04-08 12:06:52 UTC (rev 21690)
+++ scummvm/trunk/configure	2006-04-08 12:39:27 UTC (rev 21691)
@@ -760,8 +760,8 @@
 			type_1_byte='char'
 			type_2_byte='short'
 			type_4_byte='long'
-			CXXFLAGS="$CFLAGS -newlib -mstrict-align -mcpu=750 -mtune=7400"
-			LDFLAGS="$LDFLAGS -newlib"
+			CXXFLAGS="$CFLAGS -mcrt=newlib -mstrict-align -mcpu=750 -mtune=7400"
+			LDFLAGS="$LDFLAGS -mcrt=newlib"
 			;;
 		*)
 			echo "Cross-compiling to unknown target $_host, please add your target to configure."


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