mirror of https://github.com/stella-emu/stella.git
Reverted FSNode getPath() modifications introduced in Stella 3.4.1, since it causes massive performance regressions in Windows XP.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2292 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
56694b5934
commit
52cf172661
|
@ -626,7 +626,7 @@ string CartDebug::loadSymbolFile(string file)
|
|||
{
|
||||
ifstream in(node.getPath().c_str());
|
||||
if(!in.is_open())
|
||||
return DebuggerParser::red("symbol file '" + node.getPath(false) + "' not found");
|
||||
return DebuggerParser::red("symbol file '" + node.getRelativePath() + "' not found");
|
||||
|
||||
myUserAddresses.clear();
|
||||
myUserLabels.clear();
|
||||
|
@ -645,9 +645,9 @@ string CartDebug::loadSymbolFile(string file)
|
|||
addLabel(label, value);
|
||||
}
|
||||
in.close();
|
||||
return "loaded " + node.getPath(false) + " OK";
|
||||
return "loaded " + node.getRelativePath() + " OK";
|
||||
}
|
||||
return DebuggerParser::red("symbol file '" + node.getPath(false) + "' not found");
|
||||
return DebuggerParser::red("symbol file '" + node.getRelativePath() + "' not found");
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -783,7 +783,7 @@ string CartDebug::loadConfigFile(string file)
|
|||
}
|
||||
in.close();
|
||||
|
||||
return "loaded " + node.getPath(false) + " OK";
|
||||
return "loaded " + node.getRelativePath() + " OK";
|
||||
}
|
||||
else
|
||||
return DebuggerParser::red("config file not found");
|
||||
|
@ -827,7 +827,7 @@ string CartDebug::saveConfigFile(string file)
|
|||
}
|
||||
out.close();
|
||||
|
||||
return "saved " + node.getPath(false) + " OK";
|
||||
return "saved " + node.getRelativePath() + " OK";
|
||||
}
|
||||
else
|
||||
return DebuggerParser::red("config file not found");
|
||||
|
|
|
@ -842,9 +842,9 @@ string Debugger::saveROM(const string& filename) const
|
|||
string path = AbstractFilesystemNode::getAbsolutePath(filename, "~", "a26");
|
||||
FilesystemNode node(path);
|
||||
|
||||
ofstream out(node.getPath(true).c_str(), ios::out | ios::binary);
|
||||
ofstream out(node.getPath().c_str(), ios::out | ios::binary);
|
||||
if(out.is_open() && myConsole->cartridge().save(out))
|
||||
return node.getPath(false);
|
||||
return node.getRelativePath();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ string DebuggerParser::exec(const FilesystemNode& file)
|
|||
{
|
||||
ifstream in(file.getPath().c_str());
|
||||
if(!in.is_open())
|
||||
return red("autoexec file \'" + file.getPath(false) + "\' not found");
|
||||
return red("autoexec file \'" + file.getRelativePath() + "\' not found");
|
||||
|
||||
ostringstream buf;
|
||||
int count = 0;
|
||||
|
@ -149,12 +149,12 @@ string DebuggerParser::exec(const FilesystemNode& file)
|
|||
count++;
|
||||
}
|
||||
buf << "Executed " << debugger->valueToString(count) << " commands from \""
|
||||
<< file.getPath(false) << "\"";
|
||||
<< file.getRelativePath() << "\"";
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
else
|
||||
return red("autoexec file \'" + file.getPath(false) + "\' not found");
|
||||
return red("autoexec file \'" + file.getRelativePath() + "\' not found");
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -122,10 +122,17 @@ FilesystemNode FilesystemNode::getParent() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string FilesystemNode::getPath(bool fqn) const
|
||||
string FilesystemNode::getPath() const
|
||||
{
|
||||
assert(_realNode);
|
||||
return _realNode->getPath(fqn);
|
||||
return _realNode->getPath();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string FilesystemNode::getRelativePath() const
|
||||
{
|
||||
assert(_realNode);
|
||||
return _realNode->getRelativePath();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -166,11 +166,7 @@ class FilesystemNode
|
|||
virtual string getName() const;
|
||||
|
||||
/**
|
||||
* Return a string representation of the file with the following properties:
|
||||
* 1) can be passed to fopen() if fqn is true
|
||||
* 2) contains the '~' symbol (if applicable), and is suitable for archiving
|
||||
* (i.e. writing to the config file) if fqn is false
|
||||
*
|
||||
* Return a string representation of the file which can be passed to fopen().
|
||||
* This will usually be a 'path' (hence the name of the method), but can
|
||||
* be anything that fulfills the above criterions.
|
||||
*
|
||||
|
@ -179,7 +175,19 @@ class FilesystemNode
|
|||
*
|
||||
* @return the 'path' represented by this filesystem node
|
||||
*/
|
||||
virtual string getPath(bool fqn = true) const;
|
||||
virtual string getPath() const;
|
||||
|
||||
/**
|
||||
* Return a string representation of the file which contains the '~'
|
||||
* symbol (if applicable), and is suitable for archiving (i.e. writing
|
||||
* to the config file).
|
||||
*
|
||||
* @note Do not assume that this string contains (back)slashes or any
|
||||
* other kind of 'path separators'.
|
||||
*
|
||||
* @return the 'path' represented by this filesystem node
|
||||
*/
|
||||
virtual string getRelativePath() const;
|
||||
|
||||
/**
|
||||
* Determine whether this node has a parent.
|
||||
|
@ -294,10 +302,15 @@ class AbstractFilesystemNode
|
|||
virtual string getName() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the 'path' of the current node, usable in fopen() or
|
||||
containing '~' and for archiving.
|
||||
* Returns the 'path' of the current node, usable in fopen().
|
||||
*/
|
||||
virtual string getPath(bool fqn = true) const = 0;
|
||||
virtual string getPath() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the 'path' of the current node, containing '~' and for archiving.
|
||||
*/
|
||||
|
||||
virtual string getRelativePath() const = 0;
|
||||
|
||||
/**
|
||||
* Indicates whether this path refers to a directory or not.
|
||||
|
|
|
@ -204,11 +204,11 @@ bool OSystem::create()
|
|||
setConfigPaths();
|
||||
ostringstream buf;
|
||||
buf << "Base directory: '"
|
||||
<< FilesystemNode(myBaseDir).getPath(false) << "'" << endl
|
||||
<< FilesystemNode(myBaseDir).getRelativePath() << "'" << endl
|
||||
<< "Configuration file: '"
|
||||
<< FilesystemNode(myConfigFile).getPath(false) << "'" << endl
|
||||
<< FilesystemNode(myConfigFile).getRelativePath() << "'" << endl
|
||||
<< "User game properties: '"
|
||||
<< FilesystemNode(myPropertiesFile).getPath(false) << "'" << endl
|
||||
<< FilesystemNode(myPropertiesFile).getRelativePath() << "'" << endl
|
||||
<< endl;
|
||||
logMessage(buf.str(), 1);
|
||||
|
||||
|
@ -325,19 +325,19 @@ void OSystem::setConfigPaths()
|
|||
if(s == "") s = myBaseDir + "stella.cht";
|
||||
node = FilesystemNode(s);
|
||||
myCheatFile = node.getPath();
|
||||
mySettings->setString("cheatfile", node.getPath(false));
|
||||
mySettings->setString("cheatfile", node.getRelativePath());
|
||||
|
||||
s = mySettings->getString("palettefile");
|
||||
if(s == "") s = myBaseDir + "stella.pal";
|
||||
node = FilesystemNode(s);
|
||||
myPaletteFile = node.getPath();
|
||||
mySettings->setString("palettefile", node.getPath(false));
|
||||
mySettings->setString("palettefile", node.getRelativePath());
|
||||
|
||||
s = mySettings->getString("propsfile");
|
||||
if(s == "") s = myBaseDir + "stella.pro";
|
||||
node = FilesystemNode(s);
|
||||
myPropertiesFile = node.getPath();
|
||||
mySettings->setString("propsfile", node.getPath(false));
|
||||
mySettings->setString("propsfile", node.getRelativePath());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -538,7 +538,7 @@ bool OSystem::createConsole(const string& romfile, const string& md5sum)
|
|||
myFrameBuffer->showMessage("Multicart " + type + ", loading ROM" + id);
|
||||
}
|
||||
buf << "Game console created:" << endl
|
||||
<< " ROM file: " << FilesystemNode(myRomFile).getPath(false) << endl << endl
|
||||
<< " ROM file: " << FilesystemNode(myRomFile).getRelativePath() << endl << endl
|
||||
<< getROMInfo(myConsole) << endl;
|
||||
logMessage(buf.str(), 1);
|
||||
|
||||
|
@ -881,7 +881,7 @@ void OSystem::validatePath(string& path, const string& setting,
|
|||
node = FilesystemNode(node.getPath());
|
||||
}
|
||||
path = node.getPath();
|
||||
mySettings->setString(setting, node.getPath(false));
|
||||
mySettings->setString(setting, node.getRelativePath());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -164,7 +164,7 @@ void BrowserDialog::updateListing()
|
|||
_nodeList->clear();
|
||||
|
||||
// Update the path display
|
||||
_currentPath->setLabel(_node.getPath(false));
|
||||
_currentPath->setLabel(_node.getRelativePath());
|
||||
|
||||
// Read in the data from the file system
|
||||
FSList content;
|
||||
|
|
|
@ -225,29 +225,29 @@ void FileSnapDialog::setDefaults()
|
|||
const string& basedir = instance().baseDir();
|
||||
|
||||
node = FilesystemNode("~");
|
||||
myRomPath->setEditString(node.getPath(false));
|
||||
myRomPath->setEditString(node.getRelativePath());
|
||||
|
||||
mySnapPath->setEditString(instance().defaultSnapDir());
|
||||
|
||||
const string& cheatfile = basedir + "stella.cht";
|
||||
node = FilesystemNode(cheatfile);
|
||||
myCheatFile->setEditString(node.getPath(false));
|
||||
myCheatFile->setEditString(node.getRelativePath());
|
||||
|
||||
const string& palettefile = basedir + "stella.pal";
|
||||
node = FilesystemNode(palettefile);
|
||||
myPaletteFile->setEditString(node.getPath(false));
|
||||
myPaletteFile->setEditString(node.getRelativePath());
|
||||
|
||||
const string& propsfile = basedir + "stella.pro";
|
||||
node = FilesystemNode(propsfile);
|
||||
myPropsFile->setEditString(node.getPath(false));
|
||||
myPropsFile->setEditString(node.getRelativePath());
|
||||
|
||||
const string& eepromdir = basedir;
|
||||
node = FilesystemNode(eepromdir);
|
||||
myEEPROMPath->setEditString(node.getPath(false));
|
||||
myEEPROMPath->setEditString(node.getRelativePath());
|
||||
|
||||
const string& statedir = basedir + "state";
|
||||
node = FilesystemNode(statedir);
|
||||
myStatePath->setEditString(node.getPath(false));
|
||||
myStatePath->setEditString(node.getRelativePath());
|
||||
|
||||
mySnapSingle->setState(false);
|
||||
mySnap1x->setState(false);
|
||||
|
@ -309,49 +309,49 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
case kRomDirChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myBrowser->getResult());
|
||||
myRomPath->setEditString(dir.getPath(false));
|
||||
myRomPath->setEditString(dir.getRelativePath());
|
||||
break;
|
||||
}
|
||||
|
||||
case kSnapDirChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myBrowser->getResult());
|
||||
mySnapPath->setEditString(dir.getPath(false));
|
||||
mySnapPath->setEditString(dir.getRelativePath());
|
||||
break;
|
||||
}
|
||||
|
||||
case kCheatFileChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myBrowser->getResult());
|
||||
myCheatFile->setEditString(dir.getPath(false));
|
||||
myCheatFile->setEditString(dir.getRelativePath());
|
||||
break;
|
||||
}
|
||||
|
||||
case kPaletteFileChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myBrowser->getResult());
|
||||
myPaletteFile->setEditString(dir.getPath(false));
|
||||
myPaletteFile->setEditString(dir.getRelativePath());
|
||||
break;
|
||||
}
|
||||
|
||||
case kPropsFileChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myBrowser->getResult());
|
||||
myPropsFile->setEditString(dir.getPath(false));
|
||||
myPropsFile->setEditString(dir.getRelativePath());
|
||||
break;
|
||||
}
|
||||
|
||||
case kEEPROMDirChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myBrowser->getResult());
|
||||
myEEPROMPath->setEditString(dir.getPath(false));
|
||||
myEEPROMPath->setEditString(dir.getRelativePath());
|
||||
break;
|
||||
}
|
||||
|
||||
case kStateDirChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myBrowser->getResult());
|
||||
myStatePath->setEditString(dir.getPath(false));
|
||||
myStatePath->setEditString(dir.getRelativePath());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ void LauncherDialog::updateListing(const string& nameToSelect)
|
|||
myPrevDirButton->setEnabled(myCurrentNode.hasParent());
|
||||
|
||||
// Show current directory
|
||||
myDir->setLabel(myCurrentNode.getPath(false));
|
||||
myDir->setLabel(myCurrentNode.getRelativePath());
|
||||
|
||||
// Now fill the list widget with the contents of the GameList
|
||||
StringList l;
|
||||
|
@ -583,7 +583,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
case kStartupRomDirChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myRomDir->getResult());
|
||||
instance().settings().setString("romdir", dir.getPath(false));
|
||||
instance().settings().setString("romdir", dir.getRelativePath());
|
||||
// fall through to the next case
|
||||
}
|
||||
case kRomDirChosenCmd:
|
||||
|
|
|
@ -119,7 +119,7 @@ void LoggerDialog::saveLogFile()
|
|||
string path = AbstractFilesystemNode::getAbsolutePath("stella", "~", "log");
|
||||
FilesystemNode node(path);
|
||||
|
||||
ofstream out(node.getPath(true).c_str(), ios::out);
|
||||
ofstream out(node.getPath().c_str(), ios::out);
|
||||
if(out.is_open())
|
||||
{
|
||||
out << instance().logMessages();
|
||||
|
|
|
@ -109,7 +109,7 @@ RomAuditDialog::~RomAuditDialog()
|
|||
void RomAuditDialog::loadConfig()
|
||||
{
|
||||
const string& currentdir =
|
||||
instance().launcher().currentNode().getPath(false);
|
||||
instance().launcher().currentNode().getRelativePath();
|
||||
const string& path = currentdir == "" ?
|
||||
instance().settings().getString("romdir") : currentdir;
|
||||
|
||||
|
@ -209,7 +209,7 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
case kAuditDirChosenCmd:
|
||||
{
|
||||
FilesystemNode dir(myBrowser->getResult());
|
||||
myRomPath->setEditString(dir.getPath(false));
|
||||
myRomPath->setEditString(dir.getRelativePath());
|
||||
myResults1->setLabel("");
|
||||
myResults2->setLabel("");
|
||||
break;
|
||||
|
|
|
@ -49,5 +49,5 @@ OSystemMACOSX::~OSystemMACOSX()
|
|||
string OSystemMACOSX::defaultSnapDir()
|
||||
{
|
||||
FilesystemNode desktop("~/Desktop");
|
||||
return desktop.isDirectory() ? desktop.getPath(false) : "~";
|
||||
return desktop.isDirectory() ? desktop.getRelativePath() : "~";
|
||||
}
|
||||
|
|
|
@ -61,7 +61,8 @@ class POSIXFilesystemNode : public AbstractFilesystemNode
|
|||
bool exists() const { return access(_path.c_str(), F_OK) == 0; }
|
||||
string getDisplayName() const { return _displayName; }
|
||||
string getName() const { return _displayName; }
|
||||
string getPath(bool fqn) const;
|
||||
string getPath() const { return _path; }
|
||||
string getRelativePath() const;
|
||||
bool isDirectory() const { return _isDirectory; }
|
||||
bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
|
||||
bool isWritable() const { return access(_path.c_str(), W_OK) == 0; }
|
||||
|
@ -161,11 +162,11 @@ POSIXFilesystemNode::POSIXFilesystemNode(const string& p, bool verify)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string POSIXFilesystemNode::getPath(bool fqn) const
|
||||
string POSIXFilesystemNode::getRelativePath() const
|
||||
{
|
||||
// If the path starts with the home directory, replace it with '~'
|
||||
const char* home = getenv("HOME");
|
||||
if(!fqn && home != NULL && BSPF_startsWithIgnoreCase(_path, home))
|
||||
if(home != NULL && BSPF_startsWithIgnoreCase(_path, home))
|
||||
{
|
||||
string path = "~";
|
||||
const char* offset = _path.c_str() + strlen(home);
|
||||
|
@ -307,7 +308,7 @@ string AbstractFilesystemNode::getAbsolutePath(const string& p,
|
|||
{
|
||||
// Does p start with the root directory or the given startpath?
|
||||
// If not, it isn't an absolute path
|
||||
string path = FilesystemNode(p).getPath(false);
|
||||
string path = FilesystemNode(p).getRelativePath();
|
||||
if(!BSPF_startsWithIgnoreCase(p, startpath+"/") &&
|
||||
!BSPF_startsWithIgnoreCase(p, "/"))
|
||||
path = startpath + "/" + p;
|
||||
|
|
|
@ -94,7 +94,8 @@ class WindowsFilesystemNode : public AbstractFilesystemNode
|
|||
bool exists() const { return _access(_path.c_str(), F_OK) == 0; }
|
||||
string getDisplayName() const { return _displayName; }
|
||||
string getName() const { return _displayName; }
|
||||
string getPath(bool fqn) const;
|
||||
string getPath() const { return _path; }
|
||||
string getRelativePath() const;
|
||||
bool isDirectory() const { return _isDirectory; }
|
||||
bool isReadable() const { return _access(_path.c_str(), R_OK) == 0; }
|
||||
bool isWritable() const { return _access(_path.c_str(), W_OK) == 0; }
|
||||
|
@ -275,11 +276,11 @@ WindowsFilesystemNode::WindowsFilesystemNode(const string& p)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string WindowsFilesystemNode::getPath(bool fqn) const
|
||||
string WindowsFilesystemNode::getRelativePath() const
|
||||
{
|
||||
// If the path starts with the home directory, replace it with '~'
|
||||
const string& home = myHomeFinder.getHomePath();
|
||||
if(!fqn && home != "" && BSPF_startsWithIgnoreCase(_path, home))
|
||||
if(home != "" && BSPF_startsWithIgnoreCase(_path, home))
|
||||
{
|
||||
string path = "~";
|
||||
const char* offset = _path.c_str() + home.length();
|
||||
|
@ -407,23 +408,23 @@ string AbstractFilesystemNode::getAbsolutePath(const string& p,
|
|||
const string& startpath,
|
||||
const string& ext)
|
||||
{
|
||||
// Does p start with a drive letter or the given startpath?
|
||||
// If not, it isn't an absolute path
|
||||
string path = FilesystemNode(p).getPath(false);
|
||||
bool startsWithDrive = path.length() >= 2 && path[1] == ':';
|
||||
if(!BSPF_startsWithIgnoreCase(p, startpath+"\\") && !startsWithDrive)
|
||||
path = startpath + "\\" + p;
|
||||
|
||||
// Does the path have a valid extension?
|
||||
// If not, we add the given one
|
||||
string::size_type idx = path.find_last_of('.');
|
||||
if(idx != string::npos)
|
||||
{
|
||||
if(!BSPF_equalsIgnoreCase(path.c_str() + idx + 1, ext))
|
||||
path = path.replace(idx+1, ext.length(), ext);
|
||||
}
|
||||
else
|
||||
path += "." + ext;
|
||||
|
||||
return path;
|
||||
// Does p start with a drive letter or the given startpath?
|
||||
// If not, it isn't an absolute path
|
||||
string path = FilesystemNode(p).getRelativePath();
|
||||
bool startsWithDrive = path.length() >= 2 && path[1] == ':';
|
||||
if(!BSPF_startsWithIgnoreCase(p, startpath+"\\") && !startsWithDrive)
|
||||
path = startpath + "\\" + p;
|
||||
|
||||
// Does the path have a valid extension?
|
||||
// If not, we add the given one
|
||||
string::size_type idx = path.find_last_of('.');
|
||||
if(idx != string::npos)
|
||||
{
|
||||
if(!BSPF_equalsIgnoreCase(path.c_str() + idx + 1, ext))
|
||||
path = path.replace(idx+1, ext.length(), ext);
|
||||
}
|
||||
else
|
||||
path += "." + ext;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -52,38 +52,59 @@ class HomeFinder
|
|||
|
||||
/** Wrapper for SHGetFolderPathA, returning the 'HOME/User' folder
|
||||
(or an empty string if the folder couldn't be determined. */
|
||||
string getHomePath() const
|
||||
const string& getHomePath() const
|
||||
{
|
||||
if(!myFolderPathFunc) return "";
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = (myFolderPathFunc)
|
||||
(NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
|
||||
|
||||
return (result == 0) ? folder_path : "";
|
||||
if(ourHomePath == "")
|
||||
{
|
||||
if(!myFolderPathFunc)
|
||||
ourHomePath = "";
|
||||
else
|
||||
{
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = (myFolderPathFunc)
|
||||
(NULL, CSIDL_PROFILE | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
|
||||
ourHomePath = (result == 0) ? folder_path : "";
|
||||
}
|
||||
}
|
||||
return ourHomePath;
|
||||
}
|
||||
|
||||
/** Wrapper for SHGetFolderPathA, returning the 'APPDATA' folder
|
||||
(or an empty string if the folder couldn't be determined. */
|
||||
string getAppDataPath() const
|
||||
const string& getAppDataPath() const
|
||||
{
|
||||
if(!myFolderPathFunc) return "";
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = (myFolderPathFunc)
|
||||
(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
|
||||
|
||||
return (result == 0) ? folder_path : "";
|
||||
if(ourAppDataPath == "")
|
||||
{
|
||||
if(!myFolderPathFunc)
|
||||
ourAppDataPath = "";
|
||||
else
|
||||
{
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = (myFolderPathFunc)
|
||||
(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
|
||||
ourAppDataPath = (result == 0) ? folder_path : "";
|
||||
}
|
||||
}
|
||||
return ourAppDataPath;
|
||||
}
|
||||
|
||||
/** Wrapper for SHGetFolderPathA, returning the 'DESKTOPDIRECTORY' folder
|
||||
(or an empty string if the folder couldn't be determined. */
|
||||
string getDesktopPath() const
|
||||
const string& getDesktopPath() const
|
||||
{
|
||||
if(!myFolderPathFunc) return "";
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = (myFolderPathFunc)
|
||||
(NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
|
||||
|
||||
return (result == 0) ? folder_path : "";
|
||||
if(ourDesktopPath == "")
|
||||
{
|
||||
if(!myFolderPathFunc)
|
||||
ourDesktopPath = "";
|
||||
else
|
||||
{
|
||||
char folder_path[MAX_PATH];
|
||||
HRESULT const result = (myFolderPathFunc)
|
||||
(NULL, CSIDL_DESKTOPDIRECTORY | CSIDL_FLAG_CREATE, NULL, 0, folder_path);
|
||||
ourDesktopPath = (result == 0) ? folder_path : "";
|
||||
}
|
||||
}
|
||||
return ourDesktopPath;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -91,6 +112,12 @@ class HomeFinder
|
|||
|
||||
HMODULE myFolderModule;
|
||||
function_pointer myFolderPathFunc;
|
||||
|
||||
static string ourHomePath, ourAppDataPath, ourDesktopPath;
|
||||
};
|
||||
|
||||
__declspec(selectany) string HomeFinder::ourHomePath = "";
|
||||
__declspec(selectany) string HomeFinder::ourAppDataPath = "";
|
||||
__declspec(selectany) string HomeFinder::ourDesktopPath = "";
|
||||
|
||||
#endif
|
||||
|
|
|
@ -72,7 +72,7 @@ OSystemWin32::OSystemWin32()
|
|||
FilesystemNode appdata(homefinder.getAppDataPath());
|
||||
if(appdata.isDirectory())
|
||||
{
|
||||
basedir = appdata.getPath(false);
|
||||
basedir = appdata.getRelativePath();
|
||||
if(basedir.length() > 1 && basedir[basedir.length()-1] != '\\')
|
||||
basedir += '\\';
|
||||
basedir += "Stella";
|
||||
|
@ -95,7 +95,7 @@ string OSystemWin32::defaultSnapDir()
|
|||
{
|
||||
HomeFinder homefinder;
|
||||
FilesystemNode desktop(homefinder.getDesktopPath());
|
||||
return desktop.isDirectory() ? desktop.getPath(false) : "~";
|
||||
return desktop.isDirectory() ? desktop.getRelativePath() : "~";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
Loading…
Reference in New Issue