tbftss/src/plat/os4/os4Init.c

102 lines
2.7 KiB
C

/*
Copyright (C) 2015-2019,2022 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <errno.h>
#include <pwd.h>
#include <sys/stat.h>
#include <unistd.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include "../../common.h"
#include "os4Init.h"
#define VSTRING "tbftss 1.5.1r1 (13.08.2022)"
#define VERSTAG "\0$VER: " VSTRING
static CONST_STRPTR stack USED = "$STACK:102400";
static CONST_STRPTR version USED = VERSTAG;
extern App app;
extern Dev dev;
void createSaveFolder(void)
{
// char *dir;
// int i;
BPTR savesPathLock = Lock("PROGDIR:saves", SHARED_LOCK);
if (!savesPathLock)
{
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saves folder not found. I am going to create it.");
// mkpath("PROGDIR:saves");
if (mkdir("PROGDIR:saves", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0 && errno != EEXIST)
{
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Failed to create save dir.");
return;
}
}
else {
UnLock(savesPathLock);
}
// for (i = 0 ; i < MAX_SAVE_SLOTS ; i++)
// {
// dir = buildFormattedString("saves/%d", i);
// mkpath(dir);
// free(dir);
// }
// app.saveDir = "saves";
STRNCPY(app.saveDir, "saves", MAX_FILENAME_LENGTH);
// char *userHome;
// char dir[MAX_FILENAME_LENGTH];
// userHome = getenv("HOME");
// if (!userHome)
// {
// SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Unable to determine user save folder. Will save to current dir.");
// return;
// }
// SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "User home = %s", userHome);
// sprintf(dir, "%s/.local/share/tbftss", userHome);
// if (mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0 && errno != EEXIST)
// {
// SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Failed to create save dir '%s'. Will save to current dir.", dir);
// return;
// }
// STRNCPY(app.saveDir, dir, MAX_FILENAME_LENGTH);
}
void createScreenshotFolder(void)
{
mkdir("/tmp/tbftss", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
dev.screenshotFolder = "/tmp/tbftss";
}