mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
Work on POSIX-like read() and lseek() support.
This commit is contained in:
parent
9f9b4a2382
commit
c94044a04a
Notes:
sideshowbarker
2024-07-19 18:48:17 +09:00
Author: https://github.com/awesomekling
Commit: c94044a04a
11 changed files with 201 additions and 36 deletions
|
@ -44,7 +44,7 @@ int main(int c, char** v)
|
|||
printf("failed to open %s inside fs image\n", v[2]);
|
||||
return 1;
|
||||
}
|
||||
auto contents = handle->read();
|
||||
auto contents = handle->readEntireFile();
|
||||
|
||||
FILE* fout = fopen(v[3], "w");
|
||||
if (!fout) {
|
||||
|
@ -71,7 +71,7 @@ int main(int c, char** v)
|
|||
printf("handle = %p\n", handle.ptr());
|
||||
ASSERT(handle);
|
||||
|
||||
auto contents = handle->read();
|
||||
auto contents = handle->readEntireFile();
|
||||
ASSERT(contents);
|
||||
|
||||
printf("contents: '%s'\n", contents->pointer());
|
||||
|
@ -141,11 +141,33 @@ int main(int c, char** v)
|
|||
printf("failed to open %s\n", pathbuf);
|
||||
continue;
|
||||
}
|
||||
auto contents = handle->read();
|
||||
auto contents = handle->readEntireFile();
|
||||
fwrite(contents.pointer(), sizeof(char), contents.size(), stdout);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd == "kat" && parts.size() > 1) {
|
||||
char pathbuf[1024];
|
||||
sprintf(pathbuf, "%s/%s", currentDirectory.characters(), parts[1].characters());
|
||||
auto handle = vfs.open(pathbuf);
|
||||
if (!handle) {
|
||||
printf("failed to open %s\n", pathbuf);
|
||||
continue;
|
||||
}
|
||||
ssize_t nread;
|
||||
byte buffer[512];
|
||||
for (;;) {
|
||||
nread = handle->read(buffer, sizeof(buffer));
|
||||
printf("read() returned %d\n", nread);
|
||||
if (nread <= 0)
|
||||
break;
|
||||
fwrite(buffer, 1, nread, stdout);
|
||||
}
|
||||
if (nread < 0)
|
||||
printf("ERROR: %d\n", nread);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd == "ma") {
|
||||
SimpleMalloc::dump();
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue