From a1f6b93474d3ff5b481678225693b89c07eec03c Mon Sep 17 00:00:00 2001 From: Gardouille Date: Sat, 5 Oct 2019 21:06:33 +0200 Subject: [PATCH] Create symlink to local if remote data exist --- save.game.link | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/save.game.link b/save.game.link index f207102..6ec3ae8 100755 --- a/save.game.link +++ b/save.game.link @@ -37,6 +37,21 @@ move_steam_game_dir() { fi } # }}} +# Symlink one Steam save game dir from remote to local {{{ +symlink_steam_game_dir() { + _game_id="${1}" + _local_game_path="${local_steam_userdata}/${_game_id}" + _remote_game_path="${remote_steam_userdata}/${_game_id}" + + if [ -d "${_remote_game_path}" ]; then + ln -s -- "${_remote_game_path}" "${_local_game_path}" + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Symlink Steam game — Symlink remote data of ${_game_id} to local storage." + else + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Symlink Steam game — ${_game_id} doesn't have remote data." + fi +} +# }}} + # }}} # Tests {{{ @@ -80,6 +95,7 @@ for game_id in ${steam_games}; do ## Data can't be managed "cannot") [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam for loop — The data of ${game_id} − ${local_game_path} doesn't exist. Skip." + symlink_steam_game_dir "${game_id}" ;; *) printf '\e[1;35m%-6s\e[m\n' "Data of ${game_id} − ${local_game_path} are not managed. Type: ${local_game_path_type}. Abort"