MCPcopy
hub / github.com/vercel-labs/just-bash / IFileSystem

Interface IFileSystem

packages/just-bash/src/fs/interface.ts:118–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 * - Custom implementations (e.g., remote storage, browser IndexedDB)
117 */
118export interface IFileSystem {
119 // Note: Sync method are not supported and must not be added.
120 /**
121 * Read the contents of a file as decoded text. Default encoding is utf8;
122 * pass an explicit text encoding (`"ascii"`, etc.) to override.
123 *
124 * For raw bytes (encoding `"binary"` / `"latin1"`), use {@link readFileBytes}
125 * — the opaque return type forces callers to decide whether to forward
126 * bytes unchanged or decode as text.
127 *
128 * @throws Error if file doesn't exist or is a directory
129 */
130 readFile(
131 path: string,
132 options?: ReadFileOptions | BufferEncoding,
133 ): Promise<string>;
134
135 /**
136 * Read the raw bytes of a file as a {@link ByteString} (latin1-shaped: each
137 * char = one byte). Use when the bytes will be piped onward unchanged or
138 * explicitly decoded with `decodeBytesToUtf8` — never call string methods
139 * on the result, that's the bug class this type prevents.
140 *
141 * Optional for backwards compatibility with external `IFileSystem`
142 * implementations written before this method existed; built-in
143 * filesystems all implement it. Internal callers must route through the
144 * `readBytesFrom(fs, path)` helper, which falls back to `readFileBuffer`
145 * when this method is missing.
146 *
147 * @throws Error if file doesn't exist or is a directory
148 */
149 readFileBytes?(path: string): Promise<ByteString>;
150
151 /**
152 * Read the contents of a file as a Uint8Array (binary)
153 * @throws Error if file doesn't exist or is a directory
154 */
155 readFileBuffer(path: string): Promise<Uint8Array>;
156
157 /**
158 * Write content to a file, creating it if it doesn't exist
159 */
160 writeFile(
161 path: string,
162 content: FileContent,
163 options?: WriteFileOptions | BufferEncoding,
164 ): Promise<void>;
165
166 /**
167 * Append content to a file, creating it if it doesn't exist
168 */
169 appendFile(
170 path: string,
171 content: FileContent,
172 options?: WriteFileOptions | BufferEncoding,
173 ): Promise<void>;
174
175 /**

Callers 168

readFileMethod · 0.65
operators.test.tsFile · 0.65
readFileMethod · 0.65
readBytesFromFunction · 0.65
readBytesFromFunction · 0.65

Implementers 4

ReadWriteFspackages/just-bash/src/fs/read-write-f
OverlayFspackages/just-bash/src/fs/overlay-fs/o
InMemoryFspackages/just-bash/src/fs/in-memory-fs
MountableFspackages/just-bash/src/fs/mountable-fs

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…