MCPcopy
hub / github.com/jvilk/BrowserFS / stat

Method stat

src/backend/XmlHttpRequest.ts:211–237  ·  view source on GitHub ↗
(path: string, isLstat: boolean, cb: BFSCallback<Stats>)

Source from the content-addressed store, hash-verified

209 }
210
211 public stat(path: string, isLstat: boolean, cb: BFSCallback<Stats>): void {
212 const inode = this._index.getInode(path);
213 if (inode === null) {
214 return cb(ApiError.ENOENT(path));
215 }
216 let stats: Stats;
217 if (isFileInode<Stats>(inode)) {
218 stats = inode.getData();
219 // At this point, a non-opened file will still have default stats from the listing.
220 if (stats.size < 0) {
221 this._requestFileSizeAsync(path, function(e: ApiError, size?: number) {
222 if (e) {
223 return cb(e);
224 }
225 stats.size = size!;
226 cb(null, stats.clone());
227 });
228 } else {
229 cb(null, stats.clone());
230 }
231 } else if (isDirInode(inode)) {
232 stats = inode.getStats();
233 cb(null, stats);
234 } else {
235 cb(ApiError.FileError(ErrorCode.EINVAL, path));
236 }
237 }
238
239 public statSync(path: string, isLstat: boolean): Stats {
240 const inode = this._index.getInode(path);

Callers

nothing calls this directly

Calls 10

_requestFileSizeAsyncMethod · 0.95
isFileInodeFunction · 0.90
isDirInodeFunction · 0.90
cbFunction · 0.85
getInodeMethod · 0.80
ENOENTMethod · 0.80
cloneMethod · 0.80
FileErrorMethod · 0.80
getDataMethod · 0.45
getStatsMethod · 0.45

Tested by

no test coverage detected