From e4a7de9d754c7e9b9a9f4f313b3a89bf4b5283af Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 1 May 2006 21:53:31 +0000 Subject: Patch #1479919 (AmigaOS maintaining) svn-id: r22267 --- backends/fs/amigaos4/amigaos4-fs.cpp | 51 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'backends/fs/amigaos4/amigaos4-fs.cpp') diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index d98b64f381..92897ff0ca 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -114,11 +114,8 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const String &p) { } _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, "FileInfoBlock is NULL"); @@ -126,22 +123,25 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const String &p) { return; } + // Check whether the node exists and if it is a directory BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK); if (pLock) { if (IDOS->Examine(pLock, fib) != DOSFALSE) { - if (fib->fib_EntryType > 0) + if (FIB_IS_DRAWER(fib)) { _bIsDirectory = true; - else - _bIsDirectory = false; - - if (_bIsDirectory) { - if (fib->fib_EntryType != ST_ROOT) - _sPath += "/"; - _pFileLock = IDOS->DupLock(pLock); _bIsValid = (_pFileLock != 0); + + // Add a trailing slash if it is needed + const char c = _sPath.lastChar(); + if (c != '/' && c != ':') + _sPath += '/'; + } - else _bIsValid = true; + else { + _bIsDirectory = false; + _bIsValid = true; + } } } @@ -184,19 +184,19 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam } if (IDOS->Examine(pLock, fib) != DOSFALSE) { - if (fib->fib_EntryType > 0) + if (FIB_IS_DRAWER(fib)) { _bIsDirectory = true; - else - _bIsDirectory = false; - - if (_bIsDirectory) { - if (fib->fib_EntryType != ST_ROOT) - _sPath += "/"; - _pFileLock = IDOS->DupLock(pLock); - _bIsValid = (_pFileLock != 0); + _bIsValid = _pFileLock != 0; + + const char c = _sPath.lastChar(); + if (c != '/' && c != ':') + _sPath += '/'; } - else _bIsValid = true; + else { + _bIsDirectory = false; + _bIsValid = true; + } } IDOS->FreeDosObject(DOS_FIB, fib); @@ -325,7 +325,12 @@ AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const { } AbstractFilesystemNode *AmigaOSFilesystemNode::child(const String &name) const { - TODO + assert(_bIsDirectory); + String newPath(_sPath); + if (_sPath.lastChar() != '/') + newPath += '/'; + newPath += name; + return new AmigaOSFilesystemNode(newPath); } FSList AmigaOSFilesystemNode::listVolumes(void) const { -- cgit v1.2.3