|
| 1 | +# Module Documentation |
| 2 | + |
| 3 | +## Module Node.FS.Aff |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +[Node.FS][Node.FS] Wrappers for [purescript-aff][aff] |
| 8 | + |
| 9 | +The `Aff` monad let's you write async code with ease. |
| 10 | + |
| 11 | +Consider asynchronously listing only non-hidden directories: |
| 12 | + |
| 13 | +``` purescript |
| 14 | +main = launchAff do |
| 15 | + files <- FS.readdir "." |
| 16 | + files' <- flip filterM files \file -> do |
| 17 | + stat <- FS.stat file |
| 18 | + return $ |
| 19 | + FS.isDirectory stat |
| 20 | + && (maybe false (fromChar >>> (/= ".")) $ charAt 0 file) |
| 21 | + liftEff $ Debug.Trace.trace $ show files' |
| 22 | +``` |
| 23 | + |
| 24 | +That was easy. For a working example, see [example.purs][example]. |
| 25 | +To build the example, run `gulp example`. |
| 26 | + |
| 27 | +[Node.FS]: http://github.com/purescript-node/purescript-node-fs |
| 28 | +[aff]: https://github.com/slamdata/purescript-aff |
| 29 | +[example]: http://github.com/purescript-node/purescript-node-fs-aff/blob/master/example/example.purs |
| 30 | + |
| 31 | +#### `rename` |
| 32 | + |
| 33 | +``` purescript |
| 34 | +rename :: forall eff. FilePath -> FilePath -> Aff (fs :: F.FS | eff) Unit |
| 35 | +``` |
| 36 | + |
| 37 | + |
| 38 | +Rename a file. |
| 39 | + |
| 40 | + |
| 41 | +#### `truncate` |
| 42 | + |
| 43 | +``` purescript |
| 44 | +truncate :: forall eff. FilePath -> Number -> Aff (fs :: F.FS | eff) Unit |
| 45 | +``` |
| 46 | + |
| 47 | + |
| 48 | +Truncates a file to the specified length. |
| 49 | + |
| 50 | + |
| 51 | +#### `chown` |
| 52 | + |
| 53 | +``` purescript |
| 54 | +chown :: forall eff. FilePath -> Number -> Number -> Aff (fs :: F.FS | eff) Unit |
| 55 | +``` |
| 56 | + |
| 57 | + |
| 58 | +Changes the ownership of a file. |
| 59 | + |
| 60 | + |
| 61 | +#### `chmod` |
| 62 | + |
| 63 | +``` purescript |
| 64 | +chmod :: forall eff. FilePath -> Perms -> Aff (fs :: F.FS | eff) Unit |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | +Changes the permissions of a file. |
| 69 | + |
| 70 | + |
| 71 | +#### `stat` |
| 72 | + |
| 73 | +``` purescript |
| 74 | +stat :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Stats |
| 75 | +``` |
| 76 | + |
| 77 | + |
| 78 | +Gets file statistics. |
| 79 | + |
| 80 | + |
| 81 | +#### `link` |
| 82 | + |
| 83 | +``` purescript |
| 84 | +link :: forall eff. FilePath -> FilePath -> Aff (fs :: F.FS | eff) Unit |
| 85 | +``` |
| 86 | + |
| 87 | + |
| 88 | +Creates a link to an existing file. |
| 89 | + |
| 90 | + |
| 91 | +#### `symlink` |
| 92 | + |
| 93 | +``` purescript |
| 94 | +symlink :: forall eff. FilePath -> FilePath -> F.SymlinkType -> Aff (fs :: F.FS | eff) Unit |
| 95 | +``` |
| 96 | + |
| 97 | + |
| 98 | +Creates a symlink. |
| 99 | + |
| 100 | + |
| 101 | +#### `readlink` |
| 102 | + |
| 103 | +``` purescript |
| 104 | +readlink :: forall eff. FilePath -> Aff (fs :: F.FS | eff) FilePath |
| 105 | +``` |
| 106 | + |
| 107 | + |
| 108 | +Reads the value of a symlink. |
| 109 | + |
| 110 | + |
| 111 | +#### `realpath` |
| 112 | + |
| 113 | +``` purescript |
| 114 | +realpath :: forall eff. FilePath -> Aff (fs :: F.FS | eff) FilePath |
| 115 | +``` |
| 116 | + |
| 117 | + |
| 118 | +Find the canonicalized absolute location for a path. |
| 119 | + |
| 120 | + |
| 121 | +#### `realpath'` |
| 122 | + |
| 123 | +``` purescript |
| 124 | +realpath' :: forall eff cache. FilePath -> { | cache } -> Aff (fs :: F.FS | eff) FilePath |
| 125 | +``` |
| 126 | + |
| 127 | + |
| 128 | +Find the canonicalized absolute location for a path using a cache object |
| 129 | +for already resolved paths. |
| 130 | + |
| 131 | + |
| 132 | +#### `unlink` |
| 133 | + |
| 134 | +``` purescript |
| 135 | +unlink :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Unit |
| 136 | +``` |
| 137 | + |
| 138 | + |
| 139 | +Deletes a file. |
| 140 | + |
| 141 | + |
| 142 | +#### `rmdir` |
| 143 | + |
| 144 | +``` purescript |
| 145 | +rmdir :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Unit |
| 146 | +``` |
| 147 | + |
| 148 | + |
| 149 | +Deletes a directory. |
| 150 | + |
| 151 | + |
| 152 | +#### `mkdir` |
| 153 | + |
| 154 | +``` purescript |
| 155 | +mkdir :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Unit |
| 156 | +``` |
| 157 | + |
| 158 | + |
| 159 | +Makes a new directory. |
| 160 | + |
| 161 | + |
| 162 | +#### `mkdir'` |
| 163 | + |
| 164 | +``` purescript |
| 165 | +mkdir' :: forall eff. FilePath -> Perms -> Aff (fs :: F.FS | eff) Unit |
| 166 | +``` |
| 167 | + |
| 168 | + |
| 169 | +Makes a new directory with the specified permissions. |
| 170 | + |
| 171 | + |
| 172 | +#### `readdir` |
| 173 | + |
| 174 | +``` purescript |
| 175 | +readdir :: forall eff. FilePath -> Aff (fs :: F.FS | eff) [FilePath] |
| 176 | +``` |
| 177 | + |
| 178 | + |
| 179 | +Reads the contents of a directory. |
| 180 | + |
| 181 | + |
| 182 | +#### `utimes` |
| 183 | + |
| 184 | +``` purescript |
| 185 | +utimes :: forall eff. FilePath -> Date -> Date -> Aff (fs :: F.FS | eff) Unit |
| 186 | +``` |
| 187 | + |
| 188 | + |
| 189 | +Sets the accessed and modified times for the specified file. |
| 190 | + |
| 191 | + |
| 192 | +#### `readFile` |
| 193 | + |
| 194 | +``` purescript |
| 195 | +readFile :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Buffer |
| 196 | +``` |
| 197 | + |
| 198 | + |
| 199 | +Reads the entire contents of a file returning the result as a raw buffer. |
| 200 | + |
| 201 | + |
| 202 | +#### `readTextFile` |
| 203 | + |
| 204 | +``` purescript |
| 205 | +readTextFile :: forall eff. Encoding -> FilePath -> Aff (fs :: F.FS | eff) String |
| 206 | +``` |
| 207 | + |
| 208 | + |
| 209 | +Reads the entire contents of a text file with the specified encoding. |
| 210 | + |
| 211 | + |
| 212 | +#### `writeFile` |
| 213 | + |
| 214 | +``` purescript |
| 215 | +writeFile :: forall eff. FilePath -> Buffer -> Aff (fs :: F.FS | eff) Unit |
| 216 | +``` |
| 217 | + |
| 218 | + |
| 219 | +Writes a buffer to a file. |
| 220 | + |
| 221 | + |
| 222 | +#### `writeTextFile` |
| 223 | + |
| 224 | +``` purescript |
| 225 | +writeTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: F.FS | eff) Unit |
| 226 | +``` |
| 227 | + |
| 228 | + |
| 229 | +Writes text to a file using the specified encoding. |
| 230 | + |
| 231 | + |
| 232 | +#### `appendFile` |
| 233 | + |
| 234 | +``` purescript |
| 235 | +appendFile :: forall eff. FilePath -> Buffer -> Aff (fs :: F.FS | eff) Unit |
| 236 | +``` |
| 237 | + |
| 238 | + |
| 239 | +Appends the contents of a buffer to a file. |
| 240 | + |
| 241 | + |
| 242 | +#### `appendTextFile` |
| 243 | + |
| 244 | +``` purescript |
| 245 | +appendTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: F.FS | eff) Unit |
| 246 | +``` |
| 247 | + |
| 248 | + |
| 249 | +Appends text to a file using the specified encoding. |
| 250 | + |
| 251 | + |
| 252 | +#### `exists` |
| 253 | + |
| 254 | +``` purescript |
| 255 | +exists :: forall eff. String -> Aff (fs :: F.FS | eff) Boolean |
| 256 | +``` |
| 257 | + |
| 258 | + |
| 259 | +Check to see if a file exists. |
| 260 | + |
| 261 | + |
| 262 | + |
| 263 | + |
0 commit comments