mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-04 05:50:15 +00:00
Change default location of aseprite.ini on Windows platform
The new default location is %AppData%/Aseprite folder. This will be useful for a future setup program. So if aseprite.ini is located in aseprite.exe directory, it acts like a portable program, in other case it acts like an installed program.
This commit is contained in:
parent
3c959233b6
commit
1d3854c670
@ -24,6 +24,7 @@
|
||||
|
||||
#include "app/resource_finder.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/path.h"
|
||||
|
||||
#include <allegro/config.h>
|
||||
#include <allegro/file.h>
|
||||
@ -48,8 +49,13 @@ ConfigModule::ConfigModule()
|
||||
|
||||
// If the file wasn't found, we will create configuration file
|
||||
// in the first path
|
||||
if (config_filename[0] == 0 && rf.first())
|
||||
config_filename = rf.filename();
|
||||
if (config_filename[0] == 0) {
|
||||
config_filename = rf.defaultFilename();
|
||||
|
||||
std::string dir = base::get_file_path(config_filename);
|
||||
if (!base::is_directory(dir))
|
||||
base::make_directory(dir);
|
||||
}
|
||||
|
||||
override_config_file(config_filename.c_str());
|
||||
g_configFilename = config_filename;
|
||||
|
@ -94,8 +94,7 @@ void verbose_printf(const char* format, ...)
|
||||
std::string filename;
|
||||
ResourceFinder rf;
|
||||
rf.includeBinDir("aseprite.log");
|
||||
if (rf.first())
|
||||
filename = rf.filename();
|
||||
filename = rf.defaultFilename();
|
||||
|
||||
if (filename.size() > 0)
|
||||
log_fileptr = fopen(filename.c_str(), "w");
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "app/resource_finder.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/path.h"
|
||||
#include "base/string.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -40,10 +41,14 @@ const std::string& ResourceFinder::filename() const
|
||||
return m_paths.at(m_current);
|
||||
}
|
||||
|
||||
bool ResourceFinder::first()
|
||||
const std::string& ResourceFinder::defaultFilename() const
|
||||
{
|
||||
m_current = 0;
|
||||
return (m_current < (int)m_paths.size());
|
||||
if (m_default.empty()) {
|
||||
// The first path is the default one if nobody specified it.
|
||||
if (!m_paths.empty())
|
||||
return m_paths[0];
|
||||
}
|
||||
return m_default;
|
||||
}
|
||||
|
||||
bool ResourceFinder::next()
|
||||
@ -169,6 +174,15 @@ void ResourceFinder::includeHomeDir(const char* filename)
|
||||
|
||||
#elif defined ALLEGRO_WINDOWS || defined ALLEGRO_DOS
|
||||
|
||||
// %AppData%/Aseprite/filename
|
||||
wchar_t* env = _wgetenv(L"AppData");
|
||||
if (env) {
|
||||
std::string path = base::join_path(base::to_utf8(env), "Aseprite");
|
||||
path = base::join_path(path, filename);
|
||||
addPath(path);
|
||||
m_default = path;
|
||||
}
|
||||
|
||||
// $PREFIX/data/filename
|
||||
includeDataDir(filename);
|
||||
|
||||
@ -187,10 +201,15 @@ void ResourceFinder::includeConfFile()
|
||||
// $HOME/.asepriterc
|
||||
includeHomeDir(".asepriterc");
|
||||
|
||||
#endif
|
||||
#elif defined ALLEGRO_WINDOWS
|
||||
|
||||
// $BINDIR/aseprite.ini
|
||||
includeBinDir("aseprite.ini");
|
||||
|
||||
// %AppData%/Aseprite/aseprite.ini
|
||||
includeHomeDir("aseprite.ini");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -35,11 +35,7 @@ namespace app {
|
||||
// Returns the current possible path. You cannot call this
|
||||
// function if you haven't call first() or next() before.
|
||||
const std::string& filename() const;
|
||||
|
||||
// Goes to the first option in the list of possible paths.
|
||||
// Returns true if there is (at least) one option available
|
||||
// (m_paths.size() != 0).
|
||||
bool first();
|
||||
const std::string& defaultFilename() const;
|
||||
|
||||
// Goes to next possible path.
|
||||
bool next();
|
||||
@ -64,6 +60,7 @@ namespace app {
|
||||
// Members
|
||||
std::vector<std::string> m_paths;
|
||||
int m_current;
|
||||
std::string m_default;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -68,8 +68,7 @@ namespace {
|
||||
#ifdef WIN32
|
||||
app::ResourceFinder rf;
|
||||
rf.includeBinDir("aseprite-memory.dmp");
|
||||
if (rf.first())
|
||||
filename = rf.filename();
|
||||
filename = rf.defaultFilename();
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user