diff --git a/src/common/FSNodeFactory.hxx b/src/common/FSNodeFactory.hxx index f11568943..f35e0d5e2 100644 --- a/src/common/FSNodeFactory.hxx +++ b/src/common/FSNodeFactory.hxx @@ -23,14 +23,12 @@ class AbstractFSNode; #if defined(ZIP_SUPPORT) #include "FSNodeZIP.hxx" #endif -#if defined(BSPF_UNIX) || defined(BSPF_MACOS) - #include "FSNodePOSIX.hxx" -#elif defined(BSPF_WINDOWS) +#if defined(BSPF_WINDOWS) #include "FSNodeWINDOWS.hxx" #elif defined(__LIB_RETRO__) #include "FSNodeLIBRETRO.hxx" #else - #error Unsupported platform in FSNodeFactory! + #include "FSNodeREGULAR.hxx" #endif /** @@ -41,20 +39,20 @@ class AbstractFSNode; class FSNodeFactory { public: - enum class Type { SYSTEM, ZIP }; + enum class Type { REGULAR, ZIP }; public: static unique_ptr create(const string& path, Type type) { switch(type) { - case Type::SYSTEM: - #if defined(BSPF_UNIX) || defined(BSPF_MACOS) - return make_unique(path); - #elif defined(BSPF_WINDOWS) + case Type::REGULAR: + #if defined(BSPF_WINDOWS) return make_unique(path); #elif defined(__LIB_RETRO__) return make_unique(path); + #else + return make_unique(path); #endif break; case Type::ZIP: diff --git a/src/unix/FSNodePOSIX.cxx b/src/common/FSNodeREGULAR.cxx similarity index 89% rename from src/unix/FSNodePOSIX.cxx rename to src/common/FSNodeREGULAR.cxx index 5b3c8513b..6c1e26d9c 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/common/FSNodeREGULAR.cxx @@ -21,17 +21,17 @@ #define ROOT_DIR "/" #endif -#include "FSNodePOSIX.hxx" +#include "FSNodeREGULAR.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FSNodePOSIX::FSNodePOSIX() +FSNodeREGULAR::FSNodeREGULAR() : _path{ROOT_DIR}, _displayName{_path} { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FSNodePOSIX::FSNodePOSIX(const string& path, bool verify) +FSNodeREGULAR::FSNodeREGULAR(const string& path, bool verify) : _path{path.length() > 0 ? path : "~"} // Default to home directory { // Expand '~' to the HOME environment variable @@ -63,7 +63,7 @@ FSNodePOSIX::FSNodePOSIX(const string& path, bool verify) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FSNodePOSIX::setFlags() +void FSNodeREGULAR::setFlags() { std::error_code ec; const auto s = fs::status(_fspath, ec); @@ -89,7 +89,7 @@ void FSNodePOSIX::setFlags() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string FSNodePOSIX::getShortPath() const +string FSNodeREGULAR::getShortPath() const { // If the path starts with the home directory, replace it with '~' #if defined(BSPF_WINDOWS) @@ -112,13 +112,13 @@ string FSNodePOSIX::getShortPath() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool FSNodePOSIX::hasParent() const +bool FSNodeREGULAR::hasParent() const { return _path != "" && _path != ROOT_DIR; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const +bool FSNodeREGULAR::getChildren(AbstractFSList& myList, ListMode mode) const { std::error_code ec; for (const auto& entry: fs::directory_iterator{_fspath, @@ -142,7 +142,7 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const // Only create the object and add it to the list when absolutely // necessary - FSNodePOSIX node(path.string(), false); + FSNodeREGULAR node(path.string(), false); node._isFile = isFile; node._isDirectory = isDir; node._size = isFile ? entry.file_size() : 0; @@ -155,14 +155,14 @@ bool FSNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode) const fs::perms::group_write | fs::perms::others_write)) != fs::perms::none; - myList.emplace_back(make_shared(node)); + myList.emplace_back(make_shared(node)); } return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -size_t FSNodePOSIX::read(ByteBuffer& buffer, size_t size) const +size_t FSNodeREGULAR::read(ByteBuffer& buffer, size_t size) const { std::ifstream in(_fspath, std::ios::binary); if (in) @@ -182,7 +182,7 @@ size_t FSNodePOSIX::read(ByteBuffer& buffer, size_t size) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -size_t FSNodePOSIX::read(stringstream& buffer) const +size_t FSNodeREGULAR::read(stringstream& buffer) const { std::ifstream in(_fspath); if (in) @@ -199,7 +199,7 @@ size_t FSNodePOSIX::read(stringstream& buffer) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -size_t FSNodePOSIX::write(const ByteBuffer& buffer, size_t size) const +size_t FSNodeREGULAR::write(const ByteBuffer& buffer, size_t size) const { std::ofstream out(_fspath, std::ios::binary); if (out) @@ -213,7 +213,7 @@ size_t FSNodePOSIX::write(const ByteBuffer& buffer, size_t size) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -size_t FSNodePOSIX::write(const stringstream& buffer) const +size_t FSNodeREGULAR::write(const stringstream& buffer) const { std::ofstream out(_fspath); if (out) @@ -227,7 +227,7 @@ size_t FSNodePOSIX::write(const stringstream& buffer) const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool FSNodePOSIX::makeDir() +bool FSNodeREGULAR::makeDir() { if (!(exists() && _isDirectory) && fs::create_directory(_fspath)) { @@ -247,7 +247,7 @@ bool FSNodePOSIX::makeDir() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool FSNodePOSIX::rename(const string& newfile) +bool FSNodeREGULAR::rename(const string& newfile) { fs::path newpath = newfile; @@ -272,7 +272,7 @@ bool FSNodePOSIX::rename(const string& newfile) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -AbstractFSNodePtr FSNodePOSIX::getParent() const +AbstractFSNodePtr FSNodeREGULAR::getParent() const { if (_path == ROOT_DIR) return nullptr; @@ -280,5 +280,5 @@ AbstractFSNodePtr FSNodePOSIX::getParent() const const char* start = _path.c_str(); const char* end = lastPathComponent(_path); - return make_unique(string(start, size_t(end - start))); + return make_unique(string(start, size_t(end - start))); } diff --git a/src/unix/FSNodePOSIX.hxx b/src/common/FSNodeREGULAR.hxx similarity index 89% rename from src/unix/FSNodePOSIX.hxx rename to src/common/FSNodeREGULAR.hxx index 5dc90b7fd..ba352d69c 100644 --- a/src/unix/FSNodePOSIX.hxx +++ b/src/common/FSNodeREGULAR.hxx @@ -15,8 +15,8 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#ifndef FS_NODE_POSIX_HXX -#define FS_NODE_POSIX_HXX +#ifndef FS_NODE_REGULAR_HXX +#define FS_NODE_REGULAR_HXX #include "FSNode.hxx" @@ -27,22 +27,22 @@ * Parts of this class are documented in the base interface classes, * AbstractFSNode and FSNode. See those classes for more information. */ -class FSNodePOSIX : public AbstractFSNode +class FSNodeREGULAR : public AbstractFSNode { public: /** - * Creates a FSNodePOSIX with the root node as path. + * Creates a FSNodeREGULAR with the root node as path. */ - FSNodePOSIX(); + FSNodeREGULAR(); /** - * Creates a FSNodePOSIX for a given path. + * Creates a FSNodeREGULAR for a given path. * * @param path String with the path the new node should point to. * @param verify true if the isValid and isDirectory/isFile flags should * be verified during the construction. */ - explicit FSNodePOSIX(const string& path, bool verify = true); + explicit FSNodeREGULAR(const string& path, bool verify = true); bool exists() const override { return fs::exists(_fspath); } const string& getName() const override { return _displayName; } diff --git a/src/common/FSNodeZIP.cxx b/src/common/FSNodeZIP.cxx index aa0cb75d3..24f432d7f 100644 --- a/src/common/FSNodeZIP.cxx +++ b/src/common/FSNodeZIP.cxx @@ -101,7 +101,7 @@ FSNodeZIP::FSNodeZIP(const string& p) // Behind the scenes, this node is actually a platform-specific object // for whatever system we are running on _realNode = FSNodeFactory::create(_zipFile, - FSNodeFactory::Type::SYSTEM); + FSNodeFactory::Type::REGULAR); setFlags(_zipFile, _virtualPath, _realNode); // cerr << "==============================================================\n"; diff --git a/src/common/module.mk b/src/common/module.mk index dc9f1fd1b..11597735f 100644 --- a/src/common/module.mk +++ b/src/common/module.mk @@ -9,6 +9,7 @@ MODULE_OBJS := \ src/common/FBBackendSDL2.o \ src/common/FBSurfaceSDL2.o \ src/common/FpsMeter.o \ + src/common/FSNodeREGULAR.o \ src/common/FSNodeZIP.o \ src/common/HighScoresManager.o \ src/common/JoyMap.o \ diff --git a/src/emucore/FSNode.cxx b/src/emucore/FSNode.cxx index 99f3e9686..a5c80340a 100644 --- a/src/emucore/FSNode.cxx +++ b/src/emucore/FSNode.cxx @@ -44,7 +44,7 @@ void FSNode::setPath(const string& path) _realNode = FSNodeFactory::create(path, FSNodeFactory::Type::ZIP); else #endif - _realNode = FSNodeFactory::create(path, FSNodeFactory::Type::SYSTEM); + _realNode = FSNodeFactory::create(path, FSNodeFactory::Type::REGULAR); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/unix/module.mk b/src/unix/module.mk index b01b04ffc..5e791a65c 100644 --- a/src/unix/module.mk +++ b/src/unix/module.mk @@ -1,7 +1,6 @@ MODULE := src/unix MODULE_OBJS := \ - src/unix/FSNodePOSIX.o \ src/unix/OSystemUNIX.o \ src/unix/SerialPortUNIX.o