mirror of
https://github.com/LIV2/amiberry.git
synced 2025-12-06 06:32:45 +00:00
Macos folder changes (#1373)
* refactor: use separate dir for amiberry.conf and data under macOS (#1372) Moving the contents of the data folder and amiberry.conf, under <user>/Library/Application Support/Amiberry for macOS platforms
This commit is contained in:
parent
00b9c692d3
commit
1c0c07cb10
@ -3,17 +3,17 @@
|
||||
CWD_VAR=$(cd "$(dirname "$0")"; pwd)
|
||||
USERDIR=`echo ~`
|
||||
|
||||
if [[ ! -f "$USERDIR/Documents/Amiberry/Configurations/amiberry.conf" ]]; then
|
||||
cat $CWD_VAR/../Resources/Configurations/amiberry-osx.conf | sed -e "s#USERDIR#$USERDIR#g" > "$USERDIR/Documents/Amiberry/Configurations/amiberry.conf"
|
||||
if [[ ! -f "$USERDIR/Library/Application Support/Amiberry/amiberry.conf" ]]; then
|
||||
cat $CWD_VAR/../Resources/Configurations/amiberry-osx.conf | sed -e "s#USERDIR#$USERDIR#g" > "$USERDIR/Library/Application Support/Amiberry/amiberry.conf"
|
||||
fi
|
||||
|
||||
for file in $CWD_VAR/../Resources/Configurations/**/*(.); do
|
||||
if [[ "$file" != "$CWD_VAR/../Resources/Configurations/amiberry-osx.conf" ]]; then
|
||||
if [[ "$file" != "$CWD_VAR/../Resources/Configurations/amiberry.conf" ]]; then
|
||||
if [[ ! -f "$USERDIR/Documents/Amiberry/Configurations${file##*/Configurations}" ]]; then
|
||||
echo "Copying $file to $USERDIR/Documents/Amiberry/Configurations${file##*/Configurations}"
|
||||
mkdir -p $(dirname "$USERDIR/Documents/Amiberry/Configurations${file##*/Configurations}")
|
||||
cp $file "$USERDIR/Documents/Amiberry/Configurations${file##*/Configurations}"
|
||||
if [[ ! -f "$USERDIR/Library/Application Support/Amiberry${file##*/Configurations}" ]]; then
|
||||
echo "Copying $file to $USERDIR/Library/Application Support/Amiberry${file##*/Configurations}"
|
||||
mkdir -p $(dirname "$USERDIR/Library/Application Support/Amiberry${file##*/Configurations}")
|
||||
cp $file "$USERDIR/Library/Application Support/Amiberry${file##*/Configurations}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -3912,14 +3912,6 @@ void init_macos_amiberry_folders(const std::string& macos_amiberry_directory)
|
||||
if (!my_existsdir(directory.c_str()))
|
||||
my_mkdir(directory.c_str());
|
||||
|
||||
directory = macos_amiberry_directory + "/Data";
|
||||
if (!my_existsdir(directory.c_str()))
|
||||
my_mkdir(directory.c_str());
|
||||
|
||||
directory = macos_amiberry_directory + "/Data/floppy_sounds";
|
||||
if (!my_existsdir(directory.c_str()))
|
||||
my_mkdir(directory.c_str());
|
||||
|
||||
directory = macos_amiberry_directory + "/Savestates";
|
||||
if (!my_existsdir(directory.c_str()))
|
||||
my_mkdir(directory.c_str());
|
||||
@ -3937,6 +3929,16 @@ void init_macos_amiberry_folders(const std::string& macos_amiberry_directory)
|
||||
my_mkdir(directory.c_str());
|
||||
}
|
||||
|
||||
void init_macos_library_folders(const std::string& macos_amiberry_directory)
|
||||
{
|
||||
if (!my_existsdir(macos_amiberry_directory.c_str()))
|
||||
my_mkdir(macos_amiberry_directory.c_str());
|
||||
|
||||
std::string directory = macos_amiberry_directory + "/floppy_sounds";
|
||||
if (!my_existsdir(directory.c_str()))
|
||||
my_mkdir(directory.c_str());
|
||||
}
|
||||
|
||||
#ifdef __MACH__
|
||||
#include <mach-o/dyld.h>
|
||||
void macos_copy_amiberry_files_to_userdir(std::string macos_amiberry_directory)
|
||||
@ -3967,22 +3969,31 @@ static void init_amiberry_paths(void)
|
||||
{
|
||||
current_dir = start_path_data;
|
||||
#ifdef __MACH__
|
||||
// MacOS stores these files under the user Documents/Amiberry folder
|
||||
// On MacOS, we these files under the user Documents/Amiberry folder by default
|
||||
// If the folder is missing, we create it and copy the files from the app bundle
|
||||
// The exception is the Data folder and amiberry.conf, which live in the user Library/Application Support/Amiberry folder
|
||||
const std::string macos_home_directory = getenv("HOME");
|
||||
const std::string macos_library_directory = macos_home_directory + "/Library/Application Support/Amiberry";
|
||||
const std::string macos_amiberry_directory = macos_home_directory + "/Documents/Amiberry";
|
||||
if (!my_existsdir(macos_amiberry_directory.c_str()))
|
||||
|
||||
if (!my_existsdir(macos_amiberry_directory.c_str()) || !my_existsdir(macos_library_directory.c_str()))
|
||||
{
|
||||
// Amiberry home dir is missing, generate it and all directories under it
|
||||
//If Amiberry library dir is missing, generate it
|
||||
init_macos_library_folders(macos_library_directory);
|
||||
|
||||
// If Amiberry home dir is missing, generate it and all directories under it
|
||||
init_macos_amiberry_folders(macos_amiberry_directory);
|
||||
macos_copy_amiberry_files_to_userdir(macos_amiberry_directory);
|
||||
}
|
||||
config_path = controllers_path = data_dir = whdboot_path = whdload_arch_path = floppy_path = harddrive_path = cdrom_path =
|
||||
|
||||
config_path = controllers_path = whdboot_path = whdload_arch_path = floppy_path = harddrive_path = cdrom_path =
|
||||
logfile_path = rom_path = rp9_path = saveimage_dir = savestate_dir = ripper_path =
|
||||
input_dir = screenshot_dir = nvram_dir = plugins_dir = video_dir = macos_amiberry_directory;
|
||||
|
||||
config_path.append("/Configurations/");
|
||||
controllers_path.append("/Controllers/");
|
||||
data_dir.append("/Data/");
|
||||
data_dir = macos_library_directory;
|
||||
data_dir.append("/");
|
||||
whdboot_path.append("/Whdboot/");
|
||||
whdload_arch_path.append("/Lha/");
|
||||
floppy_path.append("/Floppies/");
|
||||
@ -3999,6 +4010,9 @@ static void init_amiberry_paths(void)
|
||||
nvram_dir.append("/Nvram/");
|
||||
plugins_dir.append("/Plugins/");
|
||||
video_dir.append("/Videos/");
|
||||
|
||||
amiberry_conf_file = data_dir;
|
||||
amiberry_conf_file.append("amiberry.conf");
|
||||
#else
|
||||
config_path = controllers_path = data_dir = whdboot_path = whdload_arch_path = floppy_path = harddrive_path = cdrom_path =
|
||||
logfile_path = rom_path = rp9_path = saveimage_dir = savestate_dir = ripper_path =
|
||||
@ -4024,9 +4038,10 @@ static void init_amiberry_paths(void)
|
||||
nvram_dir.append("/nvram/");
|
||||
plugins_dir.append("/plugins/");
|
||||
video_dir.append("/videos/");
|
||||
#endif
|
||||
|
||||
amiberry_conf_file = config_path;
|
||||
amiberry_conf_file.append("amiberry.conf");
|
||||
#endif
|
||||
|
||||
retroarch_file = config_path;
|
||||
retroarch_file.append("retroarch.cfg");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user