diff --git a/src/common/FSNodeZIP.hxx b/src/common/FSNodeZIP.hxx index 079d3c546..f71698871 100644 --- a/src/common/FSNodeZIP.hxx +++ b/src/common/FSNodeZIP.hxx @@ -106,21 +106,6 @@ class FilesystemNodeZIP : public AbstractFSNode // ZipHandler static reference variable responsible for accessing ZIP files static unique_ptr myZipHandler; - - // Get last component of path - static const char* lastPathComponent(const string& str) - { - if(str.empty()) - return ""; - - const char* start = str.c_str(); - const char* cur = start + str.size() - 2; - - while (cur >= start && !(*cur == '/' || *cur == '\\')) - --cur; - - return cur + 1; - } }; #endif diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index 05378d185..0737b8bdd 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -471,6 +471,26 @@ class AbstractFSNode * a try-catch block. */ virtual size_t write(const stringstream& buffer) const { return 0; } + + /** + * Returns the last component of a given path. + * + * @param str String containing the path. + * @return Pointer to the first char of the last component inside str. + */ + static const char* lastPathComponent(const string& str) + { + if(str.empty()) + return ""; + + const char* start = str.c_str(); + const char* cur = start + str.size() - 2; + + while (cur >= start && !(*cur == '/' || *cur == '\\')) + --cur; + + return cur + 1; + } }; #endif diff --git a/src/unix/FSNodePOSIX.hxx b/src/unix/FSNodePOSIX.hxx index 5aba86afa..3e09e3bb5 100644 --- a/src/unix/FSNodePOSIX.hxx +++ b/src/unix/FSNodePOSIX.hxx @@ -89,30 +89,6 @@ class FilesystemNodePOSIX : public AbstractFSNode * using the stat() function. */ void setFlags(); - - /** - * 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. - */ - static const char* lastPathComponent(const 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; - } }; #endif diff --git a/src/windows/FSNodeWINDOWS.cxx b/src/windows/FSNodeWINDOWS.cxx index 179476b27..bc4212ddd 100644 --- a/src/windows/FSNodeWINDOWS.cxx +++ b/src/windows/FSNodeWINDOWS.cxx @@ -39,31 +39,6 @@ #include "Windows.hxx" #include "FSNodeWINDOWS.hxx" -/** - * 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 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; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FilesystemNodeWINDOWS::exists() const {