aboutsummaryrefslogtreecommitdiff
path: root/backends/fs
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2014-10-11 20:13:25 +0200
committerWillem Jan Palenstijn2014-10-11 21:13:13 +0200
commit4b0995738667e05a425ecbda5c9ab37e814ebe95 (patch)
treecb298f8454bc4938d5175a5c31c2137426e550ea /backends/fs
parentf76e02e5d65ae235e4816ace30398c3b923a6b4a (diff)
downloadscummvm-rg350-4b0995738667e05a425ecbda5c9ab37e814ebe95.tar.gz
scummvm-rg350-4b0995738667e05a425ecbda5c9ab37e814ebe95.tar.bz2
scummvm-rg350-4b0995738667e05a425ecbda5c9ab37e814ebe95.zip
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().
Diffstat (limited to 'backends/fs')
-rw-r--r--backends/fs/amigaos4/amigaos4-fs.cpp26
-rw-r--r--backends/fs/amigaos4/amigaos4-fs.h5
2 files changed, 24 insertions, 7 deletions
diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp
index 2cf397492a..7bebdf8ce6 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 223d809032..408354888e 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.