[Scummvm-cvs-logs] CVS: scummvm/backends/fs/windows windows-fs.cpp,1.22,1.23

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Mon Feb 7 06:28:24 CET 2005


Update of /cvsroot/scummvm/scummvm/backends/fs/windows
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26215

Modified Files:
	windows-fs.cpp 
Log Message:
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.


Index: windows-fs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/fs/windows/windows-fs.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- windows-fs.cpp	1 Jan 2005 16:08:46 -0000	1.22
+++ windows-fs.cpp	7 Feb 2005 14:25:04 -0000	1.23
@@ -89,7 +89,7 @@
 	// 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 @@
 	return new WindowsFilesystemNode();
 }
 
+AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) {
+	return new WindowsFilesystemNode(path);
+}
+
 WindowsFilesystemNode::WindowsFilesystemNode() {
 	_isDirectory = true;
 #ifndef _WIN32_WCE
@@ -128,6 +132,35 @@
 #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;





More information about the Scummvm-git-logs mailing list