()
| 14 | } from 'react-native-safe-area-context'; |
| 15 | |
| 16 | function FsDemo() { |
| 17 | const [info, setInfo] = useState<{ key: string; value: string }[]>([]); |
| 18 | const insets = useSafeAreaInsets(); |
| 19 | |
| 20 | useEffect(() => { |
| 21 | // Directory constants. |
| 22 | setInfo([ |
| 23 | { key: 'CacheDir', value: Dirs.CacheDir }, |
| 24 | { key: 'DatabaseDir', value: Dirs.DatabaseDir ?? '<undefined>' }, |
| 25 | { key: 'DocumentDir', value: Dirs.DocumentDir }, |
| 26 | { key: 'LibraryDir', value: Dirs.LibraryDir ?? '<undefined>' }, |
| 27 | { key: 'MainBundleDir', value: Dirs.MainBundleDir }, |
| 28 | { key: 'SDCardDir', value: Dirs.SDCardDir ?? '<undefined>' }, |
| 29 | ]); |
| 30 | |
| 31 | // Deletes and asset extraction. |
| 32 | FileSystem.unlink(Dirs.CacheDir + '/BundledData.txt') |
| 33 | .then(() => console.log('Deleted BundledData.txt')) |
| 34 | .catch(() => console.log('Did not delete BundledData.txt')) |
| 35 | .then(() => |
| 36 | FileSystem.cpAsset( |
| 37 | 'BundledData.txt', |
| 38 | Dirs.CacheDir + '/BundledData.txt' |
| 39 | ) |
| 40 | ) |
| 41 | .then(() => FileSystem.readFile(Dirs.CacheDir + '/BundledData.txt')) |
| 42 | .then((res) => |
| 43 | setInfo((prev) => { |
| 44 | prev.push({ |
| 45 | key: 'readFile(CacheDir/BundledData.txt)', |
| 46 | value: JSON.stringify(res), |
| 47 | }); |
| 48 | return prev.slice(); |
| 49 | }) |
| 50 | ); |
| 51 | |
| 52 | if (Platform.OS === 'android') { |
| 53 | FileSystem.cpAsset( |
| 54 | 'raw/android_resource', |
| 55 | Dirs.CacheDir + '/android_resource.txt', |
| 56 | 'resource' |
| 57 | ) |
| 58 | .then(() => |
| 59 | FileSystem.readFile(Dirs.CacheDir + '/android_resource.txt') |
| 60 | ) |
| 61 | .then((res) => |
| 62 | setInfo((prev) => { |
| 63 | prev.push({ |
| 64 | key: 'readFile(CacheDir/android_resource.txt)', |
| 65 | value: JSON.stringify(res), |
| 66 | }); |
| 67 | return prev.slice(); |
| 68 | }) |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | // Disk usage. |
| 73 | FileSystem.df().then((res) => |
nothing calls this directly
no test coverage detected
searching dependent graphs…