mirror of https://github.com/stella-emu/stella.git
Remove 'HomeFinder' from various parts of code, restrict to Win-specific
class.
This commit is contained in:
parent
3419b3f7fb
commit
a4b4cc62b6
|
@ -23,8 +23,6 @@
|
||||||
#endif
|
#endif
|
||||||
#elif defined(BSPF_WINDOWS)
|
#elif defined(BSPF_WINDOWS)
|
||||||
#define ROOT_DIR "C:\\"
|
#define ROOT_DIR "C:\\"
|
||||||
#include "HomeFinder.hxx"
|
|
||||||
static HomeFinder ourHomeFinder;
|
|
||||||
#else
|
#else
|
||||||
#define ROOT_DIR ""
|
#define ROOT_DIR ""
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,11 +43,7 @@ FSNodeREGULAR::FSNodeREGULAR(const string& path, bool verify)
|
||||||
// Expand '~' to the HOME environment variable
|
// Expand '~' to the HOME environment variable
|
||||||
if (_path[0] == '~')
|
if (_path[0] == '~')
|
||||||
{
|
{
|
||||||
#if defined(BSPF_WINDOWS)
|
|
||||||
const char* home = ourHomeFinder.getHomePath().c_str();
|
|
||||||
#else
|
|
||||||
const char* home = std::getenv("HOME");
|
const char* home = std::getenv("HOME");
|
||||||
#endif
|
|
||||||
if (home != nullptr)
|
if (home != nullptr)
|
||||||
_path.replace(0, 1, home);
|
_path.replace(0, 1, home);
|
||||||
}
|
}
|
||||||
|
@ -100,11 +94,7 @@ void FSNodeREGULAR::setFlags()
|
||||||
string FSNodeREGULAR::getShortPath() const
|
string FSNodeREGULAR::getShortPath() const
|
||||||
{
|
{
|
||||||
// If the path starts with the home directory, replace it with '~'
|
// If the path starts with the home directory, replace it with '~'
|
||||||
#if defined(BSPF_WINDOWS)
|
|
||||||
const char* env_home = ourHomeFinder.getHomePath().c_str();
|
|
||||||
#else
|
|
||||||
const char* env_home = std::getenv("HOME");
|
const char* env_home = std::getenv("HOME");
|
||||||
#endif
|
|
||||||
const string& home = env_home != nullptr ? env_home : EmptyString;
|
const string& home = env_home != nullptr ? env_home : EmptyString;
|
||||||
|
|
||||||
if (home != EmptyString && BSPF::startsWithIgnoreCase(_path, home))
|
if (home != EmptyString && BSPF::startsWithIgnoreCase(_path, home))
|
||||||
|
|
|
@ -25,11 +25,6 @@
|
||||||
#include "FSNodeFactory.hxx"
|
#include "FSNodeFactory.hxx"
|
||||||
#include "FSNodeZIP.hxx"
|
#include "FSNodeZIP.hxx"
|
||||||
|
|
||||||
#if defined(BSPF_WINDOWS)
|
|
||||||
#include "HomeFinder.hxx"
|
|
||||||
static HomeFinder ourHomeFinder;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
FSNodeZIP::FSNodeZIP(const string& p)
|
FSNodeZIP::FSNodeZIP(const string& p)
|
||||||
{
|
{
|
||||||
|
@ -43,13 +38,9 @@ FSNodeZIP::FSNodeZIP(const string& p)
|
||||||
// Expand '~' to the users 'home' directory
|
// Expand '~' to the users 'home' directory
|
||||||
if (_zipFile[0] == '~')
|
if (_zipFile[0] == '~')
|
||||||
{
|
{
|
||||||
#if defined(BSPF_UNIX) || defined(BSPF_MACOS)
|
|
||||||
const char* home = std::getenv("HOME");
|
const char* home = std::getenv("HOME");
|
||||||
if (home != nullptr)
|
if (home != nullptr)
|
||||||
_zipFile.replace(0, 1, home);
|
_zipFile.replace(0, 1, home);
|
||||||
#elif defined(BSPF_WINDOWS)
|
|
||||||
_zipFile.replace(0, 1, ourHomeFinder.getHomePath());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cerr << " => p: " << p << endl;
|
// cerr << " => p: " << p << endl;
|
||||||
|
|
|
@ -284,17 +284,8 @@ void FileListWidget::reload()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const FSNode& FileListWidget::selected()
|
const FSNode& FileListWidget::selected()
|
||||||
{
|
{
|
||||||
if(_fileList.size() > 0)
|
_selected = BSPF::clamp(_selected, 0U, static_cast<uInt32>(_fileList.size()-1));
|
||||||
{
|
return _fileList[_selected];
|
||||||
_selected = BSPF::clamp(_selected, 0U, static_cast<uInt32>(_fileList.size()-1));
|
|
||||||
return _fileList[_selected];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// This should never happen, but we'll error-check out-of-bounds
|
|
||||||
// array access anyway
|
|
||||||
return ourDefaultNode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -727,6 +718,3 @@ string FileListWidget::getToolTip(const Common::Point& pos) const
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt64 FileListWidget::_QUICK_SELECT_DELAY = 300;
|
uInt64 FileListWidget::_QUICK_SELECT_DELAY = 300;
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
FSNode FileListWidget::ourDefaultNode = FSNode("~");
|
|
||||||
|
|
|
@ -187,8 +187,6 @@ class FileListWidget : public StringListWidget
|
||||||
|
|
||||||
unique_ptr<ProgressDialog> myProgressDialog;
|
unique_ptr<ProgressDialog> myProgressDialog;
|
||||||
|
|
||||||
static FSNode ourDefaultNode;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
FileListWidget() = delete;
|
FileListWidget() = delete;
|
||||||
|
|
|
@ -21,6 +21,15 @@
|
||||||
|
|
||||||
#include "OSystemWINDOWS.hxx"
|
#include "OSystemWINDOWS.hxx"
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
OSystemWINDOWS::OSystemWINDOWS()
|
||||||
|
{
|
||||||
|
// Make sure 'HOME' environment variable exists; other parts of the
|
||||||
|
// codebase depend on it
|
||||||
|
HomeFinder homefinder;
|
||||||
|
_putenv_s("HOME", homefinder.getHomePath().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void OSystemWINDOWS::getBaseDirectories(string& basedir, string& homedir,
|
void OSystemWINDOWS::getBaseDirectories(string& basedir, string& homedir,
|
||||||
bool useappdir, const string& usedir)
|
bool useappdir, const string& usedir)
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
class OSystemWINDOWS : public OSystemStandalone
|
class OSystemWINDOWS : public OSystemStandalone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OSystemWINDOWS() = default;
|
OSystemWINDOWS();
|
||||||
~OSystemWINDOWS() override = default;
|
~OSystemWINDOWS() override = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue