summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
Diffstat (limited to 'xmake')
-rw-r--r--xmake/core/base/os.lua6
-rw-r--r--xmake/core/sandbox/modules/os.lua9
2 files changed, 15 insertions, 0 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 9f806ba08..6df38bb1c 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -40,6 +40,7 @@ os._mkdir = os._mkdir or os.mkdir
os._rmdir = os._rmdir or os.rmdir
os._tmpdir = os._tmpdir or os.tmpdir
os._setenv = os._setenv or os.setenv
+os._readlink = os._readlink or os.readlink
os._versioninfo = os._versioninfo or os.versioninfo
-- copy single file or directory
@@ -949,6 +950,11 @@ function os.pbcopy(data)
end
end
+-- read the content of symlink
+function os.readlink(symlink)
+ return os._readlink(path.absolute(symlink))
+end
+
-- get the program directory
function os.programdir()
return xmake._PROGRAM_DIR
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index a3b088bf3..87886f0b6 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -425,6 +425,15 @@ function sandbox_os.exists(filedir)
return os.exists(vformat(filedir))
end
+-- read the content of symlink
+function sandbox_os.readlink(symlink)
+ local result = os.readlink(symlink)
+ if not result then
+ os.raise("cannot read link(%s)", symlink)
+ end
+ return result
+end
+
-- return module
return sandbox_os