Skip to content

Commit cff7baa

Browse files
committed
Readlink
1 parent 83b8771 commit cff7baa

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Node/FS/Async.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ foreign import fs "var fs = require('fs');" ::
4444
, stat :: Fn2 FilePath (JSCallback StatsObj) Unit
4545
, link :: Fn3 FilePath FilePath (JSCallback Unit) Unit
4646
, symlink :: Fn4 FilePath FilePath String (JSCallback Unit) Unit
47+
, readlink :: Fn2 FilePath (JSCallback FilePath) Unit
4748
, readFile :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit
4849
, writeFile :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit
4950
}
@@ -131,6 +132,16 @@ symlink :: forall eff. FilePath
131132
symlink src dest ty cb = return $ runFn4
132133
fs.symlink src dest (show ty) (handleCallback cb)
133134

135+
-- |
136+
-- Reads the value of a symlink.
137+
--
138+
readlink :: forall eff. FilePath
139+
-> Callback eff FilePath
140+
-> Eff (fs :: FS | eff) Unit
141+
142+
readlink path cb = return $ runFn2
143+
fs.readlink path (handleCallback cb)
144+
134145
-- |
135146
-- Reads the entire contents of a file returning the result as a raw buffer.
136147
--

src/Node/FS/Sync.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ foreign import fs "var fs = require('fs');" ::
2828
, statSync :: Fn1 FilePath StatsObj
2929
, linkSync :: Fn2 FilePath FilePath Unit
3030
, symlinkSync :: Fn3 FilePath FilePath String Unit
31+
, readlinkSync :: Fn1 FilePath FilePath
3132
, readFileSync :: forall a opts. Fn2 FilePath { | opts } a
3233
, writeFileSync :: forall a opts. Fn3 FilePath a { | opts } Unit
3334
}
@@ -108,6 +109,15 @@ symlink :: forall eff. FilePath
108109
symlink src dst ty = mkEff $ \_ -> runFn3
109110
fs.symlinkSync src dst (show ty)
110111

112+
-- |
113+
-- Reads the value of a symlink.
114+
--
115+
readlink :: forall eff. FilePath
116+
-> Eff (fs :: FS, err :: Exception Error | eff) FilePath
117+
118+
readlink path = mkEff $ \_ -> runFn1
119+
fs.readlinkSync path
120+
111121
-- |
112122
-- Reads the entire contents of a file returning the result as a raw buffer.
113123
--

0 commit comments

Comments
 (0)