Skip to content

Commit 073b9eb

Browse files
committed
Link
1 parent ef2f053 commit 073b9eb

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,8 @@
8989

9090
stat :: forall eff. FilePath -> Eff (err :: Exception Error, fs :: FS | eff) Stats
9191

92-
truncate :: forall eff. FilePath -> Number -> Eff (err :: Exception Error, fs :: FS | eff) Unit
92+
truncate :: forall eff. FilePath -> Number -> Eff (err :: Exception Error, fs :: FS | eff) Unit
93+
94+
writeFile :: forall eff. FilePath -> Buffer -> Eff (err :: Exception Error, fs :: FS | eff) Unit
95+
96+
writeTextFile :: forall eff. Encoding -> FilePath -> String -> Eff (err :: Exception Error, fs :: FS | eff) Unit

src/Node/FS/Async.purs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ foreign import fs "var fs = require('fs');" ::
4141
, truncate :: Fn3 FilePath Number (JSCallback Unit) Unit
4242
, chown :: Fn4 FilePath Number Number (JSCallback Unit) Unit
4343
, chmod :: Fn3 FilePath Number (JSCallback Unit) Unit
44+
, stat :: Fn2 FilePath (JSCallback StatsObj) Unit
45+
, link :: Fn3 FilePath FilePath (JSCallback Unit) Unit
4446
, readFile :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit
4547
, writeFile :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit
46-
, stat :: Fn2 FilePath (JSCallback StatsObj) Unit
4748
}
4849

4950
-- |
@@ -106,6 +107,17 @@ stat :: forall eff. FilePath
106107
stat file cb = return $ runFn2
107108
fs.stat file (handleCallback $ cb <<< (<$>) Stats)
108109

110+
-- |
111+
-- Creates a link to an existing file.
112+
--
113+
link :: forall eff. FilePath
114+
-> FilePath
115+
-> Callback eff Unit
116+
-> Eff (fs :: FS | eff) Unit
117+
118+
link src dst cb = return $ runFn3
119+
fs.link src dst (handleCallback cb)
120+
109121
-- |
110122
-- Reads the entire contents of a file returning the result as a raw buffer.
111123
--

src/Node/FS/Sync.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ foreign import fs "var fs = require('fs');" ::
2626
, chownSync :: Fn3 FilePath Number Number Unit
2727
, chmodSync :: Fn2 FilePath Number Unit
2828
, statSync :: Fn1 FilePath StatsObj
29+
, linkSync :: Fn2 FilePath FilePath Unit
2930
, readFileSync :: forall a opts. Fn2 FilePath { | opts } a
3031
, writeFileSync :: forall a opts. Fn3 FilePath a { | opts } Unit
3132
}
@@ -85,6 +86,16 @@ stat :: forall eff. FilePath
8586
stat file = mkEff $ \_ -> Stats $ runFn1
8687
fs.statSync file
8788

89+
-- |
90+
-- Creates a link to an existing file.
91+
--
92+
link :: forall eff. FilePath
93+
-> FilePath
94+
-> Eff (fs :: FS, err :: Exception Error | eff) Unit
95+
96+
link src dst = mkEff $ \_ -> runFn2
97+
fs.linkSync src dst
98+
8899
-- |
89100
-- Reads the entire contents of a file returning the result as a raw buffer.
90101
--

0 commit comments

Comments
 (0)