diff options
Diffstat (limited to 'backends/fs/windows')
-rw-r--r-- | backends/fs/windows/windows-fs-factory.cpp | 4 | ||||
-rw-r--r-- | backends/fs/windows/windows-fs-factory.h | 13 | ||||
-rw-r--r-- | backends/fs/windows/windows-fs.cpp | 30 |
3 files changed, 6 insertions, 41 deletions
diff --git a/backends/fs/windows/windows-fs-factory.cpp b/backends/fs/windows/windows-fs-factory.cpp index 7fbf4f7fff..ed273bb746 100644 --- a/backends/fs/windows/windows-fs-factory.cpp +++ b/backends/fs/windows/windows-fs-factory.cpp @@ -26,8 +26,6 @@ #include "backends/fs/windows/windows-fs-factory.h" #include "backends/fs/windows/windows-fs.cpp" -DECLARE_SINGLETON(WindowsFilesystemFactory); - AbstractFilesystemNode *WindowsFilesystemFactory::makeRootFileNode() const { return new WindowsFilesystemNode(); } @@ -36,7 +34,7 @@ AbstractFilesystemNode *WindowsFilesystemFactory::makeCurrentDirectoryFileNode() return new WindowsFilesystemNode("", true); } -AbstractFilesystemNode *WindowsFilesystemFactory::makeFileNodePath(const String &path) const { +AbstractFilesystemNode *WindowsFilesystemFactory::makeFileNodePath(const Common::String &path) const { return new WindowsFilesystemNode(path, false); } #endif diff --git a/backends/fs/windows/windows-fs-factory.h b/backends/fs/windows/windows-fs-factory.h index 0745b286a8..3c7b80942d 100644 --- a/backends/fs/windows/windows-fs-factory.h +++ b/backends/fs/windows/windows-fs-factory.h @@ -25,7 +25,6 @@ #ifndef WINDOWS_FILESYSTEM_FACTORY_H #define WINDOWS_FILESYSTEM_FACTORY_H -#include "common/singleton.h" #include "backends/fs/fs-factory.h" /** @@ -33,19 +32,11 @@ * * Parts of this class are documented in the base interface class, FilesystemFactory. */ -class WindowsFilesystemFactory : public FilesystemFactory, public Common::Singleton<WindowsFilesystemFactory> { +class WindowsFilesystemFactory : public FilesystemFactory { public: - typedef Common::String String; - virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; - -protected: - WindowsFilesystemFactory() {}; - -private: - friend class Common::Singleton<SingletonBaseType>; + virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; }; #endif /*WINDOWS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index 2105317a96..b06581047c 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -135,30 +135,6 @@ private: static const TCHAR* toUnicode(const char *str); }; -/** - * 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; -} - void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) { WindowsFilesystemNode entry; char *asciiName = toAscii(find_data->cFileName); @@ -232,7 +208,7 @@ WindowsFilesystemNode::WindowsFilesystemNode(const String &p, const bool current _path = p; } - _displayName = lastPathComponent(_path); + _displayName = lastPathComponent(_path, '\\'); // Check whether it is a directory, and whether the file actually exists DWORD fileAttribs = GetFileAttributes(toUnicode(_path.c_str())); @@ -322,13 +298,13 @@ AbstractFilesystemNode *WindowsFilesystemNode::getParent() const { WindowsFilesystemNode *p = new WindowsFilesystemNode(); if (_path.size() > 3) { const char *start = _path.c_str(); - const char *end = lastPathComponent(_path); + const char *end = lastPathComponent(_path, '\\'); p = new WindowsFilesystemNode(); p->_path = String(start, end - start); p->_isValid = true; p->_isDirectory = true; - p->_displayName = lastPathComponent(p->_path); + p->_displayName = lastPathComponent(p->_path, '\\'); p->_isPseudoRoot = false; } |