view src/filesystem.cpp @ 6:1d82f6e04d7d

Update: add first parts to the settings dialog
author Paper <mrpapersonic@gmail.com>
date Wed, 16 Aug 2023 00:49:17 -0400
parents 51ae25154b70
children 07a9095eaeed
line wrap: on
line source

#ifdef _WIN32
#include <shlobj.h>
#elif defined(MACOSX)
#include "sys/osx/filesystem.h"
#endif
#include <filesystem>
#include <limits.h>
#include <QMessageBox>
#include "config.h"
#include "filesystem.h"
#include "string_utils.h"

std::filesystem::path get_config_path(void) {
	std::filesystem::path cfg_path;
#ifdef _WIN32
	char buf[PATH_MAX+1];
	if (SHGetFolderPathAndSubDir(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, CONFIG_DIR, buf) == S_OK)
		cfg_path = std::filesystem::path(buf) / CONFIG_NAME;
#elif defined(MACOSX)
	/* hope and pray that std::filesystem can handle tildes... */
 	cfg_path = std::filesystem::path(StringUtils::Utf8ToWstr(osx::GetApplicationSupportDirectory())) / CONFIG_DIR / CONFIG_NAME;
#else // just assume POSIX
	cfg_path = std::filesystem::path(getenv("HOME")) / ".config" / CONFIG_DIR / CONFIG_NAME;
#endif
	return cfg_path;
}