mirror of
https://github.com/janet-lang/janet
synced 2025-01-13 17:10:27 +00:00
Remove some flags in os/open.
This commit is contained in:
parent
cdcb774dc8
commit
a7ed3dea4b
@ -1125,6 +1125,20 @@ void janet_ev_deinit(void) {
|
||||
* There is some networking code in here as well as generic
|
||||
* reading and writing primitives. */
|
||||
|
||||
void janet_stream_flags(JanetStream *stream, uint32_t flags) {
|
||||
if (stream->flags & JANET_STREAM_CLOSED) {
|
||||
janet_panic("stream is closed");
|
||||
}
|
||||
if ((stream->flags & flags) != flags) {
|
||||
const char *rmsg = "", *wmsg = "", *amsg = "", *dmsg = "", *smsg = "stream";
|
||||
if (flags & JANET_STREAM_READABLE) rmsg = "readable ";
|
||||
if (flags & JANET_STREAM_WRITABLE) wmsg = "writable ";
|
||||
if (flags & JANET_STREAM_ACCEPTABLE) amsg = "server ";
|
||||
if (flags & JANET_STREAM_UDPSERVER) dmsg = "datagram ";
|
||||
if (flags & JANET_STREAM_SOCKET) smsg = "socket";
|
||||
janet_panicf("bad stream, expected %s%s%s%s%s", rmsg, wmsg, amsg, dmsg, smsg);
|
||||
}
|
||||
}
|
||||
|
||||
/* When there is an IO error, we need to be able to convert it to a Janet
|
||||
* string to raise a Janet error. */
|
||||
|
@ -488,18 +488,6 @@ static Janet cfun_net_listen(int32_t argc, Janet *argv) {
|
||||
}
|
||||
}
|
||||
|
||||
void janet_stream_flags(JanetStream *stream, uint32_t flags) {
|
||||
if ((stream->flags & flags) != flags || (stream->flags & JANET_STREAM_CLOSED)) {
|
||||
const char *rmsg = "", *wmsg = "", *amsg = "", *dmsg = "", *smsg = "stream";
|
||||
if (flags & JANET_STREAM_READABLE) rmsg = "readable ";
|
||||
if (flags & JANET_STREAM_WRITABLE) wmsg = "writable ";
|
||||
if (flags & JANET_STREAM_ACCEPTABLE) amsg = "server ";
|
||||
if (flags & JANET_STREAM_UDPSERVER) dmsg = "datagram ";
|
||||
if (flags & JANET_STREAM_SOCKET) smsg = "socket";
|
||||
janet_panicf("bad stream, expected %s%s%s%s%s", rmsg, wmsg, amsg, dmsg, smsg);
|
||||
}
|
||||
}
|
||||
|
||||
static Janet cfun_stream_accept_loop(int32_t argc, Janet *argv) {
|
||||
janet_fixarity(argc, 2);
|
||||
JanetStream *stream = janet_getabstract(argv, 0, &janet_stream_type);
|
||||
|
@ -1661,12 +1661,6 @@ static Janet os_open(int32_t argc, Janet *argv) {
|
||||
case 'x':
|
||||
open_flags |= O_SYNC;
|
||||
break;
|
||||
case 'y':
|
||||
open_flags |= O_DSYNC;
|
||||
break;
|
||||
case 'z':
|
||||
open_flags |= O_RSYNC;
|
||||
break;
|
||||
case 'C':
|
||||
open_flags |= O_NOCTTY;
|
||||
break;
|
||||
@ -2023,9 +2017,7 @@ static const JanetReg os_cfuns[] = {
|
||||
"\t:t - shorten an existing file to length 0 (O_TRUNC)\n\n"
|
||||
"Posix only flags:\n"
|
||||
"\t:a - append to a file (O_APPEND)\n"
|
||||
"\t:x - O_DSYNC\n"
|
||||
"\t:y - O_SYNC\n"
|
||||
"\t:z - O_RSYNC\n"
|
||||
"\t:x - O_SYNC\n"
|
||||
"\t:C - O_NOCTTY\n\n"
|
||||
"Windows only flags:\n"
|
||||
"\t:R - share reads (FILE_SHARE_READ)\n"
|
||||
|
Loading…
Reference in New Issue
Block a user