2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2005-05-10 00:58:08 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2014-02-18 02:34:17 +01:00
|
|
|
*
|
2005-05-10 00:58:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(__amigaos4__)
|
|
|
|
|
2011-05-03 10:33:03 +02:00
|
|
|
#include "backends/fs/amigaos4/amigaos4-fs.h"
|
|
|
|
#include "backends/fs/stdiostream.h"
|
2009-01-30 14:26:34 +00:00
|
|
|
#include "common/debug.h"
|
2006-04-08 12:39:27 +00:00
|
|
|
#include "common/util.h"
|
2005-05-10 00:58:08 +00:00
|
|
|
|
2006-04-14 01:06:08 +00:00
|
|
|
#define ENTER() /* debug(6, "Enter") */
|
|
|
|
#define LEAVE() /* debug(6, "Leave") */
|
2005-05-10 00:58:08 +00:00
|
|
|
|
2007-09-22 20:47:41 +00:00
|
|
|
/**
|
|
|
|
* Returns the last component of a given path.
|
2008-01-27 19:47:41 +00:00
|
|
|
*
|
2008-09-03 11:22:51 +00:00
|
|
|
* @param str Common::String containing the path.
|
2007-09-22 20:47:41 +00:00
|
|
|
* @return Pointer to the first char of the last component inside str.
|
|
|
|
*/
|
|
|
|
const char *lastPathComponent(const Common::String &str) {
|
2007-09-22 20:51:34 +00:00
|
|
|
int offset = str.size();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-10-07 00:28:38 +00:00
|
|
|
if (offset <= 0) {
|
|
|
|
debug(6, "Bad offset");
|
2007-10-07 20:42:46 +00:00
|
|
|
return 0;
|
2007-10-07 00:28:38 +00:00
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-09-22 20:51:34 +00:00
|
|
|
const char *p = str.c_str();
|
2007-09-22 20:47:41 +00:00
|
|
|
|
2007-09-22 20:51:34 +00:00
|
|
|
while (offset > 0 && (p[offset-1] == '/' || p[offset-1] == ':'))
|
2007-09-22 20:47:41 +00:00
|
|
|
offset--;
|
|
|
|
|
2007-09-22 20:51:34 +00:00
|
|
|
while (offset > 0 && (p[offset-1] != '/' && p[offset-1] != ':'))
|
2007-09-22 20:47:41 +00:00
|
|
|
offset--;
|
|
|
|
|
2007-09-22 20:51:34 +00:00
|
|
|
return p + offset;
|
2007-09-22 20:47:41 +00:00
|
|
|
}
|
|
|
|
|
2005-05-10 00:58:08 +00:00
|
|
|
AmigaOSFilesystemNode::AmigaOSFilesystemNode() {
|
|
|
|
ENTER();
|
|
|
|
_sDisplayName = "Available Disks";
|
|
|
|
_bIsValid = true;
|
|
|
|
_bIsDirectory = true;
|
|
|
|
_sPath = "";
|
|
|
|
_pFileLock = 0;
|
2014-09-21 17:46:03 +02:00
|
|
|
_nProt = 0; // Protection is ignored for the root volume
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
|
|
|
}
|
|
|
|
|
2008-09-03 11:22:51 +00:00
|
|
|
AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) {
|
2005-05-10 00:58:08 +00:00
|
|
|
ENTER();
|
|
|
|
|
2008-09-10 09:20:38 +00:00
|
|
|
int offset = p.size();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-09-16 17:56:26 +00:00
|
|
|
//assert(offset > 0);
|
|
|
|
|
|
|
|
if (offset <= 0) {
|
|
|
|
debug(6, "Bad offset");
|
|
|
|
return;
|
|
|
|
}
|
2005-05-10 00:58:08 +00:00
|
|
|
|
|
|
|
_sPath = p;
|
2008-09-10 09:20:38 +00:00
|
|
|
_sDisplayName = ::lastPathComponent(_sPath);
|
2006-04-08 12:39:27 +00:00
|
|
|
_pFileLock = 0;
|
2006-10-08 12:50:53 +00:00
|
|
|
_bIsDirectory = false;
|
2014-01-22 22:51:44 +01:00
|
|
|
_bIsValid = false;
|
2006-04-08 12:39:27 +00:00
|
|
|
|
2014-09-21 17:46:03 +02:00
|
|
|
// Check whether the node exists and if it's a directory
|
2009-09-25 09:57:38 +00:00
|
|
|
struct ExamineData * pExd = IDOS->ExamineObjectTags(EX_StringNameInput,_sPath.c_str(),TAG_END);
|
|
|
|
if (pExd) {
|
|
|
|
_nProt = pExd->Protection;
|
|
|
|
if (EXD_IS_DIRECTORY(pExd)) {
|
|
|
|
_bIsDirectory = true;
|
2009-12-01 19:19:58 +00:00
|
|
|
_pFileLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK);
|
2009-09-25 09:57:38 +00:00
|
|
|
_bIsValid = (_pFileLock != 0);
|
|
|
|
|
2014-09-21 17:46:03 +02:00
|
|
|
// Add a trailing slash if needed
|
2009-09-25 09:57:38 +00:00
|
|
|
const char c = _sPath.lastChar();
|
|
|
|
if (c != '/' && c != ':')
|
|
|
|
_sPath += '/';
|
2009-09-30 16:16:53 +00:00
|
|
|
} else {
|
2009-09-25 09:57:38 +00:00
|
|
|
//_bIsDirectory = false;
|
|
|
|
_bIsValid = true;
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
2006-09-16 17:56:26 +00:00
|
|
|
|
2009-09-25 09:57:38 +00:00
|
|
|
IDOS->FreeDosObject(DOS_EXAMINEDATA, pExd);
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LEAVE();
|
|
|
|
}
|
|
|
|
|
|
|
|
AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName) {
|
|
|
|
ENTER();
|
2006-04-08 12:39:27 +00:00
|
|
|
int bufSize = MAXPATHLEN;
|
2005-05-10 00:58:08 +00:00
|
|
|
_pFileLock = 0;
|
|
|
|
|
2007-05-03 02:39:33 +00:00
|
|
|
while (true) {
|
2006-07-22 14:14:16 +00:00
|
|
|
char *n = new char[bufSize];
|
|
|
|
if (IDOS->NameFromLock(pLock, (STRPTR)n, bufSize) != DOSFALSE) {
|
|
|
|
_sPath = n;
|
|
|
|
_sDisplayName = pDisplayName ? pDisplayName : IDOS->FilePart((STRPTR)n);
|
2008-05-07 14:31:45 +00:00
|
|
|
delete[] n;
|
2005-05-10 00:58:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IDOS->IoErr() != ERROR_LINE_TOO_LONG) {
|
|
|
|
_bIsValid = false;
|
2006-04-14 01:06:08 +00:00
|
|
|
debug(6, "IoErr() != ERROR_LINE_TOO_LONG");
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
2008-05-07 14:31:45 +00:00
|
|
|
delete[] n;
|
2005-05-10 00:58:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-04-08 12:39:27 +00:00
|
|
|
bufSize *= 2;
|
2008-05-07 14:31:45 +00:00
|
|
|
delete[] n;
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 17:46:03 +02:00
|
|
|
_bIsValid = false;
|
2006-10-08 12:50:53 +00:00
|
|
|
_bIsDirectory = false;
|
2005-05-10 00:58:08 +00:00
|
|
|
|
2009-09-25 09:57:38 +00:00
|
|
|
struct ExamineData * pExd = IDOS->ExamineObjectTags(EX_FileLockInput,pLock,TAG_END);
|
|
|
|
if (pExd) {
|
|
|
|
_nProt = pExd->Protection;
|
|
|
|
if (EXD_IS_DIRECTORY(pExd)) {
|
2005-05-10 00:58:08 +00:00
|
|
|
_bIsDirectory = true;
|
|
|
|
_pFileLock = IDOS->DupLock(pLock);
|
2006-05-01 21:53:31 +00:00
|
|
|
_bIsValid = _pFileLock != 0;
|
|
|
|
|
|
|
|
const char c = _sPath.lastChar();
|
|
|
|
if (c != '/' && c != ':')
|
|
|
|
_sPath += '/';
|
2009-09-30 16:16:53 +00:00
|
|
|
} else {
|
2006-10-08 12:50:53 +00:00
|
|
|
//_bIsDirectory = false;
|
2006-05-01 21:53:31 +00:00
|
|
|
_bIsValid = true;
|
2008-01-27 19:47:41 +00:00
|
|
|
}
|
2009-09-25 09:57:38 +00:00
|
|
|
|
|
|
|
IDOS->FreeDosObject(DOS_EXAMINEDATA, pExd);
|
2009-09-30 16:16:53 +00:00
|
|
|
} else {
|
2009-09-25 09:57:38 +00:00
|
|
|
debug(6, "ExamineObject() returned NULL");
|
|
|
|
}
|
2005-05-10 00:58:08 +00:00
|
|
|
|
|
|
|
LEAVE();
|
|
|
|
}
|
|
|
|
|
2006-04-08 12:39:27 +00:00
|
|
|
// We need the custom copy constructor because of DupLock()
|
2009-09-25 09:57:38 +00:00
|
|
|
AmigaOSFilesystemNode::AmigaOSFilesystemNode(const AmigaOSFilesystemNode& node)
|
|
|
|
: AbstractFSNode() {
|
2005-05-10 00:58:08 +00:00
|
|
|
ENTER();
|
2006-04-08 12:39:27 +00:00
|
|
|
_sDisplayName = node._sDisplayName;
|
|
|
|
_bIsValid = node._bIsValid;
|
|
|
|
_bIsDirectory = node._bIsDirectory;
|
|
|
|
_sPath = node._sPath;
|
|
|
|
_pFileLock = IDOS->DupLock(node._pFileLock);
|
2009-09-25 09:57:38 +00:00
|
|
|
_nProt = node._nProt;
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
|
|
|
}
|
|
|
|
|
|
|
|
AmigaOSFilesystemNode::~AmigaOSFilesystemNode() {
|
|
|
|
ENTER();
|
|
|
|
if (_pFileLock)
|
|
|
|
IDOS->UnLock(_pFileLock);
|
|
|
|
LEAVE();
|
|
|
|
}
|
|
|
|
|
2007-10-30 21:31:39 +00:00
|
|
|
bool AmigaOSFilesystemNode::exists() const {
|
2007-10-30 21:57:41 +00:00
|
|
|
ENTER();
|
2009-09-30 16:16:53 +00:00
|
|
|
if (_sPath.empty())
|
2007-10-30 21:31:39 +00:00
|
|
|
return false;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-10-30 21:31:39 +00:00
|
|
|
bool nodeExists = false;
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2014-09-21 17:46:03 +02:00
|
|
|
// Previously we were trying to examine the node in order
|
2009-09-25 09:57:38 +00:00
|
|
|
// to determine if the node exists or not.
|
|
|
|
// I don't see the point : once you have been granted a
|
2014-09-21 17:46:03 +02:00
|
|
|
// lock on it, it means it exists...
|
2009-09-25 09:57:38 +00:00
|
|
|
//
|
|
|
|
// ============================= Old code
|
|
|
|
// BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK);
|
|
|
|
// if (pLock)
|
|
|
|
// {
|
|
|
|
// if (IDOS->Examine(pLock, fib) != DOSFALSE)
|
|
|
|
// nodeExists = true;
|
|
|
|
// IDOS->UnLock(pLock);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// IDOS->FreeDosObject(DOS_FIB, fib);
|
|
|
|
//
|
|
|
|
// ============================= New code
|
|
|
|
BPTR pLock = IDOS->Lock(_sPath.c_str(), SHARED_LOCK);
|
2007-10-30 21:31:39 +00:00
|
|
|
if (pLock) {
|
2009-09-25 09:57:38 +00:00
|
|
|
nodeExists = true;
|
2007-10-30 21:31:39 +00:00
|
|
|
IDOS->UnLock(pLock);
|
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-10-30 21:31:39 +00:00
|
|
|
LEAVE();
|
|
|
|
return nodeExists;
|
|
|
|
}
|
|
|
|
|
2008-10-02 16:58:59 +00:00
|
|
|
AbstractFSNode *AmigaOSFilesystemNode::getChild(const Common::String &n) const {
|
2007-10-30 21:57:41 +00:00
|
|
|
ENTER();
|
2007-05-03 02:39:33 +00:00
|
|
|
if (!_bIsDirectory) {
|
|
|
|
debug(6, "Not a directory");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-09-03 11:22:51 +00:00
|
|
|
Common::String newPath(_sPath);
|
2007-05-03 02:39:33 +00:00
|
|
|
|
|
|
|
if (_sPath.lastChar() != '/')
|
|
|
|
newPath += '/';
|
|
|
|
|
|
|
|
newPath += n;
|
|
|
|
|
2007-10-30 21:57:41 +00:00
|
|
|
LEAVE();
|
2007-05-03 02:39:33 +00:00
|
|
|
return new AmigaOSFilesystemNode(newPath);
|
|
|
|
}
|
|
|
|
|
2007-07-09 01:26:54 +00:00
|
|
|
bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
2005-05-10 00:58:08 +00:00
|
|
|
ENTER();
|
2009-09-25 09:57:38 +00:00
|
|
|
bool ret = false;
|
2005-05-10 00:58:08 +00:00
|
|
|
|
2014-09-21 17:46:03 +02:00
|
|
|
// TODO: Honor the hidden flag
|
|
|
|
// There is no such thing as a hidden flag in AmigaOS...
|
2007-07-09 01:26:54 +00:00
|
|
|
|
2005-05-10 00:58:08 +00:00
|
|
|
if (!_bIsValid) {
|
2006-04-14 01:06:08 +00:00
|
|
|
debug(6, "Invalid node");
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
2006-05-03 20:43:26 +00:00
|
|
|
return false; // Empty list
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!_bIsDirectory) {
|
2006-04-14 01:06:08 +00:00
|
|
|
debug(6, "Not a directory");
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
2006-05-03 20:43:26 +00:00
|
|
|
return false; // Empty list
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2014-10-11 20:13:25 +02:00
|
|
|
if (isRootNode()) {
|
2006-04-14 01:06:08 +00:00
|
|
|
debug(6, "Root node");
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
2006-05-03 20:43:26 +00:00
|
|
|
myList = listVolumes();
|
|
|
|
return true;
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-25 09:57:38 +00:00
|
|
|
APTR context = IDOS->ObtainDirContextTags( EX_FileLockInput, _pFileLock,
|
|
|
|
EX_DoCurrentDir, TRUE, /* for softlinks */
|
|
|
|
EX_DataFields, (EXF_NAME|EXF_LINK|EXF_TYPE),
|
|
|
|
TAG_END);
|
|
|
|
if (context) {
|
2014-09-21 17:46:03 +02:00
|
|
|
struct ExamineData * pExd = NULL; // NB: No need to free the value after usage, everything will be dealt with by the DirContext release
|
2009-09-25 09:57:38 +00:00
|
|
|
|
|
|
|
AmigaOSFilesystemNode *entry ;
|
2009-09-30 16:16:53 +00:00
|
|
|
while ( (pExd = IDOS->ExamineDir(context)) ) {
|
|
|
|
if ( (EXD_IS_FILE(pExd) && ( Common::FSNode::kListFilesOnly == mode ))
|
2009-09-25 09:57:38 +00:00
|
|
|
|| (EXD_IS_DIRECTORY(pExd) && ( Common::FSNode::kListDirectoriesOnly == mode ))
|
|
|
|
|| Common::FSNode::kListAll == mode
|
|
|
|
)
|
|
|
|
{
|
|
|
|
BPTR pLock = IDOS->Lock( pExd->Name, SHARED_LOCK );
|
2009-09-30 16:16:53 +00:00
|
|
|
if (pLock) {
|
2009-09-25 09:57:38 +00:00
|
|
|
entry = new AmigaOSFilesystemNode( pLock, pExd->Name );
|
2009-09-30 16:16:53 +00:00
|
|
|
if (entry) {
|
2009-09-25 09:57:38 +00:00
|
|
|
myList.push_back(entry);
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-25 09:57:38 +00:00
|
|
|
IDOS->UnLock(pLock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-30 16:16:53 +00:00
|
|
|
|
|
|
|
if (ERROR_NO_MORE_ENTRIES != IDOS->IoErr() ) {
|
2010-06-15 12:33:20 +00:00
|
|
|
debug(6, "An error occurred during ExamineDir");
|
2009-09-25 09:57:38 +00:00
|
|
|
ret = false;
|
2009-09-30 16:16:53 +00:00
|
|
|
} else {
|
2009-09-25 09:57:38 +00:00
|
|
|
ret = true;
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2009-09-25 09:57:38 +00:00
|
|
|
IDOS->ReleaseDirContext(context);
|
2009-09-30 16:16:53 +00:00
|
|
|
} else {
|
2009-09-25 09:57:38 +00:00
|
|
|
debug(6, "Unable to ObtainDirContext");
|
|
|
|
ret = false;
|
2007-10-31 19:37:34 +00:00
|
|
|
}
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-10-31 19:37:34 +00:00
|
|
|
LEAVE();
|
2009-09-25 09:57:38 +00:00
|
|
|
|
|
|
|
return ret;
|
2007-10-31 19:37:34 +00:00
|
|
|
}
|
|
|
|
|
2008-10-02 16:58:59 +00:00
|
|
|
AbstractFSNode *AmigaOSFilesystemNode::getParent() const {
|
2005-05-10 00:58:08 +00:00
|
|
|
ENTER();
|
|
|
|
|
2014-10-11 20:13:25 +02:00
|
|
|
if (isRootNode()) {
|
2006-04-14 01:06:08 +00:00
|
|
|
debug(6, "Root node");
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
2006-04-04 21:01:26 +00:00
|
|
|
return new AmigaOSFilesystemNode(*this);
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2014-10-11 20:13:25 +02:00
|
|
|
BPTR pLock = _pFileLock;
|
|
|
|
|
|
|
|
if (!_bIsDirectory) {
|
|
|
|
assert(!pLock);
|
|
|
|
pLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK);
|
|
|
|
assert(pLock);
|
|
|
|
}
|
|
|
|
|
2006-04-08 12:39:27 +00:00
|
|
|
AmigaOSFilesystemNode *node;
|
|
|
|
|
2014-10-11 20:13:25 +02:00
|
|
|
BPTR parentDir = IDOS->ParentDir( pLock );
|
2006-01-27 15:51:41 +00:00
|
|
|
if (parentDir) {
|
|
|
|
node = new AmigaOSFilesystemNode(parentDir);
|
|
|
|
IDOS->UnLock(parentDir);
|
2009-09-30 16:16:53 +00:00
|
|
|
} else
|
2005-05-10 00:58:08 +00:00
|
|
|
node = new AmigaOSFilesystemNode();
|
|
|
|
|
2014-10-11 20:13:25 +02:00
|
|
|
if (!_bIsDirectory) {
|
|
|
|
IDOS->UnLock(pLock);
|
|
|
|
}
|
|
|
|
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-05-03 02:39:33 +00:00
|
|
|
return node;
|
2006-04-30 22:52:10 +00:00
|
|
|
}
|
|
|
|
|
2007-10-31 17:43:40 +00:00
|
|
|
bool AmigaOSFilesystemNode::isReadable() const {
|
2014-01-22 22:51:44 +01:00
|
|
|
if (!_bIsValid)
|
|
|
|
return false;
|
|
|
|
|
2009-09-25 09:57:38 +00:00
|
|
|
// Regular RWED protection flags are low-active or inverted, thus the negation.
|
2014-10-11 20:13:25 +02:00
|
|
|
// Moreover, a pseudo root filesystem is readable whatever the
|
2014-09-21 17:46:03 +02:00
|
|
|
// protection says.
|
2014-10-11 20:13:25 +02:00
|
|
|
bool readable = !(_nProt & EXDF_OTR_READ) || isRootNode();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-10-31 17:43:40 +00:00
|
|
|
return readable;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AmigaOSFilesystemNode::isWritable() const {
|
2014-01-22 22:51:44 +01:00
|
|
|
if (!_bIsValid)
|
|
|
|
return false;
|
|
|
|
|
2009-09-25 09:57:38 +00:00
|
|
|
// Regular RWED protection flags are low-active or inverted, thus the negation.
|
2014-10-11 20:13:25 +02:00
|
|
|
// Moreover, a pseudo root filesystem is never writable whatever
|
2014-09-21 17:46:03 +02:00
|
|
|
// the protection says (Because of it's pseudo nature).
|
2014-10-11 20:13:25 +02:00
|
|
|
bool writable = !(_nProt & EXDF_OTR_WRITE) && !isRootNode();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2007-10-31 17:43:40 +00:00
|
|
|
return writable;
|
|
|
|
}
|
|
|
|
|
2009-09-25 09:57:38 +00:00
|
|
|
AbstractFSList AmigaOSFilesystemNode::listVolumes() const {
|
2005-05-10 00:58:08 +00:00
|
|
|
ENTER();
|
2006-04-14 01:06:08 +00:00
|
|
|
|
2006-05-03 11:13:21 +00:00
|
|
|
AbstractFSList myList;
|
2005-05-10 00:58:08 +00:00
|
|
|
|
2006-04-08 12:39:27 +00:00
|
|
|
const uint32 kLockFlags = LDF_READ | LDF_VOLUMES;
|
2006-09-16 17:56:26 +00:00
|
|
|
char buffer[MAXPATHLEN];
|
2005-05-10 00:58:08 +00:00
|
|
|
|
2006-04-08 12:39:27 +00:00
|
|
|
struct DosList *dosList = IDOS->LockDosList(kLockFlags);
|
2005-05-10 00:58:08 +00:00
|
|
|
if (!dosList) {
|
2006-04-14 01:06:08 +00:00
|
|
|
debug(6, "Cannot lock the DOS list");
|
2005-05-10 00:58:08 +00:00
|
|
|
LEAVE();
|
|
|
|
return myList;
|
|
|
|
}
|
|
|
|
|
|
|
|
dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES);
|
|
|
|
while (dosList) {
|
|
|
|
if (dosList->dol_Type == DLT_VOLUME &&
|
2015-01-26 19:56:24 +02:00
|
|
|
dosList->dol_Name &&
|
|
|
|
dosList->dol_Port) {
|
2013-10-25 21:11:12 +02:00
|
|
|
|
2014-09-21 17:46:03 +02:00
|
|
|
// The original line was
|
|
|
|
//if (dosList->dol_Type == DLT_VOLUME &&
|
|
|
|
//dosList->dol_Name &&
|
|
|
|
//dosList->dol_Task) {
|
2013-10-25 21:11:12 +02:00
|
|
|
// which errored using SDK 53.24 with a 'struct dosList' has no member called 'dol_Task'
|
2015-01-26 19:56:24 +02:00
|
|
|
// The reason for that was that
|
|
|
|
// 1) dol_Task wasn't a task pointer, it is a message port instead
|
|
|
|
// 2) It was redefined to be dol_Port in dos/obsolete.h in afore mentioned SDK
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-09-16 17:56:26 +00:00
|
|
|
// Copy name to buffer
|
|
|
|
IDOS->CopyStringBSTRToC(dosList->dol_Name, buffer, MAXPATHLEN);
|
|
|
|
|
|
|
|
// Volume name + '\0'
|
|
|
|
char *volName = new char [strlen(buffer) + 1];
|
|
|
|
|
|
|
|
strcpy(volName, buffer);
|
2005-05-10 00:58:08 +00:00
|
|
|
|
2006-09-16 17:56:26 +00:00
|
|
|
strcat(buffer, ":");
|
2005-05-10 00:58:08 +00:00
|
|
|
|
2006-09-16 17:56:26 +00:00
|
|
|
BPTR volumeLock = IDOS->Lock((STRPTR)buffer, SHARED_LOCK);
|
2006-04-08 12:39:27 +00:00
|
|
|
if (volumeLock) {
|
2006-09-16 17:56:26 +00:00
|
|
|
|
|
|
|
char *devName = new char [MAXPATHLEN];
|
|
|
|
|
|
|
|
// Find device name
|
|
|
|
IDOS->DevNameFromLock(volumeLock, devName, MAXPATHLEN, DN_DEVICEONLY);
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2006-09-16 17:56:26 +00:00
|
|
|
sprintf(buffer, "%s (%s)", volName, devName);
|
|
|
|
|
2008-05-07 14:31:45 +00:00
|
|
|
delete[] devName;
|
2006-09-16 17:56:26 +00:00
|
|
|
|
|
|
|
AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, buffer);
|
2005-05-10 00:58:08 +00:00
|
|
|
if (entry) {
|
2009-09-25 09:57:38 +00:00
|
|
|
myList.push_back(entry);
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
2006-09-16 17:56:26 +00:00
|
|
|
|
2006-04-08 12:39:27 +00:00
|
|
|
IDOS->UnLock(volumeLock);
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
2006-09-16 17:56:26 +00:00
|
|
|
|
2008-05-07 14:31:45 +00:00
|
|
|
delete[] volName;
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
2014-09-22 11:01:09 +03:00
|
|
|
dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES);
|
2005-05-10 00:58:08 +00:00
|
|
|
}
|
|
|
|
|
2006-04-08 12:39:27 +00:00
|
|
|
IDOS->UnLockDosList(kLockFlags);
|
2005-05-10 00:58:08 +00:00
|
|
|
|
|
|
|
LEAVE();
|
2008-01-27 19:47:41 +00:00
|
|
|
|
2005-05-10 00:58:08 +00:00
|
|
|
return myList;
|
|
|
|
}
|
|
|
|
|
2009-01-23 03:41:36 +00:00
|
|
|
Common::SeekableReadStream *AmigaOSFilesystemNode::createReadStream() {
|
2011-05-03 10:33:03 +02:00
|
|
|
return StdioStream::makeFromPath(getPath(), false);
|
2008-09-03 12:56:46 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 03:41:36 +00:00
|
|
|
Common::WriteStream *AmigaOSFilesystemNode::createWriteStream() {
|
2011-05-03 10:33:03 +02:00
|
|
|
return StdioStream::makeFromPath(getPath(), true);
|
2008-09-03 12:56:46 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 16:49:17 +06:00
|
|
|
bool AmigaOSFilesystemNode::create(bool isDirectory) {
|
|
|
|
error("Not supported");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-05-03 02:39:33 +00:00
|
|
|
#endif //defined(__amigaos4__)
|