added a bit of doc and some games

This commit is contained in:
Marc
2022-10-03 20:33:57 +02:00
parent 68308d9df5
commit 9325a087ee
11 changed files with 92 additions and 6 deletions
+32 -1
View File
@@ -4,13 +4,44 @@
#ifndef __FILE_H__
#define __FILE_H__
//valid copy flags
#define cp_DEFAULT 0
#define CP_LINK 1
#define CP_RECURSIVE 2
#define CP_NO_TARGET_DIR 4
int copy(const char * path, const char * dest, u_int32_t flags);
/**
* @brief execute the cp command from the source to the dest
* @param source path to the source files
* @param dest path to the destination folder
* @param flags refer to the "valid copy flags" use them like this CP_LINK | CP_RECURSIVE
* @return status code
*/
int copy(const char * source, const char * dest, u_int32_t flags);
/**
* @brief execute the cp command from the source to the dest
* @param source path to the source files
* @param dest path to the destination folder
* @param bool enable recursive rm -r
* @return status code
*/
int delete(const char * path, bool recursive);
/**
* @brief Run the mv command
* @param source
* @param destination
* @return mv's exit value
*/
int move(const char * source, const char * destination);
/**
* @brief Recursively rename all file and folder to lowercase.
*
* @param folder
*/
void casefold(const char * folder);
#endif
+1
View File
@@ -5,6 +5,7 @@
#include "fomod/group.h"
#include "fomod/xmlUtil.h"
int installFOMod(const char * modFolder, const char * destination);
#endif
+7
View File
@@ -1 +1,8 @@
/**
* @brief Get the user home dir regardless if he used sudo.
*
* @return char* path to the home dir
*/
char * getHome();
+9
View File
@@ -1,6 +1,15 @@
#ifndef __INSTALL_H__
#define __INSTALL_H__
#include <stdlib.h>
#define INSTALLED_FLAG_FILE "__DO_NOT_REMOVE__"
/**
* @brief Add a mod to the folder defined in main.h
*
* @param filePath path to the mod file
* @param appId game for which the mod is destined to be used with.
* @return EXIT_SUCCESS or EXIT_FAILURE
*/
int addMod(char * filePath, int appId);
#endif
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef __MACRO_H__
#define __MACRO_H__
//cannot be empty it's made for fixed size array
//cannot be empty it's made for fixed size array like the ones in steam.h
#define LEN(array) sizeof(array) / sizeof(array[0])
#endif
+3
View File
@@ -5,6 +5,9 @@
// in c "A" "B" is the same as "AB"
#define MANAGER_FILES ".local/share/" APP_NAME
#define MOD_FOLDER_NAME "MOD_FOLDER"
//the folder in which the games file will be linked or copied
#define GAME_FOLDER_NAME "GAME_FOLDER"
//the director that will contain all modifications to game files while being deployed
#define GAME_UPPER_DIR_NAME "UPPER_DIRS"
//overlayfs temporary dir.
#define GAME_WORK_DIR_NAME "WORK_DIRS"
-1
View File
@@ -96,6 +96,5 @@ void swapPlace(int appid, int modId, int modId2) {
GList * list = listMods(appid);
g_list_free(list);
}
+9
View File
@@ -15,6 +15,15 @@
* @return GList of char containing the name of the mod folder in order
*/
GList * listMods(int appid);
/**
* @brief Change the mod order by swaping two mod
*
* @param appid the game
* index of the mod in the mod list.
* @param modId
* @param modId2
*/
void swapPlace(int appid, int modId, int modId2);
#endif
+9
View File
@@ -1,6 +1,15 @@
#ifndef __OVERLAY_H__
#define __OVERLAY_H__
/**
* @brief Overlayfs is what make it possible to deploy to the game files without altering anything.
* it allows us to overlay multiple folder over the game files. like appling filters to an image.
* @param sources a null ended table of folder that will overlay of the game files
* @param dest the overlayed folder(the game data folder)
* @param upperdir the director that will store the changed files
* @param workdir a directory that will contains only temporary files.
* @return int error code
*/
int overlayMount(char ** sources, const char * dest, const char * upperdir, const char * workdir);
#endif
+2 -2
View File
@@ -223,9 +223,9 @@ GHashTable* search_games(int * status) {
}
int getGameIdFromAppId(u_int32_t id) {
int getGameIdFromAppId(u_int32_t appid) {
for(int k = 0; k < LEN(GAMES_APPIDS); k++) {
if(id == GAMES_APPIDS[k]) {
if(appid == GAMES_APPIDS[k]) {
return k;
}
}
+19 -1
View File
@@ -36,14 +36,32 @@ const static char * steamLibraries[] = {
// order has to be the same as in GAMES_NAMES
const static u_int32_t GAMES_APPIDS[] = {
489830,
22330,
377160
};
//the name of the game in the steamapps/common folder
const static char * GAMES_NAMES[] = {
"Skyrim Special Edition",
"Oblivion",
"Fallout 4"
};
/**
* @brief list all installed games and the paths to the game's files
*
* @param status pointer to a status variable that will be modified to EXIT_SUCCESS or EXIT_FAILURE
* @return GHashTable* a map appid(int) => path(char *)
*/
//TODO: flip the return value and parameter
GHashTable* search_games(int * status);
int getGameIdFromAppId(u_int32_t id);
/**
* @brief search the index of the game inside GAMES_NAMES or GAMES_APPIDS
*
* @param appid
* @return -1 in case of failure or the index of the game.
*/
int getGameIdFromAppId(u_int32_t appid);
#endif