UNPKG

nufatfs

Version:

A new async-friendly library for accessing FAT16 and FAT32 filesystems

25 lines (24 loc) 760 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ClusterChainLink = void 0; class ClusterChainLink { constructor(fat, index, length) { this.fat = fat; this.index = index; this.length = length; } async read() { return this.fat.readClusters(this.index, 1); } async write(data) { const actualClusterSize = this.fat.clusterSizeInBytes; if (data.length !== actualClusterSize) { const oldData = data; data = new Uint8Array(actualClusterSize); data.fill(0, oldData.length); data.set(oldData, 0); } await this.fat.writeClusters(this.index, data); } } exports.ClusterChainLink = ClusterChainLink;