diff options
author | Kamil Zbróg | 2014-01-27 21:43:05 +0100 |
---|---|---|
committer | Kamil Zbróg | 2014-01-27 21:43:05 +0100 |
commit | 8eac80cfc59c34299899ebe18a3b0582ef76e0d2 (patch) | |
tree | 5d02a8fba0559c16f2a2045b14e3e292509c6924 /backends/fs/wii | |
parent | 444934a0accec982f55db92c17ef65270fe18e66 (diff) | |
parent | 0f5eeaed7b3c9d2f74eee7dff2114c5f4dc63f00 (diff) | |
download | scummvm-rg350-8eac80cfc59c34299899ebe18a3b0582ef76e0d2.tar.gz scummvm-rg350-8eac80cfc59c34299899ebe18a3b0582ef76e0d2.tar.bz2 scummvm-rg350-8eac80cfc59c34299899ebe18a3b0582ef76e0d2.zip |
Merge remote-tracking branch 'sync/master' into prince-malik
Diffstat (limited to 'backends/fs/wii')
-rw-r--r-- | backends/fs/wii/wii-fs-factory.cpp | 15 | ||||
-rw-r--r-- | backends/fs/wii/wii-fs.cpp | 44 | ||||
-rw-r--r-- | backends/fs/wii/wii-fs.h | 2 |
3 files changed, 42 insertions, 19 deletions
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..f785101099 100644 --- a/backends/fs/wii/wii-fs.h +++ b/backends/fs/wii/wii-fs.h @@ -51,7 +51,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; |