diff options
author | Max Horn | 2002-11-19 01:36:47 +0000 |
---|---|---|
committer | Max Horn | 2002-11-19 01:36:47 +0000 |
commit | ce3cde15a027fd092d0d27fa165f0166d4ecb927 (patch) | |
tree | 6da6d74fef1a1bf25b6380eed687f6fcc1f1068a /backends/fs | |
parent | f2007606a9155190ffe061dfde90fd1711ec73e8 (diff) | |
download | scummvm-rg350-ce3cde15a027fd092d0d27fa165f0166d4ecb927.tar.gz scummvm-rg350-ce3cde15a027fd092d0d27fa165f0166d4ecb927.tar.bz2 scummvm-rg350-ce3cde15a027fd092d0d27fa165f0166d4ecb927.zip |
added some preliminary game auto detect code to the launcher; this required a small change to the FS API, Windows/Morphos code will have to be adapted slightly I fear. Also, not all games are detected correctly, and some probably never will be, so we still have to add a dialog for cases where auto detect doesn't work
svn-id: r5600
Diffstat (limited to 'backends/fs')
-rw-r--r-- | backends/fs/fs.h | 12 | ||||
-rw-r--r-- | backends/fs/posix/posix-fs.cpp | 10 |
2 files changed, 17 insertions, 5 deletions
diff --git a/backends/fs/fs.h b/backends/fs/fs.h index 47e47d3a9e..7bb63c9671 100644 --- a/backends/fs/fs.h +++ b/backends/fs/fs.h @@ -68,6 +68,16 @@ protected: typedef ScummVM::String String; public: + + /* + * Flag to tell listDir() which kind of files to list. + */ + typedef enum { + kListFilesOnly = 1, + kListDirectoriesOnly = 2, + kListAll = 3 + } ListMode; + /* * The starting point for any file system browsing. Returns a special node * representing the FS root. @@ -110,7 +120,7 @@ public: * List the content of this directory node. * If this node is not a directory, throw an exception or call error(). */ - virtual FSList *listDir() const = 0; + virtual FSList *listDir(ListMode mode = kListDirectoriesOnly) const = 0; /* * The parent node of this directory. diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 0ea131b3f9..5cdda13bc2 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -50,7 +50,7 @@ public: virtual bool isDirectory() const { return _isDirectory; } virtual String path() const { return _path; } - virtual FSList *listDir() const; + virtual FSList *listDir(ListMode mode = kListDirectoriesOnly) const; virtual FilesystemNode *parent() const; virtual FilesystemNode *clone() const { return new POSIXFilesystemNode(this); } }; @@ -85,7 +85,7 @@ POSIXFilesystemNode::POSIXFilesystemNode(const POSIXFilesystemNode *node) { _path = node->_path; } -FSList *POSIXFilesystemNode::listDir() const { +FSList *POSIXFilesystemNode::listDir(ListMode mode) const { assert(_isDirectory); DIR *dirp = opendir(_path.c_str()); struct stat st; @@ -109,8 +109,10 @@ FSList *POSIXFilesystemNode::listDir() const { continue; entry._isDirectory = S_ISDIR(st.st_mode); - // FIXME - skip any non-directories for now - if (!entry._isDirectory) continue; + // Honor the chosen mode + if ((mode == kListFilesOnly && entry._isDirectory) || + (mode == kListDirectoriesOnly && !entry._isDirectory)) + continue; if (entry._isDirectory) entry._path += "/"; |