@btfuse/filesystem
Version:
Filesystem plugin for the Fuse framework
81 lines (78 loc) • 2.6 kB
JavaScript
;
/*
Copyright 2023 Breautek
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FuseDirectory = void 0;
const core_1 = require("@btfuse/core");
/**
* Wrapper around a FuseFileObject when it's known to be
* representing a directory. This wrapper will provide better
* type details
*/
class FuseDirectory {
constructor(obj) {
this.$fileObj = obj;
}
getParent() {
return this.$fileObj.getParent();
}
getPath() {
return this.$fileObj.getPath();
}
get(path) {
return this.$fileObj.get(path);
}
getDirectory(path) {
return this.$fileObj.getDirectory(path);
}
async getType() {
return this.$fileObj.getType();
}
async isDirectory() {
return this.$fileObj.isDirectory();
}
async isFile() {
return this.$fileObj.isFile();
}
async getSize() {
return this.$fileObj.getSize();
}
async mkdir(recursive) {
return await this.$fileObj.mkdir(recursive);
}
async read() {
let buffer = await this.$fileObj.read();
return await core_1.FuseResponseReader.readAsJSON(buffer);
}
async readChunk(length, offset) {
let buffer = await this.$fileObj.readChunk(length, offset);
return await core_1.FuseResponseReader.readAsJSON(buffer);
}
truncate(data) {
throw new core_1.FuseError('FuseDirectory', 'Directory is not writable. Use get API to get a FuseFileObject instead.');
}
append(data) {
throw new core_1.FuseError('FuseDirectory', 'Directory is not writable. Use get API to get a FuseFileObject instead.');
}
write(data, offset) {
throw new core_1.FuseError('FuseDirectory', 'Directory is not writable. Use get API to get a FuseFileObject instead.');
}
async remove(recursive) {
return await this.$fileObj.remove(recursive);
}
async exists() {
return await this.$fileObj.exists();
}
}
exports.FuseDirectory = FuseDirectory;
//# sourceMappingURL=FuseDirectory.js.map