2011-10-02 10:05:45 +00:00
|
|
|
#ifdef NALL_STRING_INTERNAL_HPP
|
2010-10-14 10:07:38 +00:00
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
2012-06-18 10:13:51 +00:00
|
|
|
string activepath() {
|
|
|
|
char path[PATH_MAX] = "";
|
2012-11-02 10:37:38 +00:00
|
|
|
auto unused = getcwd(path, PATH_MAX);
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
string result = path;
|
2012-06-18 10:13:51 +00:00
|
|
|
if(result.empty()) result = ".";
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
result.transform("\\", "/");
|
2013-12-03 10:01:59 +00:00
|
|
|
if(result.endsWith("/") == false) result.append("/");
|
2012-06-18 10:13:51 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
string realpath(const string& name) {
|
2012-06-18 10:13:51 +00:00
|
|
|
string result;
|
|
|
|
char path[PATH_MAX] = "";
|
2013-12-10 12:12:54 +00:00
|
|
|
if(::realpath(name, path)) result = dir(path);
|
|
|
|
if(result.empty()) result = activepath();
|
Update to v093r02 release.
byuu says:
Changelog:
- nall: fixed major memory leak in string class
- ruby: video shaders support #define-based settings now
- phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab
- sfc: remove random/ and config/, merge into system/
- ethos: delete higan.png (48x48), replace with higan512.png (512x512)
as new higan.png
- ethos: default gamma to 100% (no color adjustment)
- ethos: use "Video Shaders/Display Emulation/" instead of "Video
Shaders/Emulation/"
- use g++ instead of g++-4.7 (g++ -v must be >= 4.7)
- use -std=c++11 instead of -std=gnu++11
- applied a few patches from Debian upstream to make their packaging job
easier
So because colors are normalized in GLSL, I won't be able to offer video
shaders absolute color literals. We will have to perform basic color
conversion inside the core.
As such, the current plan is to create some sort of Emulator::Settings
interface. With that, I'll connect an option for color correction, which
will be on by default. For FC/SFC, that will mean gamma correction
(darker / stronger colors), and for GB/GBC/GBA, it will mean simulating
the weird brightness levels of the displays. I am undecided on whether
to use pea soup green for the GB or not. By not doing so, it'll be
easier for the display emulation shader to do it.
2013-11-09 11:45:54 +00:00
|
|
|
result.transform("\\", "/");
|
2013-12-03 10:01:59 +00:00
|
|
|
if(result.endsWith("/") == false) result.append("/");
|
2012-06-18 10:13:51 +00:00
|
|
|
return result;
|
2010-10-14 10:07:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 12:27:15 +00:00
|
|
|
// /home/username/
|
|
|
|
// c:/users/username/
|
2010-10-14 10:07:38 +00:00
|
|
|
string userpath() {
|
2013-04-09 13:31:46 +00:00
|
|
|
#if defined(PLATFORM_WINDOWS)
|
2012-06-18 10:13:51 +00:00
|
|
|
wchar_t path[PATH_MAX] = L"";
|
2013-03-15 13:11:33 +00:00
|
|
|
SHGetFolderPathW(nullptr, CSIDL_PROFILE | CSIDL_FLAG_CREATE, nullptr, 0, path);
|
2013-12-10 12:12:54 +00:00
|
|
|
string result = (const char*)utf8_t(path);
|
2012-06-18 10:13:51 +00:00
|
|
|
result.transform("\\", "/");
|
|
|
|
#else
|
2013-12-10 12:12:54 +00:00
|
|
|
struct passwd* userinfo = getpwuid(getuid());
|
|
|
|
string result = userinfo->pw_dir;
|
2012-06-18 10:13:51 +00:00
|
|
|
#endif
|
|
|
|
if(result.empty()) result = ".";
|
2013-12-03 10:01:59 +00:00
|
|
|
if(result.endsWith("/") == false) result.append("/");
|
2012-06-18 10:13:51 +00:00
|
|
|
return result;
|
2010-10-14 10:07:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 12:27:15 +00:00
|
|
|
// /home/username/.config/
|
|
|
|
// c:/users/username/appdata/roaming/
|
2012-06-18 10:13:51 +00:00
|
|
|
string configpath() {
|
2013-04-09 13:31:46 +00:00
|
|
|
#if defined(PLATFORM_WINDOWS)
|
2013-01-21 12:27:15 +00:00
|
|
|
wchar_t path[PATH_MAX] = L"";
|
2013-03-15 13:11:33 +00:00
|
|
|
SHGetFolderPathW(nullptr, CSIDL_APPDATA | CSIDL_FLAG_CREATE, nullptr, 0, path);
|
2013-12-10 12:12:54 +00:00
|
|
|
string result = (const char*)utf8_t(path);
|
2013-01-21 12:27:15 +00:00
|
|
|
result.transform("\\", "/");
|
2013-11-28 10:29:01 +00:00
|
|
|
#elif defined(PLATFORM_MACOSX)
|
2013-12-10 12:12:54 +00:00
|
|
|
string result = {userpath(), "Library/Application Support/"};
|
2012-06-18 10:13:51 +00:00
|
|
|
#else
|
2013-12-10 12:12:54 +00:00
|
|
|
string result = {userpath(), ".config/"};
|
2012-06-18 10:13:51 +00:00
|
|
|
#endif
|
2013-01-21 12:27:15 +00:00
|
|
|
if(result.empty()) result = ".";
|
2013-12-03 10:01:59 +00:00
|
|
|
if(result.endsWith("/") == false) result.append("/");
|
2013-01-21 12:27:15 +00:00
|
|
|
return result;
|
2010-10-14 10:07:38 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 12:12:54 +00:00
|
|
|
// /usr/share
|
|
|
|
// /Library/Application Support/
|
|
|
|
// c:/ProgramData/
|
2013-04-09 13:31:46 +00:00
|
|
|
string sharedpath() {
|
|
|
|
#if defined(PLATFORM_WINDOWS)
|
|
|
|
wchar_t path[PATH_MAX] = L"";
|
|
|
|
SHGetFolderPathW(nullptr, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, nullptr, 0, path);
|
2013-12-10 12:12:54 +00:00
|
|
|
string result = (const char*)utf8_t(path);
|
2013-04-09 13:31:46 +00:00
|
|
|
result.transform("\\", "/");
|
2013-11-28 10:29:01 +00:00
|
|
|
#elif defined(PLATFORM_MACOSX)
|
2013-12-10 12:12:54 +00:00
|
|
|
string result = "/Library/Application Support/";
|
2013-04-09 13:31:46 +00:00
|
|
|
#else
|
2013-12-10 12:12:54 +00:00
|
|
|
string result = "/usr/share/";
|
2013-04-09 13:31:46 +00:00
|
|
|
#endif
|
|
|
|
if(result.empty()) result = ".";
|
2013-12-03 10:01:59 +00:00
|
|
|
if(result.endsWith("/") == false) result.append("/");
|
2013-04-09 13:31:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-12-10 12:12:54 +00:00
|
|
|
// /tmp
|
|
|
|
// c:/users/username/AppData/Local/Temp/
|
2012-08-16 10:30:47 +00:00
|
|
|
string temppath() {
|
2013-04-09 13:31:46 +00:00
|
|
|
#if defined(PLATFORM_WINDOWS)
|
2012-08-16 10:30:47 +00:00
|
|
|
wchar_t path[PATH_MAX] = L"";
|
|
|
|
GetTempPathW(PATH_MAX, path);
|
2013-01-21 12:27:15 +00:00
|
|
|
string result = (const char*)utf8_t(path);
|
|
|
|
result.transform("\\", "/");
|
2013-12-10 12:12:54 +00:00
|
|
|
#elif defined(P_tmpdir)
|
|
|
|
string result = P_tmpdir;
|
2012-08-16 10:30:47 +00:00
|
|
|
#else
|
2013-12-10 12:12:54 +00:00
|
|
|
string result = "/tmp/";
|
2012-08-16 10:30:47 +00:00
|
|
|
#endif
|
2013-12-10 12:12:54 +00:00
|
|
|
if(result.endsWith("/") == false) result.append("/");
|
|
|
|
return result;
|
2012-08-16 10:30:47 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 10:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|