diff options
| author | ruki <[email protected]> | 2023-03-04 00:57:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-03-04 00:57:05 +0800 |
| commit | 95bde15f54e6dfffe5eeeee2a04e697f615e8868 (patch) | |
| tree | 8996e4ed8b9ec01539b62b4186c088020da84ba4 /xmake/core/base/os.lua | |
| parent | 9f5e98c4cc256d3321d4d5e23037304e723cdb93 (diff) | |
improve fscase
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 3d0ad886d..dee65cbdc 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -39,6 +39,7 @@ os._mkdir = os._mkdir or os.mkdir os._rmdir = os._rmdir or os.rmdir os._touch = os._touch or os.touch os._tmpdir = os._tmpdir or os.tmpdir +os._fscase = os._fscase or os.fscase os._setenv = os._setenv or os.setenv os._getenvs = os._getenvs or os.getenvs os._cpuinfo = os._cpuinfo or os.cpuinfo @@ -1068,8 +1069,24 @@ function os.isroot() end -- is case-insensitive filesystem? -function os.fscase() - if os._FSCASE == nil then +function os.fscase(filepath) + if os._FSCASE == nil or filepath then + if os._fscase then + if filepath then + assert(os.exists(filepath), filepath .. " not found in os.fscase()") + else + local tmpdir = os.tmpdir() + if not os.isdir(tmpdir) then + os.mkdir(tmpdir) + end + filepath = tmpdir + end + local fscase = os._fscase(filepath) + if fscase ~= -1 then + os._FSCASE = (fscase == 1) + return os._FSCASE + end + end if os.host() == "windows" then os._FSCASE = false else @@ -1379,3 +1396,4 @@ end -- return module return os + |
