Skip to content

Commit

Permalink
Merge pull request #780 from permaweb/twilson63/feat-added-file-close
Browse files Browse the repository at this point in the history
feat(dev-cli): add file close function to aolib
  • Loading branch information
twilson63 authored Jun 9, 2024
2 parents 2fc3edb + 1fb8b25 commit e9cf001
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dev-cli/container/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/bash
#!/bin/sh

docker build . -t p3rmaw3b/ao
9 changes: 8 additions & 1 deletion dev-cli/container/src/aolibc/aostdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ EM_ASYNC_JS(int, weavedrive_read, (int fd, int *dst_ptr, size_t length), {
return Promise.resolve(await drive.read(fd, dst_ptr, length));
});

EM_ASYNC_JS(int, weavedrive_close, (int fd), {
const drive = Module.WeaveDrive(Module, FS);
return drive.close(fd);
});

FILE* fopen(const char* filename, const char* mode) {
AO_LOG( "AO: Called fopen: %s, %s\n", filename, mode);
int fd = weavedrive_open(filename, mode);
Expand All @@ -47,6 +52,8 @@ size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream) {

int fclose(FILE* stream) {
AO_LOG( "AO: fclose called\n");
int fd = fileno(stream);
weavedrive_close(fd);
return 0; // Returning success, adjust as necessary
}

Expand Down Expand Up @@ -85,4 +92,4 @@ int munmap(void* addr, size_t length) {
AO_LOG("AO: munmap called with addr: %p, length: %zu\n", addr, length);
return 0;
}
*/
*/
6 changes: 3 additions & 3 deletions dev-cli/src/versions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
export const VERSION = {
"CLI": "0.0.56",
"IMAGE": "0.0.36"
}
"CLI": "0.0.57",
"IMAGE": "0.0.37"
}

0 comments on commit e9cf001

Please sign in to comment.