From 278ea7627a3c76e2712c1117ced1bdc3045bdb9d Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 11 May 2022 22:31:07 +0800 Subject: send and recv stream files --- xmake/modules/private/service/stream.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xmake/modules/private/service/stream.lua b/xmake/modules/private/service/stream.lua index 8cb802ab8..aab400558 100644 --- a/xmake/modules/private/service/stream.lua +++ b/xmake/modules/private/service/stream.lua @@ -202,6 +202,16 @@ function stream:send_file(filepath, opt) return ok end +-- send files +function stream:send_files(filepaths, opt) + for _, filepath in ipairs(filepaths) do + if not self:send_file(filepath, opt) then + return false + end + end + return true +end + -- recv the given bytes function stream:recv(buff, size) assert(size <= buff:size(), "too large size(%d)", size) @@ -348,6 +358,16 @@ function stream:recv_file(filepath) end end +-- recv files +function stream:recv_files(filepaths) + for _, filepath in ipairs(filepaths) do + if not self:recv_file(filepath) then + return false + end + end + return true +end + -- recv compressed file function stream:_recv_compressed_file(lz4_stream, filepath, size) local buff = self._BUFF -- cgit v1.3.1