aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/advancedDetector.cpp6
-rw-r--r--common/file.cpp28
-rw-r--r--common/fs.cpp194
-rw-r--r--common/fs.h120
-rw-r--r--common/iff_container.h4
-rw-r--r--common/keyboard.h266
-rw-r--r--common/md5.cpp11
7 files changed, 258 insertions, 371 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index a342ed910a..f3e8671025 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -276,7 +276,7 @@ PluginError detectGameForEngineCreation(
FSList fslist;
FilesystemNode dir(ConfMan.get("path"));
- if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
+ if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
return kInvalidPathError;
}
@@ -345,7 +345,7 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p
// Get the information of the existing files
for (FSList::const_iterator file = fslist->begin(); file != fslist->end(); ++file) {
if (file->isDirectory()) continue;
- tstr = file->name();
+ tstr = file->getName();
tstr.toLowercase();
// Strip any trailing dot
@@ -364,7 +364,7 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p
debug(3, "> %s: %s", tstr.c_str(), md5str);
- if (testFile.open(file->path())) {
+ if (testFile.open(file->getPath())) {
filesSize[tstr] = (int32)testFile.size();
testFile.close();
}
diff --git a/common/file.cpp b/common/file.cpp
index 2eba1bcb3d..238c3a4bb3 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -226,7 +226,7 @@ void File::addDefaultDirectoryRecursive(const FilesystemNode &dir, int level, co
return;
FSList fslist;
- if (!dir.listDir(fslist, FilesystemNode::kListAll)) {
+ if (!dir.getChildren(fslist, FilesystemNode::kListAll)) {
// Failed listing the contents of this node, so it is either not a
// directory, or just doesn't exist at all.
return;
@@ -237,7 +237,7 @@ void File::addDefaultDirectoryRecursive(const FilesystemNode &dir, int level, co
// Do not add directories multiple times, unless this time they are added
// with a bigger depth.
- const String &directory(dir.path());
+ const String &directory(dir.getPath());
if (_defaultDirectories->contains(directory) && (*_defaultDirectories)[directory] >= level)
return;
(*_defaultDirectories)[directory] = level;
@@ -247,13 +247,13 @@ void File::addDefaultDirectoryRecursive(const FilesystemNode &dir, int level, co
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
if (file->isDirectory()) {
- addDefaultDirectoryRecursive(file->path(), level - 1, prefix + file->name() + "/");
+ addDefaultDirectoryRecursive(file->getPath(), level - 1, prefix + file->getName() + "/");
} else {
String lfn(prefix);
- lfn += file->name();
+ lfn += file->getName();
lfn.toLowercase();
if (!_filesMap->contains(lfn)) {
- (*_filesMap)[lfn] = file->path();
+ (*_filesMap)[lfn] = file->getPath();
}
}
}
@@ -364,15 +364,21 @@ bool File::open(const String &filename, AccessMode mode) {
bool File::open(const FilesystemNode &node, AccessMode mode) {
assert(mode == kFileReadMode || mode == kFileWriteMode);
- if (!node.isValid()) {
- warning("File::open: Trying to open an invalid FilesystemNode object");
+ if (!node.exists()) {
+ warning("File::open: Trying to open a FilesystemNode which does not exist");
return false;
} else if (node.isDirectory()) {
warning("File::open: Trying to open a FilesystemNode which is a directory");
return false;
- }
+ } /*else if (!node.isReadable() && mode == kFileReadMode) {
+ warning("File::open: Trying to open an unreadable FilesystemNode object for reading");
+ return false;
+ } else if (!node.isWritable() && mode == kFileWriteMode) {
+ warning("File::open: Trying to open an unwritable FilesystemNode object for writing");
+ return false;
+ }*/
- String filename(node.name());
+ String filename(node.getName());
if (_handle) {
error("File::open: This file object already is opened (%s), won't open '%s'", _name.c_str(), filename.c_str());
@@ -383,7 +389,7 @@ bool File::open(const FilesystemNode &node, AccessMode mode) {
const char *modeStr = (mode == kFileReadMode) ? "rb" : "wb";
- _handle = fopen(node.path().c_str(), modeStr);
+ _handle = fopen(node.getPath().c_str(), modeStr);
if (_handle == NULL) {
if (mode == kFileReadMode)
@@ -409,7 +415,7 @@ bool File::exists(const String &filename) {
// FIXME: can't use isValid() here since at the time of writing
// FilesystemNode is to be unable to find for example files
// added in extrapath
- if (file.isDirectory())
+ if (file.isDirectory() || !file.exists())
return false;
// Next, try to locate the file by *opening* it in read mode. This has
diff --git a/common/fs.cpp b/common/fs.cpp
index c33fc42223..28f3e11f0b 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -23,14 +23,45 @@
*/
#include "common/stdafx.h"
-
-#include "backends/fs/abstract-fs.h"
#include "common/util.h"
+#include "backends/fs/abstract-fs.h"
+#include "backends/fs/fs-factory-maker.cpp"
-
-FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
- _realNode = realNode;
- _refCount = new int(1);
+/*
+ * Simple DOS-style pattern matching function (understands * and ? like used in DOS).
+ * Taken from exult/files/listfiles.cc
+ */
+static bool matchString(const char *str, const char *pat) {
+ const char *p = 0;
+ const char *q = 0;
+
+ for (;;) {
+ switch (*pat) {
+ case '*':
+ p = ++pat;
+ q = str;
+ break;
+
+ default:
+ if (*pat != *str) {
+ if (p) {
+ pat = p;
+ str = ++q;
+ if(!*str)
+ return !*pat;
+ break;
+ }
+ else
+ return false;
+ }
+ // fallthrough
+ case '?':
+ if(!*str)
+ return !*pat;
+ pat++;
+ str++;
+ }
+ }
}
FilesystemNode::FilesystemNode() {
@@ -38,6 +69,11 @@ FilesystemNode::FilesystemNode() {
_refCount = 0;
}
+FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
+ _realNode = realNode;
+ _refCount = new int(1);
+}
+
FilesystemNode::FilesystemNode(const FilesystemNode &node) {
_realNode = node._realNode;
_refCount = node._refCount;
@@ -46,10 +82,12 @@ FilesystemNode::FilesystemNode(const FilesystemNode &node) {
}
FilesystemNode::FilesystemNode(const Common::String &p) {
+ AbstractFilesystemFactory *factory = FilesystemFactoryMaker::makeFactory();
+
if (p.empty() || p == ".")
- _realNode = AbstractFilesystemNode::getCurrentDirectory();
+ _realNode = factory->makeCurrentDirectoryFileNode();
else
- _realNode = AbstractFilesystemNode::getNodeForPath(p);
+ _realNode = factory->makeFileNodePath(p);
_refCount = new int(1);
}
@@ -57,18 +95,7 @@ FilesystemNode::~FilesystemNode() {
decRefCount();
}
-void FilesystemNode::decRefCount() {
- if (_refCount) {
- assert(*_refCount > 0);
- --(*_refCount);
- if (*_refCount == 0) {
- delete _refCount;
- delete _realNode;
- }
- }
-}
-
-FilesystemNode &FilesystemNode::operator =(const FilesystemNode &node) {
+FilesystemNode &FilesystemNode::operator= (const FilesystemNode &node) {
if (node._refCount)
++(*node._refCount);
@@ -80,40 +107,48 @@ FilesystemNode &FilesystemNode::operator =(const FilesystemNode &node) {
return *this;
}
-bool FilesystemNode::isValid() const {
- if (_realNode == 0)
+bool FilesystemNode::operator< (const FilesystemNode& node) const
+{
+ if (isDirectory() && !node.isDirectory())
+ return true;
+ if (!isDirectory() && node.isDirectory())
return false;
- return _realNode->isValid();
+ return scumm_stricmp(getDisplayName().c_str(), node.getDisplayName().c_str()) < 0;
}
-FilesystemNode FilesystemNode::getParent() const {
- if (_realNode == 0)
- return *this;
-
- AbstractFilesystemNode *node = _realNode->parent();
- if (node == 0) {
- return *this;
- } else {
- return FilesystemNode(node);
+void FilesystemNode::decRefCount() {
+ if (_refCount) {
+ assert(*_refCount > 0);
+ --(*_refCount);
+ if (*_refCount == 0) {
+ delete _refCount;
+ delete _realNode;
+ }
}
}
+bool FilesystemNode::exists() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->exists();
+}
+
FilesystemNode FilesystemNode::getChild(const Common::String &n) const {
if (_realNode == 0)
return *this;
assert(_realNode->isDirectory());
- AbstractFilesystemNode *node = _realNode->child(n);
+ AbstractFilesystemNode *node = _realNode->getChild(n);
return FilesystemNode(node);
}
-bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
+bool FilesystemNode::getChildren(FSList &fslist, ListMode mode, bool hidden) const {
if (!_realNode || !_realNode->isDirectory())
return false;
AbstractFSList tmp;
- if (!_realNode->listDir(tmp, mode))
+ if (!_realNode->getChildren(tmp, mode, hidden))
return false;
fslist.clear();
@@ -124,33 +159,92 @@ bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
return true;
}
+Common::String FilesystemNode::getDisplayName() const {
+ assert(_realNode);
+ return _realNode->getDisplayName();
+}
+
+Common::String FilesystemNode::getName() const {
+ assert(_realNode);
+ return _realNode->getName();
+}
+
+FilesystemNode FilesystemNode::getParent() const {
+ if (_realNode == 0)
+ return *this;
+
+ AbstractFilesystemNode *node = _realNode->getParent();
+ if (node == 0) {
+ return *this;
+ } else {
+ return FilesystemNode(node);
+ }
+}
+
+Common::String FilesystemNode::getPath() const {
+ assert(_realNode);
+ return _realNode->getPath();
+}
+
bool FilesystemNode::isDirectory() const {
if (_realNode == 0)
return false;
return _realNode->isDirectory();
}
-Common::String FilesystemNode::displayName() const {
- assert(_realNode);
- return _realNode->displayName();
+bool FilesystemNode::isReadable() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->isReadable();
}
-Common::String FilesystemNode::name() const {
- assert(_realNode);
- return _realNode->name();
+bool FilesystemNode::isWritable() const {
+ if (_realNode == 0)
+ return false;
+ return _realNode->isWritable();
}
-Common::String FilesystemNode::path() const {
- assert(_realNode);
- return _realNode->path();
+bool FilesystemNode::lookupFile(FSList &results, FSList &fslist, Common::String &filename, bool hidden, bool exhaustive) const
+{
+ for(FSList::iterator entry = fslist.begin(); entry != fslist.end(); ++entry)
+ {
+ if(entry->isDirectory()) {
+ lookupFileRec(results, *entry, filename, hidden, exhaustive);
+ }
+ }
+
+ //TODO: we would return true even if no matches were found, if the initial results list isn't empty
+ return ((results.size() > 0) ? true : false);
}
+bool FilesystemNode::lookupFile(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
+{
+ lookupFileRec(results, dir, filename, hidden, exhaustive);
+
+ //TODO: we would return true even if no matches were found, if the initial results list isn't empty
+ return ((results.size() > 0) ? true : false);
+}
-bool FilesystemNode::operator< (const FilesystemNode& node) const
+void FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
{
- if (isDirectory() && !node.isDirectory())
- return true;
- if (!isDirectory() && node.isDirectory())
- return false;
- return scumm_stricmp(displayName().c_str(), node.displayName().c_str()) < 0;
+ FSList entries;
+ dir.getChildren(entries, FilesystemNode::kListAll, hidden);
+
+ for(FSList::iterator entry = entries.begin(); entry != entries.end(); ++entry)
+ {
+ if(entry->isDirectory()) {
+ lookupFileRec(results, *entry, filename, hidden, exhaustive);
+ } else {
+ //TODO: here we assume all backends implement the lastPathComponent method. It is currently static,
+ // so it might be a good idea to include it inside the backend class. This would enforce its
+ // implementation by all ports.
+ if(matchString(lastPathComponent(entry->getPath()), filename.c_str())) {
+ results.push_back(*entry);
+
+ if(!exhaustive) {
+ break;
+ }
+ }
+ }
+ }
}
diff --git a/common/fs.h b/common/fs.h
index 4c275b5b2a..6a2f049be1 100644
--- a/common/fs.h
+++ b/common/fs.h
@@ -33,7 +33,6 @@
class FilesystemNode;
class AbstractFilesystemNode;
-
/**
* List of multiple file system nodes. E.g. the contents of a given directory.
* This is subclass instead of just a typedef so that we can use forward
@@ -41,9 +40,8 @@ class AbstractFilesystemNode;
*/
class FSList : public Common::Array<FilesystemNode> {};
-
/**
- * FilesystemNode provides an abstraction for file pathes, allowing for portable
+ * FilesystemNode provides an abstraction for file paths, allowing for portable
* file system browsing. To this ends, multiple or single roots have to be supported
* (compare Unix with a single root, Windows with multiple roots C:, D:, ...).
*
@@ -67,9 +65,8 @@ class FSList : public Common::Array<FilesystemNode> {};
*/
class FilesystemNode {
private:
- AbstractFilesystemNode *_realNode;
int *_refCount;
-
+ AbstractFilesystemNode *_realNode;
FilesystemNode(AbstractFilesystemNode *realNode);
public:
@@ -113,51 +110,42 @@ public:
/**
* Copy operator.
*/
- FilesystemNode &operator =(const FilesystemNode &node);
-
+ FilesystemNode &operator= (const FilesystemNode &node);
+
/**
- * Checks if the FilesystemNode is valid for any usage
+ * Compare the name of this node to the name of another. Directories
+ * go before normal files.
*/
- bool isValid() const;
+ bool operator< (const FilesystemNode& node) const;
- /**
- * Get the parent node of this node. If this node has no parent node,
- * then it returns a duplicate of this node.
+ /*
+ * Indicates whether the object refered by this path exists in the filesystem or not.
*/
- FilesystemNode getParent() const;
+ virtual bool exists() const;
/**
* Fetch a child node of this node, with the given name. Only valid for
- * directory nodes (an assertion is triggered otherwise). If no no child
- * node with the given name exists, an invalid node is returned.
+ * directory nodes (an assertion is triggered otherwise).
+ * If no child node with the given name exists, an invalid node is returned.
*/
FilesystemNode getChild(const Common::String &name) const;
-
+
/**
* Return a list of child nodes of this directory node. If called on a node
* that does not represent a directory, false is returned.
+ *
* @return true if succesful, false otherwise (e.g. when the directory does not exist).
- * @todo Rename this to listChildren or getChildren.
- */
- virtual bool listDir(FSList &fslist, ListMode mode = kListDirectoriesOnly) const;
-
- /**
- * Is this node pointing to a directory?
- * @todo Currently we assume that a valid node that is not a directory
- * automatically is a file (ignoring things like symlinks). That might
- * actually be OK... but we could still add an isFile method. Or even replace
- * isValid and isDirectory by a getType() method that can return values like
- * kDirNodeType, kFileNodeType, kInvalidNodeType.
*/
- virtual bool isDirectory() const;
+ virtual bool getChildren(FSList &fslist, ListMode mode = kListDirectoriesOnly, bool hidden = false) const;
/**
* Return a human readable string for this node, usable for display (e.g.
* in the GUI code). Do *not* rely on it being usable for anything else,
* like constructing paths!
+ *
* @return the display name
*/
- virtual Common::String displayName() const;
+ virtual Common::String getDisplayName() const;
/**
* Return a string representation of the name of the file. This is can be
@@ -167,7 +155,7 @@ public:
*
* @return the file name
*/
- virtual Common::String name() const;
+ virtual Common::String getName() const;
/**
* Return a string representation of the file which can be passed to fopen(),
@@ -180,18 +168,80 @@ public:
*
* @return the 'path' represented by this filesystem node
*/
- virtual Common::String path() const;
+ virtual Common::String getPath() const;
+
+ /**
+ * Get the parent node of this node. If this node has no parent node,
+ * then it returns a duplicate of this node.
+ */
+ FilesystemNode getParent() const;
/**
- * Compare the name of this node to the name of another. Directories
- * go before normal files.
+ * Indicates whether this path refers to a directory or not.
+ *
+ * @todo Currently we assume that a valid node that is not a directory
+ * automatically is a file (ignoring things like symlinks). That might
+ * actually be OK... but we could still add an isFile method. Or even replace
+ * isValid and isDirectory by a getType() method that can return values like
+ * kDirNodeType, kFileNodeType, kInvalidNodeType.
*/
- bool operator< (const FilesystemNode& node) const;
+ virtual bool isDirectory() const;
+
+ /**
+ * Indicates whether this path can be read from or not.
+ */
+ virtual bool isReadable() const;
+
+ /**
+ * Indicates whether this path can be written to or not.
+ */
+ virtual bool isWritable() const;
+
+ /**
+ * Searches recursively for a filename inside the given directories.
+ *
+ * @param results List to put the matches in.
+ * @param fslist List of directories to search within.
+ * @param filename Name of the file to look for.
+ * @param hidden Whether to search hidden files or not. Default: false
+ * @param exhaustive Whether to continue searching after one match has been found. Default: false
+ *
+ * @return true if matches could be found, false otherwise.
+ */
+ virtual bool lookupFile(FSList &results, FSList &fslist, Common::String &filename, bool hidden, bool exhaustive) const;
+
+ /**
+ * Searches recursively for a filename inside the given directory.
+ *
+ * @param results List to put the matches in.
+ * @param FilesystemNode Directory to search within.
+ * @param filename Name of the file to look for.
+ * @param hidden Whether to search hidden files or not. Default: false
+ * @param exhaustive Whether to continue searching after one match has been found. Default: false
+ *
+ * @return true if matches could be found, false otherwise.
+ */
+ virtual bool lookupFile(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const;
protected:
+ /**
+ * Decreases the reference count to the FilesystemNode, and if necessary,
+ * deletes the corresponding underlying references.
+ */
void decRefCount();
+
+ /**
+ * Searches recursively for a filename inside the given directory.
+ *
+ * @param results List to put the matches in.
+ * @param FilesystemNode Directory to search within.
+ * @param filename Name of the file to look for.
+ * @param hidden Whether to search hidden files or not.
+ * @param exhaustive Whether to continue searching after one match has been found.
+ */
+ void lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const;
};
//} // End of namespace Common
-#endif
+#endif //COMMON_FS_H
diff --git a/common/iff_container.h b/common/iff_container.h
index cc55970591..0d07b5bd57 100644
--- a/common/iff_container.h
+++ b/common/iff_container.h
@@ -18,8 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL$
- * $Id$
+ * $URL:https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/gsoc2007-fsnode/common/iff_container.h $
+ * $Id:iff_container.h 26949 2007-05-26 20:23:24Z david_corrales $
*/
#ifndef COMMON_IFF_CONTAINER_H
diff --git a/common/keyboard.h b/common/keyboard.h
deleted file mode 100644
index d0d0e43f00..0000000000
--- a/common/keyboard.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef COMMON_KEYBOARD_H
-#define COMMON_KEYBOARD_H
-
-#include "common/scummsys.h"
-
-namespace Common {
-
-enum KeyCode {
- KEYCODE_INVALID = 0,
-
- KEYCODE_BACKSPACE = 8,
- KEYCODE_TAB = 9,
- KEYCODE_CLEAR = 12,
- KEYCODE_RETURN = 13,
- KEYCODE_PAUSE = 19,
- KEYCODE_ESCAPE = 27,
- KEYCODE_SPACE = 32,
- KEYCODE_EXCLAIM = 33,
- KEYCODE_QUOTEDBL = 34,
- KEYCODE_HASH = 35,
- KEYCODE_DOLLAR = 36,
- KEYCODE_AMPERSAND = 38,
- KEYCODE_QUOTE = 39,
- KEYCODE_LEFTPAREN = 40,
- KEYCODE_RIGHTPAREN = 41,
- KEYCODE_ASTERISK = 42,
- KEYCODE_PLUS = 43,
- KEYCODE_COMMA = 44,
- KEYCODE_MINUS = 45,
- KEYCODE_PERIOD = 46,
- KEYCODE_SLASH = 47,
- KEYCODE_0 = 48,
- KEYCODE_1 = 49,
- KEYCODE_2 = 50,
- KEYCODE_3 = 51,
- KEYCODE_4 = 52,
- KEYCODE_5 = 53,
- KEYCODE_6 = 54,
- KEYCODE_7 = 55,
- KEYCODE_8 = 56,
- KEYCODE_9 = 57,
- KEYCODE_COLON = 58,
- KEYCODE_SEMICOLON = 59,
- KEYCODE_LESS = 60,
- KEYCODE_EQUALS = 61,
- KEYCODE_GREATER = 62,
- KEYCODE_QUESTION = 63,
- KEYCODE_AT = 64,
-
- KEYCODE_LEFTBRACKET = 91,
- KEYCODE_BACKSLASH = 92,
- KEYCODE_RIGHTBRACKET= 93,
- KEYCODE_CARET = 94,
- KEYCODE_UNDERSCORE = 95,
- KEYCODE_BACKQUOTE = 96,
- KEYCODE_a = 97,
- KEYCODE_b = 98,
- KEYCODE_c = 99,
- KEYCODE_d = 100,
- KEYCODE_e = 101,
- KEYCODE_f = 102,
- KEYCODE_g = 103,
- KEYCODE_h = 104,
- KEYCODE_i = 105,
- KEYCODE_j = 106,
- KEYCODE_k = 107,
- KEYCODE_l = 108,
- KEYCODE_m = 109,
- KEYCODE_n = 110,
- KEYCODE_o = 111,
- KEYCODE_p = 112,
- KEYCODE_q = 113,
- KEYCODE_r = 114,
- KEYCODE_s = 115,
- KEYCODE_t = 116,
- KEYCODE_u = 117,
- KEYCODE_v = 118,
- KEYCODE_w = 119,
- KEYCODE_x = 120,
- KEYCODE_y = 121,
- KEYCODE_z = 122,
- KEYCODE_DELETE = 127,
-
- // Numeric keypad
- KEYCODE_KP0 = 256,
- KEYCODE_KP1 = 257,
- KEYCODE_KP2 = 258,
- KEYCODE_KP3 = 259,
- KEYCODE_KP4 = 260,
- KEYCODE_KP5 = 261,
- KEYCODE_KP6 = 262,
- KEYCODE_KP7 = 263,
- KEYCODE_KP8 = 264,
- KEYCODE_KP9 = 265,
- KEYCODE_KP_PERIOD = 266,
- KEYCODE_KP_DIVIDE = 267,
- KEYCODE_KP_MULTIPLY = 268,
- KEYCODE_KP_MINUS = 269,
- KEYCODE_KP_PLUS = 270,
- KEYCODE_KP_ENTER = 271,
- KEYCODE_KP_EQUALS = 272,
-
- // Arrows + Home/End pad
- KEYCODE_UP = 273,
- KEYCODE_DOWN = 274,
- KEYCODE_RIGHT = 275,
- KEYCODE_LEFT = 276,
- KEYCODE_INSERT = 277,
- KEYCODE_HOME = 278,
- KEYCODE_END = 279,
- KEYCODE_PAGEUP = 280,
- KEYCODE_PAGEDOWN = 281,
-
- // Function keys
- KEYCODE_F1 = 282,
- KEYCODE_F2 = 283,
- KEYCODE_F3 = 284,
- KEYCODE_F4 = 285,
- KEYCODE_F5 = 286,
- KEYCODE_F6 = 287,
- KEYCODE_F7 = 288,
- KEYCODE_F8 = 289,
- KEYCODE_F9 = 290,
- KEYCODE_F10 = 291,
- KEYCODE_F11 = 292,
- KEYCODE_F12 = 293,
- KEYCODE_F13 = 294,
- KEYCODE_F14 = 295,
- KEYCODE_F15 = 296,
-
- // Key state modifier keys
- KEYCODE_NUMLOCK = 300,
- KEYCODE_CAPSLOCK = 301,
- KEYCODE_SCROLLOCK = 302,
- KEYCODE_RSHIFT = 303,
- KEYCODE_LSHIFT = 304,
- KEYCODE_RCTRL = 305,
- KEYCODE_LCTRL = 306,
- KEYCODE_RALT = 307,
- KEYCODE_LALT = 308,
- KEYCODE_RMETA = 309,
- KEYCODE_LMETA = 310,
- KEYCODE_LSUPER = 311, // Left "Windows" key
- KEYCODE_RSUPER = 312, // Right "Windows" key
- KEYCODE_MODE = 313, // "Alt Gr" key
- KEYCODE_COMPOSE = 314, // Multi-key compose key
-
- // Miscellaneous function keys
- KEYCODE_HELP = 315,
- KEYCODE_PRINT = 316,
- KEYCODE_SYSREQ = 317,
- KEYCODE_BREAK = 318,
- KEYCODE_MENU = 319,
- KEYCODE_POWER = 320, // Power Macintosh power key
- KEYCODE_EURO = 321, // Some european keyboards
- KEYCODE_UNDO = 322 // Atari keyboard has Undo
-};
-
-/**
- * List of certan special and some fake 'ascii' values used in keyboard events.
- * The values for the function keys listed here are based on what certain SCUMM
- * games expect in their scripts.
- * @todo Get rid of the function key values, and instead enforce that engines use
- * the keycode value to handle these.
- */
-enum {
- ASCII_BACKSPACE = 8,
- ASCII_TAB = 9,
- ASCII_RETURN = 13,
- ASCII_ESCAPE = 27,
- ASCII_SPACE = 32,
-
- ASCII_F1 = 315,
- ASCII_F2 = 316,
- ASCII_F3 = 317,
- ASCII_F4 = 318,
- ASCII_F5 = 319,
- ASCII_F6 = 320,
- ASCII_F7 = 321,
- ASCII_F8 = 322,
- ASCII_F9 = 323,
- ASCII_F10 = 324,
- ASCII_F11 = 325,
- ASCII_F12 = 326
-};
-
-/**
- * Keyboard modifier flags, used for Event::kbd::flags.
- */
-enum {
- KBD_CTRL = 1 << 0,
- KBD_ALT = 1 << 1,
- KBD_SHIFT = 1 << 2
-};
-
-/**
- * Keyboard status, as used in the Event struct.
- */
-struct KeyState {
- /**
- * Abstract key code (will be the same for any given key regardless
- * of modifiers being held at the same time.
- * For example, this is the same for both 'A' and Shift-'A'.
- * @todo Document which values are to be used for non-ASCII keys
- * like F1-F10. For now, let's just say that our primary backend
- * is the SDL one, and it uses the values SDL uses... so until
- * we fix this, your best bet is to get a copy of SDL_keysym.h
- * and look at that, if you want to find out a key code.
- */
- KeyCode keycode;
-
- /**
- * ASCII-value of the pressed key (if any).
- * This depends on modifiers, i.e. pressing the 'A' key results in
- * different values here depending on the status of shift, alt and
- * caps lock.
- */
- uint16 ascii;
-
- /**
- * Status of the modifier keys. Bits are set in this for each
- * pressed modifier
- * @see KBD_CTRL, KBD_ALT, KBD_SHIFT
- */
- byte flags;
-
- KeyState(KeyCode kc = KEYCODE_INVALID, uint16 asc = 0, byte f = 0) {
- keycode = kc;
- ascii = asc ? asc : (uint16)kc;
- flags = f;
- }
-
- void reset() {
- keycode = KEYCODE_INVALID;
- ascii = flags = 0;
- }
-};
-
-} // End of namespace Common
-
-#endif
diff --git a/common/md5.cpp b/common/md5.cpp
index a48ecb4948..32acdc5b8c 100644
--- a/common/md5.cpp
+++ b/common/md5.cpp
@@ -246,15 +246,18 @@ void md5_finish(md5_context *ctx, uint8 digest[16]) {
}
bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length) {
- if (!file.isValid()) {
- warning("md5_file: using an invalid FilesystemNode");
+ if(!file.exists()) {
+ warning("md5_file: using an inexistent FilesystemNode");
+ return false;
+ } else if (!file.isReadable()) {
+ warning("md5_file: using an unreadable FilesystemNode");
return false;
} else if (file.isDirectory()) {
- warning("md5_file: using a diretory FilesystemNode");
+ warning("md5_file: using a directory FilesystemNode");
return false;
}
- return md5_file(file.path().c_str(), digest, length);
+ return md5_file(file.getPath().c_str(), digest, length);
}
bool md5_file(const char *name, uint8 digest[16], uint32 length) {