|
|
|
@ -97,37 +97,37 @@ export class StorageItem { |
|
|
|
return (item.handle as any).entries(); |
|
|
|
} |
|
|
|
|
|
|
|
public static async createFile(item: StorageItem, name: string) : Promise<any | null> { |
|
|
|
public static async createFile(item: StorageItem, name: string): Promise<any | null> { |
|
|
|
if (item.kind !== "directory" || !item.handle) { |
|
|
|
throw new TypeError("Unable to create item in the requested directory"); |
|
|
|
} |
|
|
|
|
|
|
|
await item.verityPermissions("readwrite"); |
|
|
|
|
|
|
|
return await (item.handle as any).getFileHandle(name, { create: true }); |
|
|
|
return await ((item.handle as any).getFileHandle(name, { create: true }) as Promise<any>); |
|
|
|
} |
|
|
|
|
|
|
|
public static async createFolder(item: StorageItem, name: string) : Promise<any | null> { |
|
|
|
public static async createFolder(item: StorageItem, name: string): Promise<any | null> { |
|
|
|
if (item.kind !== "directory" || !item.handle) { |
|
|
|
throw new TypeError("Unable to create item in the requested directory"); |
|
|
|
} |
|
|
|
|
|
|
|
await item.verityPermissions("readwrite"); |
|
|
|
|
|
|
|
return await (item.handle as any).getDirectoryHandle(name, { create: true }); |
|
|
|
return await ((item.handle as any).getDirectoryHandle(name, { create: true }) as Promise<any>); |
|
|
|
} |
|
|
|
|
|
|
|
public static async deleteAsync(item: StorageItem) : Promise<any | null> { |
|
|
|
public static async deleteAsync(item: StorageItem): Promise<any | null> { |
|
|
|
if (!item.handle) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
await item.verityPermissions("readwrite"); |
|
|
|
|
|
|
|
return await (item.handle as any).remove({recursive: true}); |
|
|
|
return await ((item.handle as any).remove({ recursive: true }) as Promise<any>); |
|
|
|
} |
|
|
|
|
|
|
|
public static async moveAsync(item: StorageItem, destination: StorageItem) : Promise<any | null> { |
|
|
|
public static async moveAsync(item: StorageItem, destination: StorageItem): Promise<any | null> { |
|
|
|
if (!item.handle) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
@ -137,7 +137,7 @@ export class StorageItem { |
|
|
|
|
|
|
|
await item.verityPermissions("readwrite"); |
|
|
|
|
|
|
|
return await (item.handle as any).move(destination /*, newName */); |
|
|
|
return await ((item.handle as any).move(destination /*, newName */) as Promise<any>); |
|
|
|
} |
|
|
|
|
|
|
|
private async verityPermissions(mode: "read" | "readwrite"): Promise<void | never> { |
|
|
|
|