Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jul 18, 2024
1 parent 6a405fa commit 312b845
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/modules/process/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import("core.base.scheduler")

local inftimeout = 5000

--[[
function test_single_process(t)
local stdout = os.tmpfile()
Expand Down Expand Up @@ -33,4 +34,4 @@ function test_sched_process(t)
end)
scheduler.co_group_wait("test")
t:are_equal(count, 3)
end
end]]
8 changes: 8 additions & 0 deletions xmake/core/base/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ function os._rm(filedir)

-- is file or link?
if os.isfile(filedir) or os.islink(filedir) then
print("rmfile", filedir)
if not os.rmfile(filedir) then
return false, string.format("cannot remove file %s %s", filedir, os.strerror())
end
-- is directory?
elseif os.isdir(filedir) then
print("rmdir", filedir)
if not os.rmdir(filedir) then
return false, string.format("cannot remove directory %s %s", filedir, os.strerror())
end
Expand All @@ -163,6 +165,7 @@ end
function os._rm_empty_parentdirs(filepath)
local parentdir = path.directory(filepath)
while parentdir and os.isdir(parentdir) and os.emptydir(parentdir) do
print("rm 5", parentdir)
local ok, errors = os._rm(parentdir)
if not ok then
return false, errors
Expand Down Expand Up @@ -478,6 +481,7 @@ end

-- remove files or directories
function os.rm(filepath, opt)
print("rm", filepath)

-- check arguments
if not filepath then
Expand All @@ -489,20 +493,24 @@ function os.rm(filepath, opt)
filepath = tostring(filepath)
local filepathes = os._match_wildcard_pathes(filepath)
if type(filepathes) == "string" then
print("rm 1", filepathes)
local ok, errors = os._rm(filepathes)
if not ok then
return false, errors
end
if opt.emptydirs then
print("_rm_empty_parentdirs 1", filepathes)
return os._rm_empty_parentdirs(filepathes)
end
else
for _, _filepath in ipairs(filepathes) do
print("rm 2", _filepath)
local ok, errors = os._rm(_filepath)
if not ok then
return false, errors
end
if opt.emptydirs then
print("_rm_empty_parentdirs 2", _filepath)
ok, errors = os._rm_empty_parentdirs(_filepath)
if not ok then
return false, errors
Expand Down

0 comments on commit 312b845

Please sign in to comment.