From cb21c25e417bb546f6678ab9da7440c6e1b4b2fd Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 27 Aug 2008 20:31:22 +0000 Subject: FSNode code: Merged most versions of lastPathComponent() into one new AbstractFilesystemNode::lastPathComponent() method, with customizable path separator character svn-id: r34197 --- backends/fs/symbian/symbian-fs.cpp | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'backends/fs/symbian/symbian-fs.cpp') diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index b2a106e0da..af963dda0c 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -78,30 +78,6 @@ public: virtual AbstractFilesystemNode *getParent() const; }; -/** - * Returns the last component of a given path. - * - * Examples: - * c:\foo\bar.txt would return "\bar.txt" - * c:\foo\bar\ would return "\bar\" - * - * @param str Path to obtain the last component from. - * @return Pointer to the first char of the last component inside str. - */ -const char *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; -} - /** * Fixes the path by changing all slashes to backslashes. * @@ -136,7 +112,7 @@ SymbianFilesystemNode::SymbianFilesystemNode(const String &path) { fixFilePath(_path); - _displayName = lastPathComponent(_path); + _displayName = lastPathComponent(_path, '\\'); TEntry fileAttribs; TFileName fname; @@ -257,12 +233,12 @@ AbstractFilesystemNode *SymbianFilesystemNode::getParent() const { if (!_isPseudoRoot && _path.size() > 3) { p = new SymbianFilesystemNode(false); const char *start = _path.c_str(); - const char *end = lastPathComponent(_path); + const char *end = lastPathComponent(_path, '\\'); p->_path = String(start, end - start); p->_isValid = true; p->_isDirectory = true; - p->_displayName = lastPathComponent(p->_path); + p->_displayName = lastPathComponent(p->_path, '\\'); } else { -- cgit v1.2.3