-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.34.0 streams with read timeouts and files as streams (#52)
* streams with read timeouts and open files as streams Fixes #50
- Loading branch information
Showing
27 changed files
with
247 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule c11threads
added at
c2d0de
Submodule eli-extra-utils
updated
7 files
+7 −2 | CMakeLists.txt | |
+89 −0 | src/lerror.c | |
+15 −0 | src/lerror.h | |
+63 −0 | src/lsleep.c | |
+12 −0 | src/lsleep.h | |
+0 −110 | src/lutil.c | |
+0 −21 | src/lutil.h |
Submodule eli-fs-extra
updated
5 files
+317 −336 | src/ldir.c | |
+1 −1 | src/lfile.c | |
+36 −46 | src/llink.c | |
+238 −234 | src/llocking.c | |
+62 −64 | src/lperm.c |
Submodule eli-os-extra
updated
7 files
+2 −2 | CMakeLists.txt | |
+37 −41 | src/lcwd.c | |
+8 −8 | src/lcwd.h | |
+19 −26 | src/los.c | |
+1 −1 | src/los.h | |
+327 −303 | src/los_signal.c | |
+7 −7 | src/los_signal.h |
Submodule eli-proc-extra
updated
9 files
+4 −16 | src/lproc.c | |
+27 −35 | src/lprocess.c | |
+2 −2 | src/lprocess.h | |
+5 −5 | src/lprocess_group.c | |
+11 −35 | src/lspawn.c | |
+3 −3 | src/lspawn.h | |
+0 −8 | src/pipe.h | |
+79 −0 | src/stdio_channel.c | |
+16 −7 | src/stdio_channel.h |
Submodule eli-stream-extra
updated
5 files
+326 −211 | src/lstream.c | |
+429 −250 | src/stream.c | |
+25 −16 | src/stream.h | |
+197 −0 | src/stream_win.c | |
+12 −0 | src/stream_win.h |
Submodule lua-corehttp
updated
4 files
+1 −1 | include/core_http_config.h | |
+1 −1 | src/lcorehttp_client.c | |
+1 −1 | src/lcorehttp_preresponse.c | |
+1 −1 | src/lcorehttp_response.c |
Submodule lua-simple-ipc
updated
3 files
+11 −11 | src/lsi_core.c | |
+646 −579 | src/lsi_core_server.c | |
+331 −310 | src/lsi_core_socket.c |
Submodule lua-tar-read-native
updated
5 files
+31 −31 | src/ltar.c | |
+149 −136 | src/ltar_archive.c | |
+3 −3 | src/ltar_archive.h | |
+192 −170 | src/ltar_entry.c | |
+7 −7 | src/ltar_entry.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
local ok, stream_extra = pcall(require, "eli.stream.extra") | ||
|
||
if not ok then | ||
return {} | ||
end | ||
|
||
---#DES 'io.open_fstream' | ||
--- | ||
---@param filename string | ||
---@param mode? openmode | ||
---@return EliReadableStream | EliWritableStream | EliRWStream | nil | ||
---@return string? errmsg | ||
local function open_fstream(filename, mode) | ||
if not ok then | ||
error"eli.stream is not available" | ||
end | ||
|
||
return stream_extra.open_fstream(filename, mode) | ||
end | ||
|
||
return { | ||
open_fstream = open_fstream, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ping localhost -n 2 | ||
echo 12345 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
sleep 2 | ||
echo 12345 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
local test = TEST or require"u-test" | ||
local ok, exIo = pcall(require, "eli.extensions.io") | ||
local fs = require"eli.fs" | ||
|
||
if not ok then | ||
test["eli.extensions.io available"] = function () | ||
test.assert(false, "eli.extensions.io not available") | ||
end | ||
if not TEST then | ||
test.summary() | ||
os.exit() | ||
else | ||
return | ||
end | ||
end | ||
|
||
test["eli.extensions.io available"] = function () | ||
test.assert(true) | ||
end | ||
|
||
test["file as stream - line"] = function () | ||
local refContent = io.open"assets/test.file":read"l" | ||
local streamContent = exIo.open_fstream"assets/test.file":read"l" | ||
test.assert(refContent == streamContent, "content does not match") | ||
|
||
local refContent = io.open"assets/test.file":read"a" | ||
local stream = exIo.open_fstream"assets/test.file" | ||
local streamContent = stream:read"a" | ||
while true do | ||
local line = stream:read"L" | ||
if not line then | ||
break | ||
end | ||
streamContent = streamContent .. line | ||
end | ||
|
||
test.assert(refContent == streamContent, "content does not match") | ||
end | ||
|
||
test["file as stream - all"] = function () | ||
local refContent = io.open"assets/test.file":read"a" | ||
local streamContent = exIo.open_fstream"assets/test.file":read"a" | ||
|
||
test.assert(refContent == streamContent, "content does not match") | ||
end | ||
|
||
test["file as stream - bytes"] = function () | ||
local refContent = io.open"assets/test.file":read"l" | ||
local streamContent = exIo.open_fstream"assets/test.file":read"l" | ||
|
||
test.assert(refContent == streamContent, "content does not match") | ||
|
||
local refContent = io.open"assets/test.file":read"a" | ||
local stream = exIo.open_fstream"assets/test.file" | ||
local streamContent = stream:read"a" | ||
while true do | ||
local line = stream:read(100) | ||
if not line then | ||
break | ||
end | ||
streamContent = streamContent .. line | ||
end | ||
|
||
test.assert(refContent == streamContent, "content does not match") | ||
end | ||
|
||
test["file as stream - write"] = function () | ||
fs.remove"tmp/test-streamed.file" | ||
fs.remove"tmp/test-write.file" | ||
|
||
local content = "12345" | ||
local stream = exIo.open_fstream("tmp/test-streamed.file", "w") | ||
stream:write(content) | ||
stream:close() | ||
fs.write_file("tmp/test-write.file", content) | ||
|
||
local hashOfStreamContent = fs.hash_file"tmp/test-streamed.file" | ||
local hashOfWriteContent = fs.hash_file"tmp/test-write.file" | ||
|
||
test.assert(hashOfStreamContent == hashOfWriteContent, "content does not match") | ||
end | ||
|
||
|
||
if not TEST then | ||
test.summary() | ||
end |
Oops, something went wrong.