make •file.MapBytes follow spec & fix error message
This commit is contained in:
parent
2c2ed7920b
commit
767a2a9e38
@ -14,7 +14,7 @@ See [the BQN specification](https://mlochbaum.github.io/BQN/spec/system.html) fo
|
|||||||
| `•name` | |
|
| `•name` | |
|
||||||
| `•wdpath` | |
|
| `•wdpath` | |
|
||||||
| `•Exit` | |
|
| `•Exit` | |
|
||||||
| `•file` | Fields: `path`, `At`, `List`, `Bytes`, `Chars`, `Lines`, `Type`, `Name`; has extensions |
|
| `•file` | Fields: `path`, `At`, `List`, `Bytes`, `Chars`, `Lines`, `Type`, `Name`, `MapBytes` |
|
||||||
| `•FChars` | |
|
| `•FChars` | |
|
||||||
| `•FBytes` | |
|
| `•FBytes` | |
|
||||||
| `•FLines` | |
|
| `•FLines` | |
|
||||||
@ -38,10 +38,6 @@ See [the BQN specification](https://mlochbaum.github.io/BQN/spec/system.html) fo
|
|||||||
|
|
||||||
# CBQN-specific system functions and extensions
|
# CBQN-specific system functions and extensions
|
||||||
|
|
||||||
## `•file.MapBytes`
|
|
||||||
|
|
||||||
`mmap`s file at path `𝕩` as an 8-bit signed integer array; Use `•bit._cast` to interpret as other types, and `↓`/`↑` to select only a part of the file.
|
|
||||||
|
|
||||||
## `•term`
|
## `•term`
|
||||||
|
|
||||||
`•term.OutRaw` and `•term.ErrRaw` output the given bytes directly to the specific stream, without any trailing newline. May be removed once a proper interface for stream I/O has been made.
|
`•term.OutRaw` and `•term.ErrRaw` output the given bytes directly to the specific stream, without any trailing newline. May be removed once a proper interface for stream I/O has been made.
|
||||||
|
|||||||
@ -249,7 +249,7 @@ DEF_FREE(mmapH) {
|
|||||||
|
|
||||||
B info_c1(B,B);
|
B info_c1(B,B);
|
||||||
static Arr* mmapH_slice(B x, usz s, usz ia) {
|
static Arr* mmapH_slice(B x, usz s, usz ia) {
|
||||||
TySlice* r = m_arr(sizeof(TySlice), t_i8slice, ia);
|
TySlice* r = m_arr(sizeof(TySlice), t_c8slice, ia);
|
||||||
r->a = c(MmapHolder,x)->a + s;
|
r->a = c(MmapHolder,x)->a + s;
|
||||||
r->p = a(x);
|
r->p = a(x);
|
||||||
return (Arr*)r;
|
return (Arr*)r;
|
||||||
@ -260,8 +260,8 @@ B mmap_file(B path) {
|
|||||||
dec(path);
|
dec(path);
|
||||||
int fd = open(p, 0);
|
int fd = open(p, 0);
|
||||||
freeCStr(p);
|
freeCStr(p);
|
||||||
u64 len = lseek(fd, 0, SEEK_END);
|
|
||||||
if (fd==-1) thrF("Failed to open file: %S", strerror(errno));
|
if (fd==-1) thrF("Failed to open file: %S", strerror(errno));
|
||||||
|
u64 len = lseek(fd, 0, SEEK_END);
|
||||||
|
|
||||||
u8* data = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0); // TODO count in heap usage
|
u8* data = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0); // TODO count in heap usage
|
||||||
if (data==MAP_FAILED) {
|
if (data==MAP_FAILED) {
|
||||||
@ -292,7 +292,7 @@ void mmap_init() {
|
|||||||
TIi(t_mmapH,print) = farr_print;
|
TIi(t_mmapH,print) = farr_print;
|
||||||
TIi(t_mmapH,isArr) = true;
|
TIi(t_mmapH,isArr) = true;
|
||||||
TIi(t_mmapH,arrD1) = true;
|
TIi(t_mmapH,arrD1) = true;
|
||||||
TIi(t_mmapH,elType) = el_i8;
|
TIi(t_mmapH,elType) = el_c8;
|
||||||
// use default canStore
|
// use default canStore
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user