aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/dc
diff options
context:
space:
mode:
authorMax Horn2008-08-27 20:31:22 +0000
committerMax Horn2008-08-27 20:31:22 +0000
commitcb21c25e417bb546f6678ab9da7440c6e1b4b2fd (patch)
tree0ffb1123245e8ee73d4a4c4db8b166e395bac6d0 /backends/platform/dc
parent79fafb7b6ae8b23aaa407b4bca56170d2d46b6ac (diff)
downloadscummvm-rg350-cb21c25e417bb546f6678ab9da7440c6e1b4b2fd.tar.gz
scummvm-rg350-cb21c25e417bb546f6678ab9da7440c6e1b4b2fd.tar.bz2
scummvm-rg350-cb21c25e417bb546f6678ab9da7440c6e1b4b2fd.zip
FSNode code: Merged most versions of lastPathComponent() into one new AbstractFilesystemNode::lastPathComponent() method, with customizable path separator character
svn-id: r34197
Diffstat (limited to 'backends/platform/dc')
-rw-r--r--backends/platform/dc/dc-fs.cpp29
1 files changed, 2 insertions, 27 deletions
diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp
index 596e0d72d5..0da77e317e 100644
--- a/backends/platform/dc/dc-fs.cpp
+++ b/backends/platform/dc/dc-fs.cpp
@@ -37,13 +37,12 @@
class RoninCDFileNode : public AbstractFilesystemNode {
protected:
String _path;
- static const char *lastPathComponent(const Common::String &str);
public:
RoninCDFileNode(const String &path) : _path(path) {};
virtual bool exists() const { return true; }
- virtual String getName() const { return lastPathComponent(_path); }
+ virtual String getName() const { return lastPathComponent(_path, '/'); }
virtual String getPath() const { return _path; }
virtual bool isDirectory() const { return false; }
virtual bool isReadable() const { return true; }
@@ -75,30 +74,6 @@ public:
virtual bool isReadable() const { return false; }
};
-/**
- * Returns the last component of a given path.
- *
- * Examples:
- * /foo/bar.txt would return /bar.txt
- * /foo/bar/ would return /bar/
- *
- * @param str String containing the path.
- * @return Pointer to the first char of the last component inside str.
- */
-const char *RoninCDFileNode::lastPathComponent(const Common::String &str) {
- if(str.empty())
- return "";
-
- const char *start = str.c_str();
- const char *cur = start + str.size() - 2;
-
- while (cur >= start && *cur != '/') {
- --cur;
- }
-
- return cur + 1;
-}
-
AbstractFilesystemNode *RoninCDFileNode::makeFileNodePath(const Common::String &path) {
assert(path.size() > 0);
@@ -163,7 +138,7 @@ AbstractFilesystemNode *RoninCDFileNode::getParent() const {
return 0;
const char *start = _path.c_str();
- const char *end = lastPathComponent(_path);
+ const char *end = lastPathComponent(_path, '/');
return new RoninCDDirectoryNode(String(start, end - start));
}