2023-06-14 14:24:55 +00:00
|
|
|
(ns react-native.fs
|
2019-09-07 12:57:22 +00:00
|
|
|
(:require ["react-native-fs" :as react-native-fs]))
|
2016-07-18 16:29:51 +00:00
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn move-file
|
|
|
|
[src dst]
|
2019-09-07 12:57:22 +00:00
|
|
|
(.moveFile react-native-fs src dst))
|
2016-08-01 10:29:10 +00:00
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn stat
|
|
|
|
[path on-stat on-error]
|
2020-07-28 11:06:58 +00:00
|
|
|
(-> (.stat react-native-fs path)
|
|
|
|
(.then on-stat)
|
|
|
|
(.catch on-error)))
|
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn read-file
|
|
|
|
[path encoding on-read on-error]
|
2019-09-07 12:57:22 +00:00
|
|
|
(-> (.readFile react-native-fs path encoding)
|
2016-08-01 10:29:10 +00:00
|
|
|
(.then on-read)
|
2016-10-24 20:46:06 +00:00
|
|
|
(.catch on-error)))
|
2018-06-21 18:08:10 +00:00
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn write-file
|
|
|
|
[path content encoding on-write on-error]
|
2021-08-30 22:51:19 +00:00
|
|
|
(-> (.writeFile react-native-fs path content encoding)
|
|
|
|
(.then on-write)
|
|
|
|
(.catch on-error)))
|
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn read-dir
|
|
|
|
[path]
|
2019-09-07 12:57:22 +00:00
|
|
|
(.readDir react-native-fs path))
|
2018-07-11 19:52:53 +00:00
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn mkdir
|
|
|
|
[path]
|
2019-09-07 12:57:22 +00:00
|
|
|
(.mkdir react-native-fs path))
|
2018-07-11 19:52:53 +00:00
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn unlink
|
|
|
|
[path]
|
2019-09-07 12:57:22 +00:00
|
|
|
(.unlink react-native-fs path))
|
2018-11-26 15:52:29 +00:00
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn file-exists?
|
|
|
|
[path]
|
2019-09-07 12:57:22 +00:00
|
|
|
(.exists react-native-fs path))
|
2021-08-30 22:51:19 +00:00
|
|
|
|
2022-12-20 14:45:37 +00:00
|
|
|
(defn cache-dir
|
|
|
|
[]
|
2021-08-30 22:51:19 +00:00
|
|
|
(.-CachesDirectoryPath ^js react-native-fs))
|