Created
August 8, 2022 04:49
-
-
Save lucasvinbr/02b91bcc9310f8630887f833e6c63d8a to your computer and use it in GitHub Desktop.
Set up folder junctions (hard symlinks) for easier use of the base urho3d editor with other projects' assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local lfs = require("lfs") | |
local projectFolderName = "rock" | |
local baseUrhoPath = "F:/urro/Urho3D/bin/Data/" | |
local projectPath = "F:/urro/caracas-jam-winter2-2022-rock/bin/Data/" | |
local foldersToAddLinkIn = { | |
"Fonts", | |
"Music", | |
"Materials", | |
"Models", | |
"Objects", | |
"Particle", | |
"Scenes", | |
"Sounds", | |
"Textures", | |
"UI", | |
"Urho2D" | |
} | |
---@param path string | |
local function ConvertToBackslashes(path) | |
return path:gsub("%/", "\\") | |
end | |
for dirName, _ in lfs.dir(baseUrhoPath) do | |
if not(dirName == "." or dirName == ".." or dirName:match("%.lua")) then | |
for _, entry in ipairs(foldersToAddLinkIn) do | |
if dirName == entry and lfs.attributes(baseUrhoPath .. dirName).mode == "directory" then | |
-- create folder if not exists | |
lfs.chdir(baseUrhoPath .. dirName) | |
local baseFolder = baseUrhoPath .. dirName .. "/" .. projectFolderName | |
local linkFolder = projectPath .. dirName .. "/" .. projectFolderName | |
if not(lfs.attributes(baseUrhoPath .. dirName .. "/" .. projectFolderName)) then | |
lfs.mkdir(projectFolderName) | |
end | |
if not(lfs.attributes(projectPath .. dirName .. "/" .. projectFolderName)) then | |
--lfs.link(baseUrhoPath .. dirName .. "/" .. projectFolderName, projectPath .. dirName .. "/" .. projectFolderName) | |
local command = "mklink /J \"" .. ConvertToBackslashes(linkFolder) .. "\" \"" .. ConvertToBackslashes(baseFolder) .. "\"" | |
print(command) | |
local popenHandle = io.popen(command) | |
if popenHandle then | |
popenHandle:close() | |
end | |
-- print(lfs.attributes(baseUrhoPath .. dirName).mode) | |
end | |
lfs.chdir(baseUrhoPath) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment