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 "app/resource_finder.h"
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
|
#include "base/path.h"
|
||||||
|
|
||||||
#include <allegro/config.h>
|
#include <allegro/config.h>
|
||||||
#include <allegro/file.h>
|
#include <allegro/file.h>
|
||||||
@ -48,8 +49,13 @@ ConfigModule::ConfigModule()
|
|||||||
|
|
||||||
// If the file wasn't found, we will create configuration file
|
// If the file wasn't found, we will create configuration file
|
||||||
// in the first path
|
// in the first path
|
||||||
if (config_filename[0] == 0 && rf.first())
|
if (config_filename[0] == 0) {
|
||||||
config_filename = rf.filename();
|
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());
|
override_config_file(config_filename.c_str());
|
||||||
g_configFilename = config_filename;
|
g_configFilename = config_filename;
|
||||||
|
@ -94,8 +94,7 @@ void verbose_printf(const char* format, ...)
|
|||||||
std::string filename;
|
std::string filename;
|
||||||
ResourceFinder rf;
|
ResourceFinder rf;
|
||||||
rf.includeBinDir("aseprite.log");
|
rf.includeBinDir("aseprite.log");
|
||||||
if (rf.first())
|
filename = rf.defaultFilename();
|
||||||
filename = rf.filename();
|
|
||||||
|
|
||||||
if (filename.size() > 0)
|
if (filename.size() > 0)
|
||||||
log_fileptr = fopen(filename.c_str(), "w");
|
log_fileptr = fopen(filename.c_str(), "w");
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "app/resource_finder.h"
|
#include "app/resource_finder.h"
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
#include "base/path.h"
|
#include "base/path.h"
|
||||||
|
#include "base/string.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
@ -40,10 +41,14 @@ const std::string& ResourceFinder::filename() const
|
|||||||
return m_paths.at(m_current);
|
return m_paths.at(m_current);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResourceFinder::first()
|
const std::string& ResourceFinder::defaultFilename() const
|
||||||
{
|
{
|
||||||
m_current = 0;
|
if (m_default.empty()) {
|
||||||
return (m_current < (int)m_paths.size());
|
// 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()
|
bool ResourceFinder::next()
|
||||||
@ -169,6 +174,15 @@ void ResourceFinder::includeHomeDir(const char* filename)
|
|||||||
|
|
||||||
#elif defined ALLEGRO_WINDOWS || defined ALLEGRO_DOS
|
#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
|
// $PREFIX/data/filename
|
||||||
includeDataDir(filename);
|
includeDataDir(filename);
|
||||||
|
|
||||||
@ -187,10 +201,15 @@ void ResourceFinder::includeConfFile()
|
|||||||
// $HOME/.asepriterc
|
// $HOME/.asepriterc
|
||||||
includeHomeDir(".asepriterc");
|
includeHomeDir(".asepriterc");
|
||||||
|
|
||||||
#endif
|
#elif defined ALLEGRO_WINDOWS
|
||||||
|
|
||||||
// $BINDIR/aseprite.ini
|
// $BINDIR/aseprite.ini
|
||||||
includeBinDir("aseprite.ini");
|
includeBinDir("aseprite.ini");
|
||||||
|
|
||||||
|
// %AppData%/Aseprite/aseprite.ini
|
||||||
|
includeHomeDir("aseprite.ini");
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -35,11 +35,7 @@ namespace app {
|
|||||||
// Returns the current possible path. You cannot call this
|
// Returns the current possible path. You cannot call this
|
||||||
// function if you haven't call first() or next() before.
|
// function if you haven't call first() or next() before.
|
||||||
const std::string& filename() const;
|
const std::string& filename() const;
|
||||||
|
const std::string& defaultFilename() 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();
|
|
||||||
|
|
||||||
// Goes to next possible path.
|
// Goes to next possible path.
|
||||||
bool next();
|
bool next();
|
||||||
@ -64,6 +60,7 @@ namespace app {
|
|||||||
// Members
|
// Members
|
||||||
std::vector<std::string> m_paths;
|
std::vector<std::string> m_paths;
|
||||||
int m_current;
|
int m_current;
|
||||||
|
std::string m_default;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -68,8 +68,7 @@ namespace {
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
app::ResourceFinder rf;
|
app::ResourceFinder rf;
|
||||||
rf.includeBinDir("aseprite-memory.dmp");
|
rf.includeBinDir("aseprite-memory.dmp");
|
||||||
if (rf.first())
|
filename = rf.defaultFilename();
|
||||||
filename = rf.filename();
|
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user