Skip to content

Commit

Permalink
chore: unify VirtualFile API
Browse files Browse the repository at this point in the history
  • Loading branch information
divyenduz committed Nov 10, 2023
1 parent 0f8a5c9 commit 3616a9b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/getattr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const getattr: (backend: SQLiteBackend) => MountOptions["getattr"] = (

if (backend.isVirtualFile(path)) {
const virtualFile = backend.getVirtualFile(path);
cb(0, virtualFile.getAttr());
cb(0, virtualFile.attr);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const read: (backend: SQLiteBackend) => MountOptions["read"] = (

if (backend.isVirtualFile(path)) {
const virtualFile = backend.getVirtualFile(path);
const bufChunk = virtualFile.getBuffer();
const bufChunk = virtualFile.buffer;
buf.write(bufChunk.toString("binary"), "binary");
cb(Buffer.byteLength(bufChunk));
return;
Expand Down
10 changes: 5 additions & 5 deletions packages/sqlite-backend/VirtualFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ export class VirtualFile {
return this._fileId;
}

getBuffer() {
get buffer() {
return Buffer.from(this._content);
}

getSize() {
return Buffer.byteLength(this.getBuffer());
get size() {
return Buffer.byteLength(this.buffer);
}

getAttr() {
get attr() {
return {
mtime: this._date,
atime: this._date,
ctime: this._date,
blocks: 1,
ino: this.fileId,
nlink: 1,
size: this.getSize(),
size: this.size,
mode: 33188,
uid: process.getuid ? process.getuid() : 0,
gid: process.getgid ? process.getgid() : 0,
Expand Down

0 comments on commit 3616a9b

Please sign in to comment.