Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 2x 119x 119x 119x 119x 74x 74x 74x 2x | import { IFileSystemDirectoryHandle } from '../fsa/types';
import { FsaToNodeConstants } from './constants';
import type { FsLocation } from './types';
export const pathToLocation = (path: string): FsLocation => {
if (path[0] === FsaToNodeConstants.Separator) path = path.slice(1);
if (path[path.length - 1] === FsaToNodeConstants.Separator) path = path.slice(0, -1);
const lastSlashIndex = path.lastIndexOf(FsaToNodeConstants.Separator);
if (lastSlashIndex === -1) return [[], path];
const file = path.slice(lastSlashIndex + 1);
const folder = path.slice(0, lastSlashIndex).split(FsaToNodeConstants.Separator);
return [folder, file];
};
export const testDirectoryIsWritable = async (dir: IFileSystemDirectoryHandle): Promise<boolean> => {
const testFileName = '__memfs_writable_test_file_' + Math.random().toString(36).slice(2) + Date.now();
try {
await dir.getFileHandle(testFileName, { create: true });
return true;
} catch {
return false;
} finally {
try {
await dir.removeEntry(testFileName);
} catch (e) {}
}
};
|