diff options
| author | ruki <[email protected]> | 2024-02-17 00:53:50 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-02-17 00:53:50 +0800 |
| commit | 46e7ec6f73079a78f6af1da6ea39c302c676d5f9 (patch) | |
| tree | 0478600c69d32b7434ff56515c3cb5d5a24c1d63 | |
| parent | 894360ff6656c48aa7286081206eb56989233751 (diff) | |
format code
| -rw-r--r-- | xmake/core/base/io.lua | 41 | ||||
| -rw-r--r-- | xmake/core/project/config.lua | 4 |
2 files changed, 4 insertions, 41 deletions
diff --git a/xmake/core/base/io.lua b/xmake/core/base/io.lua index 6953b465f..a99e2a28f 100644 --- a/xmake/core/base/io.lua +++ b/xmake/core/base/io.lua @@ -563,9 +563,6 @@ end -- function io.open(filepath, mode, opt) - -- check - assert(filepath) - -- init option and mode opt = opt or {} mode = mode or "r" @@ -582,11 +579,6 @@ end -- open a filelock function io.openlock(filepath) - - -- check - assert(filepath) - - -- open it filepath = tostring(filepath) local lock = io.filelock_open(filepath) if lock then @@ -722,42 +714,24 @@ end -- cat the given file function io.cat(filepath, linecount, opt) - - -- init option opt = opt or {} - - -- open file local file = io.open(filepath, "r", opt) if file then - - -- show file local count = 1 for line in file:lines(opt) do - - -- show line io.write(line, "\n") - - -- end? if linecount and count >= linecount then break end - - -- update the line count count = count + 1 end - - -- exit file file:close() end end -- tail the given file function io.tail(filepath, linecount, opt) - - -- init option opt = opt or {} - - -- all? if linecount < 0 then return io.cat(filepath, opt) end @@ -765,43 +739,28 @@ function io.tail(filepath, linecount, opt) -- open file local file = io.open(filepath, "r", opt) if file then - - -- read lines local lines = {} for line in file:lines(opt) do table.insert(lines, line) end - -- tail lines local tails = {} if #lines ~= 0 then local count = 1 for index = #lines, 1, -1 do - - -- show line table.insert(tails, lines[index]) - - -- end? if linecount and count >= linecount then break end - - -- update the line count count = count + 1 end end - -- show tails if #tails ~= 0 then for index = #tails, 1, -1 do - - -- show tail io.print(tails[index]) - end end - - -- exit file file:close() end end diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index e57d96caa..f1a97da0c 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -216,6 +216,10 @@ function config.load(filepath, opt) end -- save the project configuration +-- +-- @note we pass only_changed to avoid frequent changes to the file's mtime, +-- because some plugins(vscode, compile_commands.autoupdate) depend on it's mtime. +-- function config.save(filepath, opt) opt = opt or {} filepath = filepath or config.filepath() |
