diff options
| author | ruki <[email protected]> | 2017-06-05 13:00:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-05 13:00:56 +0800 |
| commit | 36034c15b390bdfdd095df85cfb345c4b9f68250 (patch) | |
| tree | 3850073ded8e7c9e395e998e3a7bc6a9c3570ced | |
| parent | c681e7a5fa72d7c51163d161c593c0b78e88bdee (diff) | |
fix os.match with exclude mode
| -rw-r--r-- | core/src/xmake/os/find.c | 5 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/target.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 32 |
3 files changed, 33 insertions, 6 deletions
diff --git a/core/src/xmake/os/find.c b/core/src/xmake/os/find.c index ac336b52d..a4e590f8a 100644 --- a/core/src/xmake/os/find.c +++ b/core/src/xmake/os/find.c @@ -97,8 +97,9 @@ static tb_bool_t xm_os_find_walk(tb_char_t const* path, tb_file_info_t const* in tb_assert(!tb_strcmp(path, rootdir)); tb_assert(rootlen + 1 <= tb_strlen(path)); - // skip the rootdir - path += rootlen + 1; + // skip the rootdir if not "." + if (tb_strcmp(rootdir, ".")) + path += rootlen + 1; // exclude pathes tb_int_t i = 0; diff --git a/xmake/core/sandbox/modules/import/core/project/target.lua b/xmake/core/sandbox/modules/import/core/project/target.lua index b16c42e0c..45309772d 100644 --- a/xmake/core/sandbox/modules/import/core/project/target.lua +++ b/xmake/core/sandbox/modules/import/core/project/target.lua @@ -26,7 +26,7 @@ local sandbox_core_project_target = sandbox_core_project_target or {} -- load modules -local project = require("project/project") +local target = require("project/target") local raise = require("sandbox/modules/raise") -- get the filename from the given name and kind diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 4fee98405..90312ae2a 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -98,6 +98,32 @@ function sandbox_os.rm(...) end end +-- try to copy file or directory +function sandbox_os.trycp(...) + + -- format arguments + local args = {} + for _, arg in ipairs({...}) do + table.insert(args, vformat(arg)) + end + + -- done + return os.cp(unpack(args)) +end + +-- try to move file or directory +function sandbox_os.trymv(...) + + -- format arguments + local args = {} + for _, arg in ipairs({...}) do + table.insert(args, vformat(arg)) + end + + -- done + return os.mv(unpack(args)) +end + -- try to remove files or directories function sandbox_os.tryrm(...) @@ -108,7 +134,7 @@ function sandbox_os.tryrm(...) end -- remove it - os.rm(unpack(args)) + return os.rm(unpack(args)) end -- change to directory @@ -220,7 +246,7 @@ function sandbox_os.scriptdir() return rootdir end --- run shell +-- quietly run shell function sandbox_os.run(cmd, ...) -- make command @@ -233,7 +259,7 @@ function sandbox_os.run(cmd, ...) end end --- run shell with arguments list +-- quietly run shell with arguments list function sandbox_os.runv(shellname, argv) -- make shellname |
