aboutsummaryrefslogtreecommitdiff
path: root/backends/fs/windows/windows-fs.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-02-07 14:25:04 +0000
committerTorbjörn Andersson2005-02-07 14:25:04 +0000
commitd6be4f03a7491530f5a2e944aa96c49855002b90 (patch)
tree68d78c6ccf677c507e3ae2e87ca3da357f5db097 /backends/fs/windows/windows-fs.cpp
parentcc3540a00dd5142324d634a1fd5842d6bcd06c1e (diff)
downloadscummvm-rg350-d6be4f03a7491530f5a2e944aa96c49855002b90.tar.gz
scummvm-rg350-d6be4f03a7491530f5a2e944aa96c49855002b90.tar.bz2
scummvm-rg350-d6be4f03a7491530f5a2e944aa96c49855002b90.zip
Added getNodeForPath() so I can compile ScummVM with MinGW again. Since I
don't know where it's used, I'm not sure if it works correctly. svn-id: r16752
Diffstat (limited to 'backends/fs/windows/windows-fs.cpp')
-rw-r--r--backends/fs/windows/windows-fs.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp
index 75af82cd2b..3ce0548d6c 100644
--- a/backends/fs/windows/windows-fs.cpp
+++ b/backends/fs/windows/windows-fs.cpp
@@ -89,7 +89,7 @@ void WindowsFilesystemNode::addFile(FSList &list, ListMode mode, const char *bas
// Skip local directory (.) and parent (..)
if (!strcmp(asciiName, ".") || !strcmp(asciiName, ".."))
return;
-
+
isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false);
if ((!isDirectory && mode == kListDirectoriesOnly) ||
@@ -112,6 +112,10 @@ AbstractFilesystemNode *FilesystemNode::getRoot() {
return new WindowsFilesystemNode();
}
+AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) {
+ return new WindowsFilesystemNode(path);
+}
+
WindowsFilesystemNode::WindowsFilesystemNode() {
_isDirectory = true;
#ifndef _WIN32_WCE
@@ -128,6 +132,35 @@ WindowsFilesystemNode::WindowsFilesystemNode() {
#endif
}
+WindowsFilesystemNode::WindowsFilesystemNode(const String &p) {
+ int len = 0, offset = p.size();
+
+ 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
+ DWORD fileAttribs = GetFileAttributes(_path.c_str());
+
+ if (fileAttribs == INVALID_FILE_ATTRIBUTES) {
+ _isValid = false;
+ _isDirectory = false;
+ } else {
+ _isValid = true;
+ _isDirectory = ((fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0);
+ }
+}
+
WindowsFilesystemNode::WindowsFilesystemNode(const WindowsFilesystemNode *node) {
_displayName = node->_displayName;
_isDirectory = node->_isDirectory;