diff --git a/src/file.h b/src/file.h index 852dea6..3c1be0c 100644 --- a/src/file.h +++ b/src/file.h @@ -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 diff --git a/src/fomod.h b/src/fomod.h index 8f12725..8726d5e 100644 --- a/src/fomod.h +++ b/src/fomod.h @@ -5,6 +5,7 @@ #include "fomod/group.h" #include "fomod/xmlUtil.h" + int installFOMod(const char * modFolder, const char * destination); #endif diff --git a/src/getHome.h b/src/getHome.h index d242b54..141b34c 100644 --- a/src/getHome.h +++ b/src/getHome.h @@ -1 +1,8 @@ + + +/** + * @brief Get the user home dir regardless if he used sudo. + * + * @return char* path to the home dir + */ char * getHome(); diff --git a/src/install.h b/src/install.h index 9fb8a57..5a89ca6 100644 --- a/src/install.h +++ b/src/install.h @@ -1,6 +1,15 @@ #ifndef __INSTALL_H__ #define __INSTALL_H__ +#include #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 diff --git a/src/macro.h b/src/macro.h index 82803a9..10b43f7 100644 --- a/src/macro.h +++ b/src/macro.h @@ -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 diff --git a/src/main.h b/src/main.h index 02a5edd..e63cd96 100644 --- a/src/main.h +++ b/src/main.h @@ -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" diff --git a/src/order.c b/src/order.c index d4ef1de..0354585 100644 --- a/src/order.c +++ b/src/order.c @@ -96,6 +96,5 @@ void swapPlace(int appid, int modId, int modId2) { GList * list = listMods(appid); - g_list_free(list); } diff --git a/src/order.h b/src/order.h index 118381d..020b04d 100644 --- a/src/order.h +++ b/src/order.h @@ -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 diff --git a/src/overlayfs.h b/src/overlayfs.h index 438335e..f9eb612 100644 --- a/src/overlayfs.h +++ b/src/overlayfs.h @@ -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 diff --git a/src/steam.c b/src/steam.c index b26da3e..ee77166 100644 --- a/src/steam.c +++ b/src/steam.c @@ -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; } } diff --git a/src/steam.h b/src/steam.h index dedc2e7..983ce4a 100644 --- a/src/steam.h +++ b/src/steam.h @@ -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