III- Aller plus Loin ?
Inception
So, I can already see the clever ones wondering if it’s possible to create clones of clones. The answer is NOT REALLY. While it is technically possible, any mods added to the first clone will be entirely copied to the second-level clone. All Junction Points are systematically linked to the original instance. It would technically be possible to create these links manually via the command line, but managing mods through CKAN would then be much more complicated: an update to a mod in a lower instance would not be reflected in the ./CKAN
directories of the higher instance, and it would not know that the mod has been updated. This would need to be managed manually. Perhaps this will be made possible in a future version…
Nevertheless, we can imagine an implementation like this:
Level 1 (5,46Gb) KSP1125STOCK | Level 2 (5,81Gb) KSP_N1BaseGame | Level 3 User Instances | Savings |
---|---|---|---|
KSP 1.12.5 Stock | Community Fixes MJ, KER, RCS Build Air TWP Forked Parallax, EVE, Scatterer Deferred, TUFX Restock & Restock+ Waterfall ZTheme (inclus Kopernicus) | (JNSQ) (KSRSS Main) (KSRSS Test Mods) | 22,54Gb |
Implementation
How to proceed then? It should be done as follows:
- Prepare level 2 with the desired mods
- Clone the level 2 instance to create level 3
- For each directory in GameData, delete it and replace it with a junction using the command
mklink /J mod ..\..\KSP_ORIGIN\GameData\mod
It would be nice to have a ready-to-use script that does this job for us, wouldn’t it?
DISCLAIMER
What is described following this notice is to be used at your own risk. I do not guarantee the robustness of the code or the integrity of your machine in case of misuse of these instructions. I have only tested it on my own setup.
Here’s an example to place in the GameData of the final instance.
@echo off
setlocal enabledelayedexpansion
REM Ask the user to enter the name of a directory outside the current directory
REM no while loop possible in BAT, so using goto
:ask_root_folder
set "ROOT_FOLDER="
set /p ROOT_FOLDER="Please enter the source ROOT_FOLDER (outside this current folder): "
REM Check if ROOT_FOLDER exists and is not a subdirectory of the current directory
if not exist "!ROOT_FOLDER!" (
echo Folder "!ROOT_FOLDER!" does not exist. AGAIN.
goto ask_root_folder
)
REM Get the absolute path of the current directory
set "CURRENT_DIR=%cd%"
REM Check if ROOT_FOLDER is a subdirectory of the current directory
set "TEMP_ROOT=!ROOT_FOLDER:\=!"
set "TEMP_CUR=!CURRENT_DIR:\=!"
if /i "!TEMP_ROOT!"=="!TEMP_CUR!" (
echo Folder "!ROOT_FOLDER!" must be outside this current foler. AGAIN.
goto ask_root_folder
)
REM Save all directories in the current directory
set "FOLDERS="
REM Get list of junction names
(for /f %%j in ('dir /a:l /b') do echo %%j) > junctions.txt
REM Loop over all folders excluding junctions
for /d %%i in (*) do (
findstr /i /x "%%i" junctions.txt >nul
if errorlevel 1 (
REM Folder is NOT a junction
set "FOLDERS=!FOLDERS! %%i"
) else (
echo Skipping junction: %%i
)
)
REM Clean up
del junctions.txt
REM for each folder in current folder
for %%i in (!FOLDERS!) do (
set "I_FOLDER=%%i"
REM check whether ROOT_FOLDER\I_FOLDER exists
if exist "!ROOT_FOLDER!\!I_FOLDER!" (
REM Remove I_FOLDER from the current folder
rmdir /s /q "!I_FOLDER!
REM Create a junction point from I_FOLDER to ROOT_FOLDER\GameData\I_FOLDER
mklink /J "!I_FOLDER!" "!ROOT_FOLDER!\GameData\!I_FOLDER!
echo creating junction point: !I_FOLDER! -> !ROOT_FOLDER!\!I_FOLDER!
) else (
echo !ROOT_FOLDER!\!I_FOLDER!" does not exist. Next.
)
)
echo Finished.
pause
Need to know more? You can reach out to the community on our Discord!
4o