diff options
Diffstat (limited to 'backends/fs')
47 files changed, 185 insertions, 93 deletions
diff --git a/backends/fs/abstract-fs.cpp b/backends/fs/abstract-fs.cpp index 372c7423dd..c3991ee8f4 100644 --- a/backends/fs/abstract-fs.cpp +++ b/backends/fs/abstract-fs.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #include "backends/fs/abstract-fs.h" diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h index 2b66a6e6e1..34a8120caa 100644 --- a/backends/fs/abstract-fs.h +++ b/backends/fs/abstract-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef BACKENDS_ABSTRACT_FS_H diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.cpp b/backends/fs/amigaos4/amigaos4-fs-factory.cpp index a62b581f39..4ca65e53a5 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.cpp +++ b/backends/fs/amigaos4/amigaos4-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(__amigaos4__) diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.h b/backends/fs/amigaos4/amigaos4-fs-factory.h index 0390e85072..432caf6fcf 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.h +++ b/backends/fs/amigaos4/amigaos4-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef AMIGAOS_FILESYSTEM_FACTORY_H diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index fe388c2a6e..6d5b099736 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(__amigaos4__) @@ -61,7 +62,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode() { _bIsDirectory = true; _sPath = ""; _pFileLock = 0; - _nProt = 0; // protection is ignored for the root volume + _nProt = 0; // Protection is ignored for the root volume LEAVE(); } @@ -81,8 +82,9 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) { _sDisplayName = ::lastPathComponent(_sPath); _pFileLock = 0; _bIsDirectory = false; + _bIsValid = false; - // Check whether the node exists and if it is a directory + // Check whether the node exists and if it's a directory struct ExamineData * pExd = IDOS->ExamineObjectTags(EX_StringNameInput,_sPath.c_str(),TAG_END); if (pExd) { _nProt = pExd->Protection; @@ -91,7 +93,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const Common::String &p) { _pFileLock = IDOS->Lock((CONST_STRPTR)_sPath.c_str(), SHARED_LOCK); _bIsValid = (_pFileLock != 0); - // Add a trailing slash if it is needed + // Add a trailing slash if needed const char c = _sPath.lastChar(); if (c != '/' && c != ':') _sPath += '/'; @@ -132,7 +134,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayNam delete[] n; } - _bIsValid = false; + _bIsValid = false; _bIsDirectory = false; struct ExamineData * pExd = IDOS->ExamineObjectTags(EX_FileLockInput,pLock,TAG_END); @@ -186,10 +188,10 @@ bool AmigaOSFilesystemNode::exists() const { bool nodeExists = false; - // previously we were trying to examine the node in order + // Previously we were trying to examine the node in order // to determine if the node exists or not. // I don't see the point : once you have been granted a - // lock on it then it means it exists... + // lock on it, it means it exists... // // ============================= Old code // BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK); @@ -235,8 +237,8 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b ENTER(); bool ret = false; - //TODO: honor the hidden flag - // There is nothing like a hidden flag under AmigaOS... + // TODO: Honor the hidden flag + // There is no such thing as a hidden flag in AmigaOS... if (!_bIsValid) { debug(6, "Invalid node"); @@ -250,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(); @@ -262,7 +264,7 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b EX_DataFields, (EXF_NAME|EXF_LINK|EXF_TYPE), TAG_END); if (context) { - struct ExamineData * pExd = NULL; // NB: no need to free value after usage, all is dealt by the DirContext release + struct ExamineData * pExd = NULL; // NB: No need to free the value after usage, everything will be dealt with by the DirContext release AmigaOSFilesystemNode *entry ; while ( (pExd = IDOS->ExamineDir(context)) ) { @@ -305,46 +307,58 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b AbstractFSNode *AmigaOSFilesystemNode::getParent() const { ENTER(); - if (!_bIsDirectory) { - debug(6, "Not a directory"); - LEAVE(); - return 0; - } - - 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; } bool AmigaOSFilesystemNode::isReadable() const { + if (!_bIsValid) + return false; + // Regular RWED protection flags are low-active or inverted, thus the negation. - // moreover pseudo root filesystem (null _pFileLock) is readable whatever the - // protection says - bool readable = !(_nProt & EXDF_READ) || _pFileLock == 0; + // Moreover, a pseudo root filesystem is readable whatever the + // protection says. + bool readable = !(_nProt & EXDF_OTR_READ) || isRootNode(); return readable; } bool AmigaOSFilesystemNode::isWritable() const { + if (!_bIsValid) + return false; + // Regular RWED protection flags are low-active or inverted, thus the negation. - // moreover pseudo root filesystem (null _pFileLock) is never writable whatever - // the protection says (because of the pseudo nature) - bool writable = !(_nProt & EXDF_WRITE) && _pFileLock !=0; + // Moreover, a pseudo root filesystem is never writable whatever + // the protection says (Because of it's pseudo nature). + bool writable = !(_nProt & EXDF_OTR_WRITE) && !isRootNode(); return writable; } @@ -368,7 +382,16 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const { while (dosList) { if (dosList->dol_Type == DLT_VOLUME && dosList->dol_Name && - dosList->dol_Task) { + dosList->dol_Port) { + + // The original line was + //if (dosList->dol_Type == DLT_VOLUME && + //dosList->dol_Name && + //dosList->dol_Task) { + // which errored using SDK 53.24 with a 'struct dosList' has no member called 'dol_Task' + // 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 // Copy name to buffer IDOS->CopyStringBSTRToC(dosList->dol_Name, buffer, MAXPATHLEN); @@ -402,7 +425,7 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const { delete[] volName; } - dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES); + dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES); } IDOS->UnLockDosList(kLockFlags); diff --git a/backends/fs/amigaos4/amigaos4-fs.h b/backends/fs/amigaos4/amigaos4-fs.h index c5ca61476f..408354888e 100644 --- a/backends/fs/amigaos4/amigaos4-fs.h +++ b/backends/fs/amigaos4/amigaos4-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef AMIGAOS_FILESYSTEM_H @@ -43,7 +44,13 @@ */ class AmigaOSFilesystemNode : public AbstractFSNode { protected: + /** + * The main file lock. + * If this is NULL but _bIsValid is true, then this Node references + * the virtual filesystem root. + */ BPTR _pFileLock; + Common::String _sDisplayName; Common::String _sPath; bool _bIsDirectory; @@ -55,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. @@ -69,19 +81,19 @@ public: AmigaOSFilesystemNode(const Common::String &p); /** - * Creates an AmigaOSFilesystemNode given its lock and display name + * Creates an AmigaOSFilesystemNode given its lock and display name. * * @param pLock BPTR to the lock. * @param pDisplayName name to be used for display, in case not supplied the FilePart() of the filename will be used. * - * @note This shouldn't even be public as it's only internally, at best it should have been protected if not private + * @note This shouldn't even be public as it's only internally, at best it should have been protected if not private. */ AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0); /** * Copy constructor. * - * @note Needed because it duplicates the file lock + * @note Needed because it duplicates the file lock. */ AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node); diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp index 4e09c3446b..98c522f1d6 100644 --- a/backends/fs/ds/ds-fs-factory.cpp +++ b/backends/fs/ds/ds-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ // Disable symbol overrides for FILE as that is used in FLAC headers diff --git a/backends/fs/ds/ds-fs-factory.h b/backends/fs/ds/ds-fs-factory.h index ed5804b94a..7c42145518 100644 --- a/backends/fs/ds/ds-fs-factory.h +++ b/backends/fs/ds/ds-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef DS_FILESYSTEM_FACTORY_H diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index e3f282df05..3782caf432 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/ds/ds-fs.h b/backends/fs/ds/ds-fs.h index 862f4c39d2..b9ccfcbe9c 100644 --- a/backends/fs/ds/ds-fs.h +++ b/backends/fs/ds/ds-fs.h @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/fs-factory.h b/backends/fs/fs-factory.h index 6d378955ec..fce82a9847 100644 --- a/backends/fs/fs-factory.h +++ b/backends/fs/fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef FILESYSTEM_FACTORY_H diff --git a/backends/fs/n64/n64-fs-factory.cpp b/backends/fs/n64/n64-fs-factory.cpp index 5c588c5eb5..e662d6fd9b 100644 --- a/backends/fs/n64/n64-fs-factory.cpp +++ b/backends/fs/n64/n64-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifdef __N64__ diff --git a/backends/fs/n64/n64-fs-factory.h b/backends/fs/n64/n64-fs-factory.h index 5dec7c7eab..0a6ac8f41e 100644 --- a/backends/fs/n64/n64-fs-factory.h +++ b/backends/fs/n64/n64-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef N64_FILESYSTEM_FACTORY_H diff --git a/backends/fs/n64/n64-fs.h b/backends/fs/n64/n64-fs.h index d177cae9b4..d503a6601e 100644 --- a/backends/fs/n64/n64-fs.h +++ b/backends/fs/n64/n64-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef N64_FILESYSTEM_H diff --git a/backends/fs/n64/romfsstream.cpp b/backends/fs/n64/romfsstream.cpp index 570f25932d..8661f8e9ab 100644 --- a/backends/fs/n64/romfsstream.cpp +++ b/backends/fs/n64/romfsstream.cpp @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/n64/romfsstream.h b/backends/fs/n64/romfsstream.h index b0f27db13e..7c64bce3f3 100644 --- a/backends/fs/n64/romfsstream.h +++ b/backends/fs/n64/romfsstream.h @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index 776ea86155..d6266c78c9 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(POSIX) || defined(PLAYSTATION3) diff --git a/backends/fs/posix/posix-fs-factory.h b/backends/fs/posix/posix-fs-factory.h index c7cec6fab5..7aedde5b01 100644 --- a/backends/fs/posix/posix-fs-factory.h +++ b/backends/fs/posix/posix-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef POSIX_FILESYSTEM_FACTORY_H diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 320c5a6f39..4baf9f14fe 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(POSIX) || defined(PLAYSTATION3) diff --git a/backends/fs/posix/posix-fs.h b/backends/fs/posix/posix-fs.h index e124829c02..bd07749010 100644 --- a/backends/fs/posix/posix-fs.h +++ b/backends/fs/posix/posix-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef POSIX_FILESYSTEM_H diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp index ef7b2013a3..9c12d27a6e 100644 --- a/backends/fs/ps2/ps2-fs-factory.cpp +++ b/backends/fs/ps2/ps2-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(__PLAYSTATION2__) diff --git a/backends/fs/ps2/ps2-fs-factory.h b/backends/fs/ps2/ps2-fs-factory.h index 9c6709cccf..d6745a64d3 100644 --- a/backends/fs/ps2/ps2-fs-factory.h +++ b/backends/fs/ps2/ps2-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef PS2_FILESYSTEM_FACTORY_H diff --git a/backends/fs/ps2/ps2-fs.cpp b/backends/fs/ps2/ps2-fs.cpp index 3a86cb3d9c..9b6e1270f1 100644 --- a/backends/fs/ps2/ps2-fs.cpp +++ b/backends/fs/ps2/ps2-fs.cpp @@ -17,13 +17,14 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(__PLAYSTATION2__) -// Disable symbol overrides so that we can use system headers. -#define FORBIDDEN_SYMBOL_ALLOW_ALL - +// Disable symbol overrides so that we can use "FILE" +#define FORBIDDEN_SYMBOL_EXCEPTION_FILE +#define FORBIDDEN_SYMBOL_EXCEPTION_printf #include "backends/fs/ps2/ps2-fs.h" @@ -57,13 +58,13 @@ const char *_lastPathComponent(const Common::String &str) { cur++; - // printf("lastPathComponent path=%s token=%s\n", start, cur); + // dbg_printf("lastPathComponent path=%s token=%s\n", start, cur); return cur; } Ps2FilesystemNode::Ps2FilesystemNode() { - printf("NEW FSNODE()\n"); + dbg_printf("NEW FSNODE()\n"); _isHere = true; _isDirectory = true; @@ -74,7 +75,7 @@ Ps2FilesystemNode::Ps2FilesystemNode() { } Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path) { - printf("NEW FSNODE(%s)\n", path.c_str()); + dbg_printf("NEW FSNODE(%s)\n", path.c_str()); _path = path; @@ -106,7 +107,7 @@ Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path) { } Ps2FilesystemNode::Ps2FilesystemNode(const Common::String &path, bool verify) { - printf("NEW FSNODE(%s, %d)\n", path.c_str(), verify); + dbg_printf("NEW FSNODE(%s, %d)\n", path.c_str(), verify); _path = path; @@ -163,24 +164,24 @@ void Ps2FilesystemNode::doverify(void) { _verified = true; - printf(" verify: %s -> ", _path.c_str()); + dbg_printf(" verify: %s -> ", _path.c_str()); #if 0 if (_path.empty()) { - printf("PlayStation 2 Root !\n"); + dbg_printf("PlayStation 2 Root !\n"); _verified = true; return; } if (_path.lastChar() == ':') { - printf("Dev: %s\n", _path.c_str()); + dbg_printf("Dev: %s\n", _path.c_str()); _verified = true; return; } #endif if (_path[3] != ':' && _path[4] != ':') { - printf("relative path !\n"); + dbg_printf("relative path !\n"); _isHere = false; _isDirectory = false; return; @@ -203,7 +204,7 @@ void Ps2FilesystemNode::doverify(void) { fileXioWaitAsync(FXIO_WAIT, &fd); if (!fd) { - printf(" yes [stat]\n"); + dbg_printf(" yes [stat]\n"); return true; } break; @@ -217,11 +218,11 @@ void Ps2FilesystemNode::doverify(void) { #if 1 fd = fio.open(_path.c_str(), O_RDONLY); - printf("_path = %s -- fio.open -> %d\n", _path.c_str(), fd); + dbg_printf("_path = %s -- fio.open -> %d\n", _path.c_str(), fd); if (fd >=0) { fio.close(fd); - printf(" yes [open]\n"); + dbg_printf(" yes [open]\n"); _isHere = true; if (medium==MC_DEV && _path.lastChar()=='/') _isDirectory = true; @@ -233,7 +234,7 @@ void Ps2FilesystemNode::doverify(void) { fd = fio.dopen(_path.c_str()); if (fd >=0) { fio.dclose(fd); - printf(" yes [dopen]\n"); + dbg_printf(" yes [dopen]\n"); _isHere = true; _isDirectory = true; return; @@ -266,13 +267,13 @@ void Ps2FilesystemNode::doverify(void) { _isHere = false; _isDirectory = false; - printf(" no\n"); + dbg_printf(" no\n"); return; } AbstractFSNode *Ps2FilesystemNode::getChild(const Common::String &n) const { - printf("getChild : %s\n", n.c_str()); + dbg_printf("getChild : %s\n", n.c_str()); if (!_isDirectory) return NULL; @@ -327,13 +328,14 @@ AbstractFSNode *Ps2FilesystemNode::getChild(const Common::String &n) const { bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const { //TODO: honor the hidden flag - // printf("getChildren\n"); + // dbg_printf("getChildren\n"); if (!_isDirectory) return false; if (_isRoot) { - list.push_back(new Ps2FilesystemNode("cdfs:")); + if (g_systemPs2->cdPresent()) + list.push_back(new Ps2FilesystemNode("cdfs:")); if (g_systemPs2->hddPresent()) list.push_back(new Ps2FilesystemNode("pfs0:")); @@ -341,7 +343,7 @@ bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi if (g_systemPs2->usbMassPresent()) list.push_back(new Ps2FilesystemNode("mass:")); - if (g_systemPs2->getBootDevice()==HOST_DEV || g_systemPs2->netPresent()) + if (g_systemPs2->netPresent()) list.push_back(new Ps2FilesystemNode("host:")); if (g_systemPs2->mcPresent()) @@ -356,7 +358,7 @@ bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi else fd = fio.dopen(_path.c_str()); - // printf("dopen = %d\n", fd); + // dbg_printf("dopen = %d\n", fd); if (fd >= 0) { iox_dirent_t dirent; @@ -398,7 +400,7 @@ bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi } AbstractFSNode *Ps2FilesystemNode::getParent() const { - // printf("Ps2FilesystemNode::getParent : path = %s\n", _path.c_str()); + // dbg_printf("Ps2FilesystemNode::getParent : path = %s\n", _path.c_str()); if (_isRoot) return new Ps2FilesystemNode(this); // FIXME : 0 ??? @@ -410,7 +412,7 @@ AbstractFSNode *Ps2FilesystemNode::getParent() const { const char *end = _lastPathComponent(_path); Common::String str(start, end - start); - // printf(" parent = %s\n", str.c_str()); + // dbg_printf(" parent = %s\n", str.c_str()); return new Ps2FilesystemNode(str, true); } diff --git a/backends/fs/ps2/ps2-fs.h b/backends/fs/ps2/ps2-fs.h index df78f9f68a..63b866ba5b 100644 --- a/backends/fs/ps2/ps2-fs.h +++ b/backends/fs/ps2/ps2-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef PS2_FILESYSTEM_H @@ -69,12 +70,12 @@ public: virtual Common::String getPath() const { return _path; } virtual bool exists() const { - // printf("%s : is %d\n", _path.c_str(), _isHere); + // dbg_printf("%s : is %d\n", _path.c_str(), _isHere); return _isHere; } virtual bool isDirectory() const { - // printf("%s : dir %d\n", _path.c_str(), _isDirectory); + // dbg_printf("%s : dir %d\n", _path.c_str(), _isDirectory); return _isDirectory; } diff --git a/backends/fs/ps3/ps3-fs-factory.cpp b/backends/fs/ps3/ps3-fs-factory.cpp index 3257246c50..565452596f 100644 --- a/backends/fs/ps3/ps3-fs-factory.cpp +++ b/backends/fs/ps3/ps3-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #include "backends/fs/ps3/ps3-fs-factory.h" diff --git a/backends/fs/ps3/ps3-fs-factory.h b/backends/fs/ps3/ps3-fs-factory.h index 6c1988b1c9..f7d54a90fd 100644 --- a/backends/fs/ps3/ps3-fs-factory.h +++ b/backends/fs/ps3/ps3-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef PS3_FILESYSTEM_FACTORY_H diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp index bb3aca8ee6..303ea242c5 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(__PSP__) diff --git a/backends/fs/psp/psp-fs-factory.h b/backends/fs/psp/psp-fs-factory.h index d57c8fb655..26888487c2 100644 --- a/backends/fs/psp/psp-fs-factory.h +++ b/backends/fs/psp/psp-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef PSP_FILESYSTEM_FACTORY_H diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp index 67f4cd59a7..e8aad9fa98 100644 --- a/backends/fs/psp/psp-fs.cpp +++ b/backends/fs/psp/psp-fs.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(__PSP__) diff --git a/backends/fs/psp/psp-fs.h b/backends/fs/psp/psp-fs.h index 146debb5f1..1bb4543d19 100644 --- a/backends/fs/psp/psp-fs.h +++ b/backends/fs/psp/psp-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef PSP_FILESYSTEM_H diff --git a/backends/fs/psp/psp-stream.cpp b/backends/fs/psp/psp-stream.cpp index da5a46eedb..c9b2fc7d8c 100644 --- a/backends/fs/psp/psp-stream.cpp +++ b/backends/fs/psp/psp-stream.cpp @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/psp/psp-stream.h b/backends/fs/psp/psp-stream.h index 395b27392d..734cb66184 100644 --- a/backends/fs/psp/psp-stream.h +++ b/backends/fs/psp/psp-stream.h @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/stdiostream.cpp b/backends/fs/stdiostream.cpp index 3ea0f9898b..8206bd180f 100644 --- a/backends/fs/stdiostream.cpp +++ b/backends/fs/stdiostream.cpp @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/stdiostream.h b/backends/fs/stdiostream.h index 1d45600d9c..f2495feac8 100644 --- a/backends/fs/stdiostream.h +++ b/backends/fs/stdiostream.h @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/symbian/symbian-fs-factory.cpp b/backends/fs/symbian/symbian-fs-factory.cpp index 7a60109742..311a0bfd82 100644 --- a/backends/fs/symbian/symbian-fs-factory.cpp +++ b/backends/fs/symbian/symbian-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(__SYMBIAN32__) diff --git a/backends/fs/symbian/symbian-fs-factory.h b/backends/fs/symbian/symbian-fs-factory.h index b99d3fb0ec..940b58e22f 100644 --- a/backends/fs/symbian/symbian-fs-factory.h +++ b/backends/fs/symbian/symbian-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef SYMBIAN_FILESYSTEM_FACTORY_H diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index 7a652fa43c..8fbc3a402a 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(__SYMBIAN32__) diff --git a/backends/fs/symbian/symbian-fs.h b/backends/fs/symbian/symbian-fs.h index 0db9a88940..339e998a28 100644 --- a/backends/fs/symbian/symbian-fs.h +++ b/backends/fs/symbian/symbian-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef SYMBIAN_FILESYSTEM_H diff --git a/backends/fs/symbian/symbianstream.cpp b/backends/fs/symbian/symbianstream.cpp index fa7842d3b1..549bc54452 100644 --- a/backends/fs/symbian/symbianstream.cpp +++ b/backends/fs/symbian/symbianstream.cpp @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/symbian/symbianstream.h b/backends/fs/symbian/symbianstream.h index 3ca612e39b..f0ec095fea 100644 --- a/backends/fs/symbian/symbianstream.h +++ b/backends/fs/symbian/symbianstream.h @@ -8,12 +8,12 @@ * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp index 760e5316e7..f234c1e300 100644 --- a/backends/fs/wii/wii-fs-factory.cpp +++ b/backends/fs/wii/wii-fs-factory.cpp @@ -33,6 +33,9 @@ #ifdef USE_WII_DI #include <di/di.h> #include <iso9660.h> +#ifdef GAMECUBE +#include <ogc/dvd.h> +#endif #endif #ifdef USE_WII_SMB @@ -125,6 +128,14 @@ bool WiiFilesystemFactory::failedToMount(FileSystemType type) { return false; } +#ifdef USE_WII_DI +#ifndef GAMECUBE + const DISC_INTERFACE* dvd = &__io_wiidvd; +#else + const DISC_INTERFACE* dvd = &__io_gcdvd; +#endif +#endif + void WiiFilesystemFactory::mount(FileSystemType type) { switch (type) { case kDVD: @@ -133,7 +144,7 @@ void WiiFilesystemFactory::mount(FileSystemType type) { break; printf("mount dvd\n"); - if (ISO9660_Mount()) { + if (ISO9660_Mount("dvd", dvd)) { _dvdMounted = true; _dvdError = false; printf("ISO9660 mounted\n"); @@ -179,7 +190,7 @@ void WiiFilesystemFactory::umount(FileSystemType type) { printf("umount dvd\n"); - ISO9660_Unmount(); + ISO9660_Unmount("dvd:"); _dvdMounted = false; _dvdError = false; diff --git a/backends/fs/wii/wii-fs.cpp b/backends/fs/wii/wii-fs.cpp index 4a19e18240..43f4f592b7 100644 --- a/backends/fs/wii/wii-fs.cpp +++ b/backends/fs/wii/wii-fs.cpp @@ -80,9 +80,9 @@ void WiiFilesystemNode::clearFlags() { void WiiFilesystemNode::setFlags(const struct stat *st) { _exists = true; - _isDirectory = S_ISDIR(st->st_mode); - _isReadable = (st->st_mode & S_IRUSR) > 0; - _isWritable = (st->st_mode & S_IWUSR) > 0; + _isDirectory = ( (st->st_mode & S_IFDIR) != 0 ); + _isReadable = ( (st->st_mode & S_IRUSR) != 0 ); + _isWritable = ( (st->st_mode & S_IWUSR) != 0 ); } WiiFilesystemNode::WiiFilesystemNode() { @@ -106,7 +106,7 @@ WiiFilesystemNode::WiiFilesystemNode(const Common::String &p) { _displayName = lastPathComponent(_path, '/'); struct stat st; - if (!stat(_path.c_str(), &st)) + if(stat(_path.c_str(), &st) != -1) setFlags(&st); else clearFlags(); @@ -152,33 +152,45 @@ bool WiiFilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi if (_path.empty()) return getDevopChildren(list, mode, hidden); - DIR_ITER* dp = diropen (_path.c_str()); + DIR* dp = opendir (_path.c_str()); + DIR* tmpdir; if (dp == NULL) return false; - char filename[MAXPATHLEN]; - struct stat st; + struct dirent *pent; - while (dirnext(dp, filename, &st) == 0) { - if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0) + while ((pent = readdir(dp)) != NULL) { + if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0) continue; Common::String newPath(_path); if (newPath.lastChar() != '/') - newPath += '/'; - newPath += filename; - - bool isDir = S_ISDIR(st.st_mode); - + newPath += '/'; + newPath += pent->d_name; + + bool isDir = false; + tmpdir = opendir(newPath.c_str()); + if(tmpdir) + { + isDir = true; + closedir(tmpdir); + } + if ((mode == Common::FSNode::kListFilesOnly && isDir) || (mode == Common::FSNode::kListDirectoriesOnly && !isDir)) continue; - + + struct stat st; + st.st_mode = 0; + st.st_mode |= ( isDir ? S_IFDIR : 0 ); + st.st_mode |= S_IRUSR; + st.st_mode |= S_IWUSR; + list.push_back(new WiiFilesystemNode(newPath, &st)); } - dirclose(dp); + closedir(dp); return true; } diff --git a/backends/fs/wii/wii-fs.h b/backends/fs/wii/wii-fs.h index 11679d0c36..c77c543dae 100644 --- a/backends/fs/wii/wii-fs.h +++ b/backends/fs/wii/wii-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef WII_FILESYSTEM_H @@ -51,7 +52,7 @@ public: * * @param path Common::String with the path the new node should point to. */ - WiiFilesystemNode(const Common::String &path); + WiiFilesystemNode(const Common::String &p); WiiFilesystemNode(const Common::String &p, const struct stat *st); virtual bool exists() const; diff --git a/backends/fs/windows/windows-fs-factory.cpp b/backends/fs/windows/windows-fs-factory.cpp index 46df253748..9d1b13a0c9 100644 --- a/backends/fs/windows/windows-fs-factory.cpp +++ b/backends/fs/windows/windows-fs-factory.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(WIN32) diff --git a/backends/fs/windows/windows-fs-factory.h b/backends/fs/windows/windows-fs-factory.h index e7c70f1b55..b5df5406a8 100644 --- a/backends/fs/windows/windows-fs-factory.h +++ b/backends/fs/windows/windows-fs-factory.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef WINDOWS_FILESYSTEM_FACTORY_H diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index 030f394f81..49549b83cb 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #if defined(WIN32) diff --git a/backends/fs/windows/windows-fs.h b/backends/fs/windows/windows-fs.h index 351307bef0..d06044603a 100644 --- a/backends/fs/windows/windows-fs.h +++ b/backends/fs/windows/windows-fs.h @@ -17,6 +17,7 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * */ #ifndef WINDOWS_FILESYSTEM_H |