mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Add getChildren function to DataAccessor interface
DataAccessors are now no longer responsible for generating ldp:contains triples.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Stats } from 'fs';
|
||||
import type { Dirent, Stats } from 'fs';
|
||||
|
||||
import { PassThrough } from 'stream';
|
||||
import streamifyArray from 'streamify-array';
|
||||
import type { SystemError } from '../../src/util/errors/SystemError';
|
||||
@@ -149,6 +150,19 @@ export function mockFs(rootFilepath?: string, time?: Date): { data: any } {
|
||||
}
|
||||
return Object.keys(folder[name]);
|
||||
},
|
||||
async* opendir(path: string): AsyncIterableIterator<Dirent> {
|
||||
const { folder, name } = getFolder(path);
|
||||
if (!folder[name]) {
|
||||
throwSystemError('ENOENT');
|
||||
}
|
||||
for (const child of Object.keys(folder[name])) {
|
||||
yield {
|
||||
name: child,
|
||||
isFile: (): boolean => typeof folder[name][child] === 'string',
|
||||
isDirectory: (): boolean => typeof folder[name][child] === 'object',
|
||||
} as Dirent;
|
||||
}
|
||||
},
|
||||
mkdir(path: string): void {
|
||||
const { folder, name } = getFolder(path);
|
||||
if (folder[name]) {
|
||||
|
||||
Reference in New Issue
Block a user