Skip to content

Commit f7b34b4

Browse files
committed
Unlink
1 parent 257d0fa commit f7b34b4

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
truncate :: forall eff. FilePath -> Number -> Callback eff Unit -> Eff (fs :: FS | eff) Unit
5454

55+
unlink :: forall eff. FilePath -> Callback eff Unit -> Eff (fs :: FS | eff) Unit
56+
5557
writeFile :: forall eff. FilePath -> Buffer -> Callback eff Unit -> Eff (fs :: FS | eff) Unit
5658

5759
writeTextFile :: forall eff. Encoding -> FilePath -> String -> Callback eff Unit -> Eff (fs :: FS | eff) Unit
@@ -123,6 +125,8 @@
123125

124126
truncate :: forall eff. FilePath -> Number -> Eff (err :: Exception Error, fs :: FS | eff) Unit
125127

128+
unlink :: forall eff. FilePath -> Eff (err :: Exception Error, fs :: FS | eff) Unit
129+
126130
writeFile :: forall eff. FilePath -> Buffer -> Eff (err :: Exception Error, fs :: FS | eff) Unit
127131

128132
writeTextFile :: forall eff. Encoding -> FilePath -> String -> Eff (err :: Exception Error, fs :: FS | eff) Unit

src/Node/FS/Async.purs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Node.FS.Async
1010
, readlink
1111
, realpath
1212
, realpath'
13+
, unlink
1314
, readFile
1415
, readTextFile
1516
, writeFile
@@ -51,6 +52,7 @@ foreign import fs "var fs = require('fs');" ::
5152
, symlink :: Fn4 FilePath FilePath String (JSCallback Unit) Unit
5253
, readlink :: Fn2 FilePath (JSCallback FilePath) Unit
5354
, realpath :: forall cache. Fn3 FilePath { | cache } (JSCallback FilePath) Unit
55+
, unlink :: Fn2 FilePath (JSCallback Unit) Unit
5456
, readFile :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit
5557
, writeFile :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit
5658
}
@@ -125,7 +127,7 @@ link :: forall eff. FilePath
125127

126128
link src dst cb = return $ runFn3
127129
fs.link src dst (handleCallback cb)
128-
130+
129131
-- |
130132
-- Creates a symlink.
131133
--
@@ -157,7 +159,7 @@ realpath :: forall eff. FilePath
157159

158160
realpath path cb = return $ runFn3
159161
fs.realpath path {} (handleCallback cb)
160-
162+
161163
-- |
162164
-- Find the canonicalized absolute location for a path using a cache object for
163165
-- already resolved paths.
@@ -170,6 +172,16 @@ realpath' :: forall eff cache. FilePath
170172
realpath' path cache cb = return $ runFn3
171173
fs.realpath path cache (handleCallback cb)
172174

175+
-- |
176+
-- Deletes a file.
177+
--
178+
unlink :: forall eff. FilePath
179+
-> Callback eff Unit
180+
-> Eff (fs :: FS | eff) Unit
181+
182+
unlink file cb = return $ runFn2
183+
fs.unlink file (handleCallback cb)
184+
173185
-- |
174186
-- Reads the entire contents of a file returning the result as a raw buffer.
175187
--

src/Node/FS/Sync.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Node.FS.Sync
99
, readlink
1010
, realpath
1111
, realpath'
12+
, unlink
1213
, readFile
1314
, readTextFile
1415
, writeFile
@@ -35,6 +36,7 @@ foreign import fs "var fs = require('fs');" ::
3536
, symlinkSync :: Fn3 FilePath FilePath String Unit
3637
, readlinkSync :: Fn1 FilePath FilePath
3738
, realpathSync :: forall cache. Fn2 FilePath { | cache } FilePath
39+
, unlinkSync :: Fn1 FilePath Unit
3840
, readFileSync :: forall a opts. Fn2 FilePath { | opts } a
3941
, writeFileSync :: forall a opts. Fn3 FilePath a { | opts } Unit
4042
}
@@ -144,6 +146,15 @@ realpath' :: forall eff cache. FilePath
144146
realpath' path cache = mkEff $ \_ -> runFn2
145147
fs.realpathSync path cache
146148

149+
-- |
150+
-- Deletes a file.
151+
--
152+
unlink :: forall eff. FilePath
153+
-> Eff (fs :: FS, err :: Exception Error | eff) Unit
154+
155+
unlink file = mkEff $ \_ -> runFn1
156+
fs.unlinkSync file
157+
147158
-- |
148159
-- Reads the entire contents of a file returning the result as a raw buffer.
149160
--

0 commit comments

Comments
 (0)