mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-27 09:09:29 +01:00
20 lines
455 B
TypeScript
20 lines
455 B
TypeScript
import RNFS from 'react-native-fs'
|
|
|
|
export async function mkdir(path: string): Promise<void> {
|
|
const exists = await RNFS.exists(path)
|
|
if (exists) {
|
|
const isDir = (await RNFS.stat(path)).isDirectory()
|
|
if (!isDir) {
|
|
throw new Error(`path exists and is not a directory: ${path}`)
|
|
} else {
|
|
return
|
|
}
|
|
}
|
|
|
|
return await RNFS.mkdir(path)
|
|
}
|
|
|
|
export async function rmdir(path: string): Promise<void> {
|
|
return RNFS.unlink(path)
|
|
}
|