[Scummvm-cvs-logs] scummvm master -> 4b0995738667e05a425ecbda5c9ab37e814ebe95
wjp
wjp at usecode.org
Sat Oct 11 21:13:54 CEST 2014
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4b09957386 AMIGAOS4: Fix getParent() for non-directories
Commit: 4b0995738667e05a425ecbda5c9ab37e814ebe95
https://github.com/scummvm/scummvm/commit/4b0995738667e05a425ecbda5c9ab37e814ebe95
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2014-10-11T21:13:13+02:00
Commit Message:
AMIGAOS4: Fix getParent() for non-directories
The previous attempt in d32816c0 was broken because it failed
to realize that _pFileLock is only set for directories.
This patch also tries to clarify this by making the root node logic
explicit in isRootNode().
Changed paths:
backends/fs/amigaos4/amigaos4-fs.cpp
backends/fs/amigaos4/amigaos4-fs.h
diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp
index 2cf3974..7bebdf8 100644
--- a/backends/fs/amigaos4/amigaos4-fs.cpp
+++ b/backends/fs/amigaos4/amigaos4-fs.cpp
@@ -252,7 +252,7 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b
return false; // Empty list
}
- if (_pFileLock == 0) {
+ if (isRootNode()) {
debug(6, "Root node");
LEAVE();
myList = listVolumes();
@@ -307,21 +307,33 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b
AbstractFSNode *AmigaOSFilesystemNode::getParent() const {
ENTER();
- if (_pFileLock == 0) {
+ if (isRootNode()) {
debug(6, "Root node");
LEAVE();
return new AmigaOSFilesystemNode(*this);
}
+ BPTR pLock = _pFileLock;
+
+ if (!_bIsDirectory) {
+ assert(!pLock);
+ pLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK);
+ assert(pLock);
+ }
+
AmigaOSFilesystemNode *node;
- BPTR parentDir = IDOS->ParentDir( _pFileLock );
+ BPTR parentDir = IDOS->ParentDir( pLock );
if (parentDir) {
node = new AmigaOSFilesystemNode(parentDir);
IDOS->UnLock(parentDir);
} else
node = new AmigaOSFilesystemNode();
+ if (!_bIsDirectory) {
+ IDOS->UnLock(pLock);
+ }
+
LEAVE();
return node;
@@ -332,9 +344,9 @@ bool AmigaOSFilesystemNode::isReadable() const {
return false;
// Regular RWED protection flags are low-active or inverted, thus the negation.
- // Moreover, a pseudo root filesystem (null _pFileLock) is readable whatever the
+ // Moreover, a pseudo root filesystem is readable whatever the
// protection says.
- bool readable = !(_nProt & EXDF_OTR_READ) || _pFileLock == 0;
+ bool readable = !(_nProt & EXDF_OTR_READ) || isRootNode();
return readable;
}
@@ -344,9 +356,9 @@ bool AmigaOSFilesystemNode::isWritable() const {
return false;
// Regular RWED protection flags are low-active or inverted, thus the negation.
- // Moreover, a pseudo root filesystem (null _pFileLock) is never writable whatever
+ // Moreover, a pseudo root filesystem is never writable whatever
// the protection says (Because of it's pseudo nature).
- bool writable = !(_nProt & EXDF_OTR_WRITE) && _pFileLock !=0;
+ bool writable = !(_nProt & EXDF_OTR_WRITE) && !isRootNode();
return writable;
}
diff --git a/backends/fs/amigaos4/amigaos4-fs.h b/backends/fs/amigaos4/amigaos4-fs.h
index 223d809..4083548 100644
--- a/backends/fs/amigaos4/amigaos4-fs.h
+++ b/backends/fs/amigaos4/amigaos4-fs.h
@@ -62,6 +62,11 @@ protected:
*/
virtual AbstractFSList listVolumes() const;
+ /**
+ * True if this is the pseudo root filesystem.
+ */
+ bool isRootNode() const { return _bIsValid && _bIsDirectory && _pFileLock == 0; }
+
public:
/**
* Creates an AmigaOSFilesystemNode with the root node as path.
More information about the Scummvm-git-logs
mailing list