mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-22 01:57:16 +00:00
Added FilesystemNode::getNodeForPath, but right now only for Mac OS X
svn-id: r12692
This commit is contained in:
parent
9fe1aaa921
commit
28f8f4d091
@ -86,13 +86,15 @@ public:
|
||||
*/
|
||||
static FilesystemNode *getRoot();
|
||||
|
||||
#ifdef MACOSX
|
||||
/*
|
||||
* Construct a node based on a path; the path is in the same format as it
|
||||
* would be for calls to fopen().
|
||||
*
|
||||
* I.e. getNodeForPath(oldNode.path()) should create a new node identical to oldNode.
|
||||
*/
|
||||
// static FilesystemNode *getNodeForPath(const String &path);
|
||||
static FilesystemNode *getNodeForPath(const String &path);
|
||||
#endif
|
||||
|
||||
virtual ~FilesystemNode() {}
|
||||
|
||||
|
@ -83,6 +83,12 @@ FilesystemNode *FilesystemNode::getRoot() {
|
||||
return new POSIXFilesystemNode();
|
||||
}
|
||||
|
||||
#ifdef MACOSX
|
||||
FilesystemNode *FilesystemNode::getNodeForPath(const String &path) {
|
||||
return new POSIXFilesystemNode(path);
|
||||
}
|
||||
#endif
|
||||
|
||||
POSIXFilesystemNode::POSIXFilesystemNode() {
|
||||
#ifndef __DC__
|
||||
char buf[MAXPATHLEN];
|
||||
@ -99,16 +105,33 @@ POSIXFilesystemNode::POSIXFilesystemNode() {
|
||||
_isDirectory = true;
|
||||
}
|
||||
|
||||
/*
|
||||
POSIXFilesystemNode::POSIXFilesystemNode(const String &p) {
|
||||
// TODO - extract last component from path
|
||||
_displayName = p;
|
||||
// TODO - check whether it is a directory, and whether the file actually exists
|
||||
int len = 0, offset = p.size();
|
||||
struct stat st;
|
||||
|
||||
assert(offset > 0);
|
||||
|
||||
_path = p;
|
||||
|
||||
// Extract last component from path
|
||||
const char *str = p.c_str();
|
||||
while (offset > 0 && str[offset-1] == '/')
|
||||
offset--;
|
||||
while (offset > 0 && str[offset-1] != '/') {
|
||||
len++;
|
||||
offset--;
|
||||
}
|
||||
_displayName = String(str + offset, len);
|
||||
|
||||
// Check whether it is a directory, and whether the file actually exists
|
||||
#ifdef __DC__
|
||||
_isValid = true;
|
||||
_isDirectory = true;
|
||||
_path = p;
|
||||
#else
|
||||
_isValid = (0 == stat(_path.c_str(), &st));
|
||||
_isDirectory = S_ISDIR(st.st_mode);
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
|
||||
POSIXFilesystemNode::POSIXFilesystemNode(const POSIXFilesystemNode *node) {
|
||||
_displayName = node->_displayName;
|
||||
@ -126,7 +149,7 @@ FSList *POSIXFilesystemNode::listDir(ListMode mode) const {
|
||||
FSList *myList = new FSList();
|
||||
|
||||
if (dirp == NULL) return myList;
|
||||
|
||||
|
||||
// ... loop over dir entries using readdir
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
// Skip 'invisible' files
|
||||
@ -136,6 +159,8 @@ FSList *POSIXFilesystemNode::listDir(ListMode mode) const {
|
||||
POSIXFilesystemNode entry;
|
||||
entry._displayName = dp->d_name;
|
||||
entry._path = _path;
|
||||
if (entry._path.lastChar() != '/')
|
||||
entry._path += '/';
|
||||
entry._path += dp->d_name;
|
||||
|
||||
#ifdef __DC__
|
||||
|
@ -82,7 +82,7 @@ TCHAR* WindowsFilesystemNode::toUnicode(char *x) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void WindowsFilesystemNode::addFile (FSList* list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) {
|
||||
void WindowsFilesystemNode::addFile(FSList* list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) {
|
||||
WindowsFilesystemNode entry;
|
||||
char *asciiName = toAscii(find_data->cFileName);
|
||||
bool isDirectory;
|
||||
|
Loading…
x
Reference in New Issue
Block a user