From e758dad5322e2037a2f8d719c10f15c0f692d2dc Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:45:11 +0000 Subject: [PATCH 01/16] Migrated FFI to ES modules via 'lebab' --- src/Node/FS/Async.js | 4 ++-- src/Node/FS/Internal.js | 2 +- src/Node/FS/Stats.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Node/FS/Async.js b/src/Node/FS/Async.js index e1f1ba9..25442b7 100644 --- a/src/Node/FS/Async.js +++ b/src/Node/FS/Async.js @@ -1,6 +1,6 @@ "use strict"; -exports.handleCallbackImpl = function (left, right, f) { +export function handleCallbackImpl(left, right, f) { return function (err, value) { if (err) { f(left(err))(); @@ -8,4 +8,4 @@ exports.handleCallbackImpl = function (left, right, f) { f(right(value))(); } }; -}; +} diff --git a/src/Node/FS/Internal.js b/src/Node/FS/Internal.js index 0bced8a..ed2801d 100644 --- a/src/Node/FS/Internal.js +++ b/src/Node/FS/Internal.js @@ -1,3 +1,3 @@ "use strict"; -exports.unsafeRequireFS = require("fs"); +export var unsafeRequireFS = require("fs"); diff --git a/src/Node/FS/Stats.js b/src/Node/FS/Stats.js index 31a1bc9..8ad4529 100644 --- a/src/Node/FS/Stats.js +++ b/src/Node/FS/Stats.js @@ -1,7 +1,7 @@ "use strict"; -exports.showStatsObj = require("util").inspect; +export var showStatsObj = require("util").inspect; -exports.statsMethod = function (m, s) { +export function statsMethod(m, s) { return s[m](); -}; +} From 94b85ef74d1b213b58090e8ba742fc2f8584c109 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:45:11 +0000 Subject: [PATCH 02/16] Replaced 'export var' with 'export const' --- src/Node/FS/Internal.js | 2 +- src/Node/FS/Stats.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Node/FS/Internal.js b/src/Node/FS/Internal.js index ed2801d..ab8e851 100644 --- a/src/Node/FS/Internal.js +++ b/src/Node/FS/Internal.js @@ -1,3 +1,3 @@ "use strict"; -export var unsafeRequireFS = require("fs"); +export const unsafeRequireFS = require("fs"); diff --git a/src/Node/FS/Stats.js b/src/Node/FS/Stats.js index 8ad4529..d30b8f2 100644 --- a/src/Node/FS/Stats.js +++ b/src/Node/FS/Stats.js @@ -1,6 +1,6 @@ "use strict"; -export var showStatsObj = require("util").inspect; +export const showStatsObj = require("util").inspect; export function statsMethod(m, s) { return s[m](); From 6fb6cd21e587c9ee64f89912669f7d5cf46dccab Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:45:11 +0000 Subject: [PATCH 03/16] Removed '"use strict";' in FFI files --- src/Node/FS/Async.js | 2 -- src/Node/FS/Internal.js | 2 -- src/Node/FS/Stats.js | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/Node/FS/Async.js b/src/Node/FS/Async.js index 25442b7..e3f9a5a 100644 --- a/src/Node/FS/Async.js +++ b/src/Node/FS/Async.js @@ -1,5 +1,3 @@ -"use strict"; - export function handleCallbackImpl(left, right, f) { return function (err, value) { if (err) { diff --git a/src/Node/FS/Internal.js b/src/Node/FS/Internal.js index ab8e851..3fb4c19 100644 --- a/src/Node/FS/Internal.js +++ b/src/Node/FS/Internal.js @@ -1,3 +1 @@ -"use strict"; - export const unsafeRequireFS = require("fs"); diff --git a/src/Node/FS/Stats.js b/src/Node/FS/Stats.js index d30b8f2..d95017b 100644 --- a/src/Node/FS/Stats.js +++ b/src/Node/FS/Stats.js @@ -1,5 +1,3 @@ -"use strict"; - export const showStatsObj = require("util").inspect; export function statsMethod(m, s) { From 67675f4e2e067931f8c199f19e69b2866678a26a Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:45:11 +0000 Subject: [PATCH 04/16] Update to CI to use 'unstable' purescript --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 063845e..f5a96fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: - uses: actions/checkout@v2 - uses: purescript-contrib/setup-purescript@main + with: + purescript: "unstable" - uses: actions/setup-node@v1 with: From 844a4f5f94885ec0e096570b44a4b2b41de7636e Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:45:11 +0000 Subject: [PATCH 05/16] Update Bower dependencies to master or main --- bower.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bower.json b/bower.json index e7d45e8..0619925 100644 --- a/bower.json +++ b/bower.json @@ -20,26 +20,26 @@ "package.json" ], "dependencies": { - "purescript-datetime": "^5.0.0", - "purescript-effect": "^3.0.0", - "purescript-either": "^5.0.0", - "purescript-enums": "^5.0.0", - "purescript-exceptions": "^5.0.0", - "purescript-functions": "^5.0.0", - "purescript-integers": "^5.0.0", - "purescript-js-date": "^7.0.0", - "purescript-maybe": "^5.0.0", + "purescript-datetime": "master", + "purescript-effect": "master", + "purescript-either": "master", + "purescript-enums": "master", + "purescript-exceptions": "master", + "purescript-functions": "master", + "purescript-integers": "master", + "purescript-js-date": "main", + "purescript-maybe": "master", "purescript-node-buffer": "^7.0.0", "purescript-node-path": "^4.0.0", "purescript-node-streams": "^5.0.0", - "purescript-nullable": "^5.0.0", - "purescript-partial": "^3.0.0", - "purescript-prelude": "^5.0.0", - "purescript-strings": "^5.0.0", - "purescript-unsafe-coerce": "^5.0.0" + "purescript-nullable": "main", + "purescript-partial": "master", + "purescript-prelude": "master", + "purescript-strings": "master", + "purescript-unsafe-coerce": "master" }, "devDependencies": { - "purescript-console": "^5.0.0", + "purescript-console": "master", "purescript-node-buffer": "^7.0.0" } } From 1a64f930ce08c9d67c9d94b1c7ca487432df31e7 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:45:11 +0000 Subject: [PATCH 06/16] Update pulp to 16.0.0-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 63f9f51..784caa5 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "devDependencies": { "eslint": "^7.15.0", - "pulp": "^15.0.0", + "pulp": "16.0.0-0", "purescript-psa": "^0.8.0", "rimraf": "^3.0.2" } From 92d742cb1d650b1ffa1c5e57121013c3aa1a79d1 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:45:11 +0000 Subject: [PATCH 07/16] Update psa to 0.8.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 784caa5..c08ce8f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "devDependencies": { "eslint": "^7.15.0", "pulp": "16.0.0-0", - "purescript-psa": "^0.8.0", + "purescript-psa": "^0.8.2", "rimraf": "^3.0.2" } } From 7e51c39113d770926a79d397f87b5127c1eb187c Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:47:50 +0000 Subject: [PATCH 08/16] Add eslint config --- .eslintrc.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 84cef4f..7b219e5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,10 +1,11 @@ { "parserOptions": { - "ecmaVersion": 5 + "ecmaVersion": 6, + "sourceType": "module" }, "extends": "eslint:recommended", "env": { - "commonjs": true + "node": true }, "rules": { "strict": [2, "global"], From b702565c29e27353e833b4f8ead50587f8c91407 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:47:57 +0000 Subject: [PATCH 09/16] Update ci.yml to v2 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5a96fe..06ed895 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,9 +16,9 @@ jobs: with: purescript: "unstable" - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: - node-version: "10" + node-version: "14" - name: Install dependencies run: | From ac365d1f83710175aaa008bbad788587a42f42db Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:51:31 +0000 Subject: [PATCH 10/16] Update Bower dependencies to master or main --- bower.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index 0619925..ccbc2cb 100644 --- a/bower.json +++ b/bower.json @@ -29,9 +29,9 @@ "purescript-integers": "master", "purescript-js-date": "main", "purescript-maybe": "master", - "purescript-node-buffer": "^7.0.0", - "purescript-node-path": "^4.0.0", - "purescript-node-streams": "^5.0.0", + "purescript-node-buffer": "master", + "purescript-node-path": "master", + "purescript-node-streams": "master", "purescript-nullable": "main", "purescript-partial": "master", "purescript-prelude": "master", From 27ede603f7c41f0226f9110716e526c8616b898f Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 21:52:50 +0000 Subject: [PATCH 11/16] Update Bower dependencies to master or main --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index ccbc2cb..eae3ea9 100644 --- a/bower.json +++ b/bower.json @@ -40,6 +40,6 @@ }, "devDependencies": { "purescript-console": "master", - "purescript-node-buffer": "^7.0.0" + "purescript-node-buffer": "master" } } From 8ccb1f08ee32e1d9e6ce2ed0dd47a742afb945bd Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Tue, 22 Mar 2022 22:38:13 +0000 Subject: [PATCH 12/16] Refactor unsafeRequireFS --- src/Node/FS/Async.js | 25 +++++++++ src/Node/FS/Async.purs | 105 ++++++++++++++++++------------------ src/Node/FS/Internal.js | 1 - src/Node/FS/Internal.purs | 2 - src/Node/FS/Stats.js | 2 +- src/Node/FS/Stream.js | 4 ++ src/Node/FS/Stream.purs | 18 +++---- src/Node/FS/Sync.js | 25 +++++++++ src/Node/FS/Sync.purs | 111 +++++++++++++++++++------------------- 9 files changed, 170 insertions(+), 123 deletions(-) delete mode 100644 src/Node/FS/Internal.js create mode 100644 src/Node/FS/Stream.js create mode 100644 src/Node/FS/Sync.js diff --git a/src/Node/FS/Async.js b/src/Node/FS/Async.js index e3f9a5a..93ab025 100644 --- a/src/Node/FS/Async.js +++ b/src/Node/FS/Async.js @@ -1,3 +1,28 @@ +export { + rename as rename_, + truncate as truncate_, + chown as chown_, + chmod as chmod_, + stat as stat_, + link as link_, + symlink as symlink_, + readlink as readlink_, + realpath as realpath_, + unlink as unlink_, + rmdir as rmdir_, + mkdir as mkdir_, + readdir as readdir_, + utimes as utimes_, + readFile as readFile_, + writeFile as writeFile_, + appendFile as appendFile_, + exists as exists_, + open as open_, + read as read_, + write as write_, + close as close_ +} from "fs"; + export function handleCallbackImpl(left, right, f) { return function (err, value) { if (err) { diff --git a/src/Node/FS/Async.purs b/src/Node/FS/Async.purs index 77f9c10..b94c326 100644 --- a/src/Node/FS/Async.purs +++ b/src/Node/FS/Async.purs @@ -48,7 +48,7 @@ import Effect.Unsafe (unsafePerformEffect) import Node.Buffer (Buffer, size) import Node.Encoding (Encoding) import Node.FS (FileDescriptor, ByteCount, FilePosition, BufferLength, BufferOffset, FileMode, FileFlags, SymlinkType, fileFlagsToNode, symlinkTypeToNode) -import Node.FS.Internal (mkEffect, unsafeRequireFS) +import Node.FS.Internal (mkEffect) import Node.FS.Perms (Perms, permsToString, all, mkPerms) import Node.FS.Stats (StatsObj, Stats(..)) import Node.Path (FilePath) @@ -64,42 +64,41 @@ foreign import handleCallbackImpl :: handleCallback :: forall a. (Callback a) -> JSCallback a handleCallback cb = runFn3 handleCallbackImpl Left Right cb -fs :: - { rename :: Fn3 FilePath FilePath (JSCallback Unit) Unit - , truncate :: Fn3 FilePath Int (JSCallback Unit) Unit - , chown :: Fn4 FilePath Int Int (JSCallback Unit) Unit - , chmod :: Fn3 FilePath String (JSCallback Unit) Unit - , stat :: Fn2 FilePath (JSCallback StatsObj) Unit - , link :: Fn3 FilePath FilePath (JSCallback Unit) Unit - , symlink :: Fn4 FilePath FilePath String (JSCallback Unit) Unit - , readlink :: Fn2 FilePath (JSCallback FilePath) Unit - , realpath :: forall cache. Fn3 FilePath { | cache } (JSCallback FilePath) Unit - , unlink :: Fn2 FilePath (JSCallback Unit) Unit - , rmdir :: Fn2 FilePath (JSCallback Unit) Unit - , mkdir :: Fn3 FilePath { recursive :: Boolean, mode :: String } (JSCallback Unit) Unit - , readdir :: Fn2 FilePath (JSCallback (Array FilePath)) Unit - , utimes :: Fn4 FilePath Int Int (JSCallback Unit) Unit - , readFile :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit - , writeFile :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit - , appendFile :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit - , exists :: forall a. Fn2 FilePath (Boolean -> a) Unit - , open :: Fn4 FilePath String (Nullable FileMode) (JSCallback FileDescriptor) Unit - , read :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit - , write :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit - , close :: Fn2 FileDescriptor (JSCallback Unit) Unit - } -fs = unsafeRequireFS -- | Type synonym for callback functions. type Callback a = Either Error a -> Effect Unit +foreign import rename_ :: Fn3 FilePath FilePath (JSCallback Unit) Unit +foreign import truncate_ :: Fn3 FilePath Int (JSCallback Unit) Unit +foreign import chown_ :: Fn4 FilePath Int Int (JSCallback Unit) Unit +foreign import chmod_ :: Fn3 FilePath String (JSCallback Unit) Unit +foreign import stat_ :: Fn2 FilePath (JSCallback StatsObj) Unit +foreign import link_ :: Fn3 FilePath FilePath (JSCallback Unit) Unit +foreign import symlink_ :: Fn4 FilePath FilePath String (JSCallback Unit) Unit +foreign import readlink_ :: Fn2 FilePath (JSCallback FilePath) Unit +foreign import realpath_ :: forall cache. Fn3 FilePath { | cache } (JSCallback FilePath) Unit +foreign import unlink_ :: Fn2 FilePath (JSCallback Unit) Unit +foreign import rmdir_ :: Fn2 FilePath (JSCallback Unit) Unit +foreign import mkdir_ :: Fn3 FilePath { recursive :: Boolean, mode :: String } (JSCallback Unit) Unit +foreign import readdir_ :: Fn2 FilePath (JSCallback (Array FilePath)) Unit +foreign import utimes_ :: Fn4 FilePath Int Int (JSCallback Unit) Unit +foreign import readFile_ :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit +foreign import writeFile_ :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit +foreign import appendFile_ :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit +foreign import exists_ :: forall a. Fn2 FilePath (Boolean -> a) Unit +foreign import open_ :: Fn4 FilePath String (Nullable FileMode) (JSCallback FileDescriptor) Unit +foreign import read_ :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit +foreign import write_ :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit +foreign import close_ :: Fn2 FileDescriptor (JSCallback Unit) Unit + + -- | Renames a file. rename :: FilePath -> FilePath -> Callback Unit -> Effect Unit rename oldFile newFile cb = mkEffect $ \_ -> runFn3 - fs.rename oldFile newFile (handleCallback cb) + rename_ oldFile newFile (handleCallback cb) -- | Truncates a file to the specified length. truncate :: FilePath @@ -108,7 +107,7 @@ truncate :: FilePath -> Effect Unit truncate file len cb = mkEffect $ \_ -> runFn3 - fs.truncate file len (handleCallback cb) + truncate_ file len (handleCallback cb) -- | Changes the ownership of a file. chown :: FilePath @@ -118,7 +117,7 @@ chown :: FilePath -> Effect Unit chown file uid gid cb = mkEffect $ \_ -> runFn4 - fs.chown file uid gid (handleCallback cb) + chown_ file uid gid (handleCallback cb) -- | Changes the permissions of a file. chmod :: FilePath @@ -127,7 +126,7 @@ chmod :: FilePath -> Effect Unit chmod file perms cb = mkEffect $ \_ -> runFn3 - fs.chmod file (permsToString perms) (handleCallback cb) + chmod_ file (permsToString perms) (handleCallback cb) -- | Gets file statistics. stat :: FilePath @@ -135,7 +134,7 @@ stat :: FilePath -> Effect Unit stat file cb = mkEffect $ \_ -> runFn2 - fs.stat file (handleCallback $ cb <<< (<$>) Stats) + stat_ file (handleCallback $ cb <<< (<$>) Stats) -- | Creates a link to an existing file. link :: FilePath @@ -144,7 +143,7 @@ link :: FilePath -> Effect Unit link src dst cb = mkEffect $ \_ -> runFn3 - fs.link src dst (handleCallback cb) + link_ src dst (handleCallback cb) -- | Creates a symlink. symlink :: FilePath @@ -154,7 +153,7 @@ symlink :: FilePath -> Effect Unit symlink src dest ty cb = mkEffect $ \_ -> runFn4 - fs.symlink src dest (symlinkTypeToNode ty) (handleCallback cb) + symlink_ src dest (symlinkTypeToNode ty) (handleCallback cb) -- | Reads the value of a symlink. readlink :: FilePath @@ -162,7 +161,7 @@ readlink :: FilePath -> Effect Unit readlink path cb = mkEffect $ \_ -> runFn2 - fs.readlink path (handleCallback cb) + readlink_ path (handleCallback cb) -- | Find the canonicalized absolute location for a path. realpath :: FilePath @@ -170,7 +169,7 @@ realpath :: FilePath -> Effect Unit realpath path cb = mkEffect $ \_ -> runFn3 - fs.realpath path {} (handleCallback cb) + realpath_ path {} (handleCallback cb) -- | Find the canonicalized absolute location for a path using a cache object -- | for already resolved paths. @@ -180,7 +179,7 @@ realpath' :: forall cache. FilePath -> Effect Unit realpath' path cache cb = mkEffect $ \_ -> runFn3 - fs.realpath path cache (handleCallback cb) + realpath_ path cache (handleCallback cb) -- | Deletes a file. unlink :: FilePath @@ -188,7 +187,7 @@ unlink :: FilePath -> Effect Unit unlink file cb = mkEffect $ \_ -> runFn2 - fs.unlink file (handleCallback cb) + unlink_ file (handleCallback cb) -- | Deletes a directory. rmdir :: FilePath @@ -196,7 +195,7 @@ rmdir :: FilePath -> Effect Unit rmdir file cb = mkEffect $ \_ -> runFn2 - fs.rmdir file (handleCallback cb) + rmdir_ file (handleCallback cb) -- | Makes a new directory. mkdir :: FilePath @@ -221,7 +220,7 @@ mkdirRecursive' -> Callback Unit -> Effect Unit mkdirRecursive' file perms cb = mkEffect $ \_ -> runFn3 - fs.mkdir file { recursive: true, mode: permsToString perms } (handleCallback cb) + mkdir_ file { recursive: true, mode: permsToString perms } (handleCallback cb) -- | Makes a new directory with the specified permissions. mkdir' :: FilePath @@ -229,7 +228,7 @@ mkdir' :: FilePath -> Callback Unit -> Effect Unit mkdir' file perms cb = mkEffect $ \_ -> runFn3 - fs.mkdir file { recursive: false, mode: permsToString perms } (handleCallback cb) + mkdir_ file { recursive: false, mode: permsToString perms } (handleCallback cb) -- | Reads the contents of a directory. readdir :: FilePath @@ -237,7 +236,7 @@ readdir :: FilePath -> Effect Unit readdir file cb = mkEffect $ \_ -> runFn2 - fs.readdir file (handleCallback cb) + readdir_ file (handleCallback cb) -- | Sets the accessed and modified times for the specified file. utimes :: FilePath @@ -247,7 +246,7 @@ utimes :: FilePath -> Effect Unit utimes file atime mtime cb = mkEffect $ \_ -> runFn4 - fs.utimes file + utimes_ file (fromDate atime) (fromDate mtime) (handleCallback cb) @@ -262,7 +261,7 @@ readFile :: FilePath -> Effect Unit readFile file cb = mkEffect $ \_ -> runFn3 - fs.readFile file {} (handleCallback cb) + readFile_ file {} (handleCallback cb) -- | Reads the entire contents of a text file with the specified encoding. readTextFile :: Encoding @@ -271,7 +270,7 @@ readTextFile :: Encoding -> Effect Unit readTextFile encoding file cb = mkEffect $ \_ -> runFn3 - fs.readFile file { encoding: show encoding } (handleCallback cb) + readFile_ file { encoding: show encoding } (handleCallback cb) -- | Writes a buffer to a file. writeFile :: FilePath @@ -280,7 +279,7 @@ writeFile :: FilePath -> Effect Unit writeFile file buff cb = mkEffect $ \_ -> runFn4 - fs.writeFile file buff {} (handleCallback cb) + writeFile_ file buff {} (handleCallback cb) -- | Writes text to a file using the specified encoding. writeTextFile :: Encoding @@ -290,7 +289,7 @@ writeTextFile :: Encoding -> Effect Unit writeTextFile encoding file buff cb = mkEffect $ \_ -> runFn4 - fs.writeFile file buff { encoding: show encoding } (handleCallback cb) + writeFile_ file buff { encoding: show encoding } (handleCallback cb) -- | Appends the contents of a buffer to a file. appendFile :: FilePath @@ -299,7 +298,7 @@ appendFile :: FilePath -> Effect Unit appendFile file buff cb = mkEffect $ \_ -> runFn4 - fs.appendFile file buff {} (handleCallback cb) + appendFile_ file buff {} (handleCallback cb) -- | Appends text to a file using the specified encoding. appendTextFile :: Encoding @@ -309,14 +308,14 @@ appendTextFile :: Encoding -> Effect Unit appendTextFile encoding file buff cb = mkEffect $ \_ -> runFn4 - fs.appendFile file buff { encoding: show encoding } (handleCallback cb) + appendFile_ file buff { encoding: show encoding } (handleCallback cb) -- | Check if the path exists. exists :: FilePath -> (Boolean -> Effect Unit) -> Effect Unit exists file cb = mkEffect $ \_ -> runFn2 - fs.exists file $ \b -> unsafePerformEffect (cb b) + exists_ file $ \b -> unsafePerformEffect (cb b) -- | Open a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback) -- | for details. @@ -325,7 +324,7 @@ fdOpen :: FilePath -> Maybe FileMode -> Callback FileDescriptor -> Effect Unit -fdOpen file flags mode cb = mkEffect $ \_ -> runFn4 fs.open file (fileFlagsToNode flags) (toNullable mode) (handleCallback cb) +fdOpen file flags mode cb = mkEffect $ \_ -> runFn4 open_ file (fileFlagsToNode flags) (toNullable mode) (handleCallback cb) -- | Read from a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback) -- | for details. @@ -336,7 +335,7 @@ fdRead :: FileDescriptor -> Maybe FilePosition -> Callback ByteCount -> Effect Unit -fdRead fd buff off len pos cb = mkEffect $ \_ -> runFn6 fs.read fd buff off len (toNullable pos) (handleCallback cb) +fdRead fd buff off len pos cb = mkEffect $ \_ -> runFn6 read_ fd buff off len (toNullable pos) (handleCallback cb) -- | Convenience function to fill the whole buffer from the current -- | file position. @@ -357,7 +356,7 @@ fdWrite :: FileDescriptor -> Maybe FilePosition -> Callback ByteCount -> Effect Unit -fdWrite fd buff off len pos cb = mkEffect $ \_ -> runFn6 fs.write fd buff off len (toNullable pos) (handleCallback cb) +fdWrite fd buff off len pos cb = mkEffect $ \_ -> runFn6 write_ fd buff off len (toNullable pos) (handleCallback cb) -- | Convenience function to append the whole buffer to the current -- | file position. @@ -374,4 +373,4 @@ fdAppend fd buff cb = do fdClose :: FileDescriptor -> Callback Unit -> Effect Unit -fdClose fd cb = mkEffect $ \_ -> runFn2 fs.close fd (handleCallback cb) +fdClose fd cb = mkEffect $ \_ -> runFn2 close_ fd (handleCallback cb) diff --git a/src/Node/FS/Internal.js b/src/Node/FS/Internal.js deleted file mode 100644 index 3fb4c19..0000000 --- a/src/Node/FS/Internal.js +++ /dev/null @@ -1 +0,0 @@ -export const unsafeRequireFS = require("fs"); diff --git a/src/Node/FS/Internal.purs b/src/Node/FS/Internal.purs index 4277aa8..ea21e6b 100644 --- a/src/Node/FS/Internal.purs +++ b/src/Node/FS/Internal.purs @@ -8,5 +8,3 @@ import Unsafe.Coerce (unsafeCoerce) mkEffect :: forall a. (Unit -> a) -> Effect a mkEffect = unsafeCoerce - -foreign import unsafeRequireFS :: forall props. { | props } diff --git a/src/Node/FS/Stats.js b/src/Node/FS/Stats.js index d95017b..e6e6148 100644 --- a/src/Node/FS/Stats.js +++ b/src/Node/FS/Stats.js @@ -1,4 +1,4 @@ -export const showStatsObj = require("util").inspect; +export { inspect as showStatsObj } from "util"; export function statsMethod(m, s) { return s[m](); diff --git a/src/Node/FS/Stream.js b/src/Node/FS/Stream.js new file mode 100644 index 0000000..1440085 --- /dev/null +++ b/src/Node/FS/Stream.js @@ -0,0 +1,4 @@ +export { + createReadStream as createReadStream_, + createWriteStream as createWriteStream_ +} from "fs"; diff --git a/src/Node/FS/Stream.purs b/src/Node/FS/Stream.purs index ebb653c..53894a7 100644 --- a/src/Node/FS/Stream.purs +++ b/src/Node/FS/Stream.purs @@ -24,13 +24,11 @@ import Node.Path (FilePath()) import Node.FS (FileDescriptor, FileFlags(..), fileFlagsToNode) import Node.FS.Perms (Perms()) import Node.FS.Perms as Perms -import Node.FS.Internal (mkEffect, unsafeRequireFS) +import Node.FS.Internal (mkEffect) +import Node.FS.Internal as FS -fs :: - { createReadStream :: forall opts. Fn2 (Nullable FilePath) { | opts } (Readable ()) - , createWriteStream :: forall opts. Fn2 (Nullable FilePath) { | opts } (Writable ()) - } -fs = unsafeRequireFS +foreign import createReadStream_ :: forall opts. Fn2 (Nullable FilePath) { | opts } (Readable ()) +foreign import createWriteStream_ :: forall opts. Fn2 (Nullable FilePath) { | opts } (Writable ()) readWrite :: Perms readWrite = Perms.mkPerms rw rw rw @@ -71,7 +69,7 @@ createWriteStreamWith :: WriteStreamOptions -> FilePath -> Effect (Writable ()) createWriteStreamWith opts file = mkEffect $ \_ -> runFn2 - fs.createWriteStream (nonnull file) + createWriteStream_ (nonnull file) { mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags } @@ -81,7 +79,7 @@ fdCreateWriteStreamWith :: WriteStreamOptions -> FileDescriptor -> Effect (Writable ()) fdCreateWriteStreamWith opts fd = mkEffect $ \_ -> runFn2 - fs.createWriteStream null + createWriteStream_ null { fd , mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags @@ -117,7 +115,7 @@ createReadStreamWith :: ReadStreamOptions -> FilePath -> Effect (Readable ()) createReadStreamWith opts file = mkEffect $ \_ -> runFn2 - fs.createReadStream (nonnull file) + createReadStream_ (nonnull file) { mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags , autoClose: opts.autoClose @@ -128,7 +126,7 @@ fdCreateReadStreamWith :: ReadStreamOptions -> FileDescriptor -> Effect (Readable ()) fdCreateReadStreamWith opts fd = mkEffect $ \_ -> runFn2 - fs.createReadStream null + createReadStream_ null { fd , mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags diff --git a/src/Node/FS/Sync.js b/src/Node/FS/Sync.js new file mode 100644 index 0000000..0748998 --- /dev/null +++ b/src/Node/FS/Sync.js @@ -0,0 +1,25 @@ +export { + renameSync as renameSync_, + truncateSync as truncateSync_, + chownSync as chownSync_, + chmodSync as chmodSync_, + statSync as statSync_, + linkSync as linkSync_, + symlinkSync as symlinkSync_, + readlinkSync as readlinkSync_, + realpathSync as realpathSync_, + unlinkSync as unlinkSync_, + rmdirSync as rmdirSync_, + mkdirSync as mkdirSync_, + readdirSync as readdirSync_, + utimesSync as utimesSync_, + readFileSync as readFileSync_, + writeFileSync as writeFileSync_, + appendFileSync as appendFileSync_, + existsSync as existsSync_, + openSync as openSync_, + readSync as readSync_, + writeSync as writeSync_, + fsyncSync as fsyncSync_, + closeSync as closeSync_ +} from "fs"; diff --git a/src/Node/FS/Sync.purs b/src/Node/FS/Sync.purs index 0d6c94a..8b16305 100644 --- a/src/Node/FS/Sync.purs +++ b/src/Node/FS/Sync.purs @@ -52,34 +52,33 @@ import Node.FS (FileDescriptor, ByteCount, FilePosition, BufferLength, import Node.FS.Stats (StatsObj, Stats(..)) import Node.Path (FilePath()) import Node.FS.Perms (Perms, permsToString, all, mkPerms) -import Node.FS.Internal (mkEffect, unsafeRequireFS) - -fs :: - { renameSync :: Fn2 FilePath FilePath Unit - , truncateSync :: Fn2 FilePath Int Unit - , chownSync :: Fn3 FilePath Int Int Unit - , chmodSync :: Fn2 FilePath String Unit - , statSync :: Fn1 FilePath StatsObj - , linkSync :: Fn2 FilePath FilePath Unit - , symlinkSync :: Fn3 FilePath FilePath String Unit - , readlinkSync :: Fn1 FilePath FilePath - , realpathSync :: forall cache. Fn2 FilePath { | cache } FilePath - , unlinkSync :: Fn1 FilePath Unit - , rmdirSync :: Fn1 FilePath Unit - , mkdirSync :: Fn2 FilePath { recursive :: Boolean, mode :: String } Unit - , readdirSync :: Fn1 FilePath (Array FilePath) - , utimesSync :: Fn3 FilePath Int Int Unit - , readFileSync :: forall a opts. Fn2 FilePath { | opts } a - , writeFileSync :: forall a opts. Fn3 FilePath a { | opts } Unit - , appendFileSync :: forall a opts. Fn3 FilePath a { | opts } Unit - , existsSync :: FilePath -> Boolean - , openSync :: Fn3 FilePath String (Nullable FileMode) FileDescriptor - , readSync :: Fn5 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) ByteCount - , writeSync :: Fn5 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) ByteCount - , fsyncSync :: Fn1 FileDescriptor Unit - , closeSync :: Fn1 FileDescriptor Unit - } -fs = unsafeRequireFS +import Node.FS.Internal (mkEffect) +import Node.FS.Internal as FS + + +foreign import renameSync_ :: Fn2 FilePath FilePath Unit +foreign import truncateSync_ :: Fn2 FilePath Int Unit +foreign import chownSync_ :: Fn3 FilePath Int Int Unit +foreign import chmodSync_ :: Fn2 FilePath String Unit +foreign import statSync_ :: Fn1 FilePath StatsObj +foreign import linkSync_ :: Fn2 FilePath FilePath Unit +foreign import symlinkSync_ :: Fn3 FilePath FilePath String Unit +foreign import readlinkSync_ :: Fn1 FilePath FilePath +foreign import realpathSync_ :: forall cache. Fn2 FilePath { | cache } FilePath +foreign import unlinkSync_ :: Fn1 FilePath Unit +foreign import rmdirSync_ :: Fn1 FilePath Unit +foreign import mkdirSync_ :: Fn2 FilePath { recursive :: Boolean, mode :: String } Unit +foreign import readdirSync_ :: Fn1 FilePath (Array FilePath) +foreign import utimesSync_ :: Fn3 FilePath Int Int Unit +foreign import readFileSync_ :: forall a opts. Fn2 FilePath { | opts } a +foreign import writeFileSync_ :: forall a opts. Fn3 FilePath a { | opts } Unit +foreign import appendFileSync_ :: forall a opts. Fn3 FilePath a { | opts } Unit +foreign import existsSync_ :: FilePath -> Boolean +foreign import openSync_ :: Fn3 FilePath String (Nullable FileMode) FileDescriptor +foreign import readSync_ :: Fn5 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) ByteCount +foreign import writeSync_ :: Fn5 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) ByteCount +foreign import fsyncSync_ :: Fn1 FileDescriptor Unit +foreign import closeSync_ :: Fn1 FileDescriptor Unit -- | Renames a file. rename :: FilePath @@ -87,7 +86,7 @@ rename :: FilePath -> Effect Unit rename oldFile newFile = mkEffect $ \_ -> runFn2 - fs.renameSync oldFile newFile + renameSync_ oldFile newFile -- | Truncates a file to the specified length. truncate :: FilePath @@ -95,7 +94,7 @@ truncate :: FilePath -> Effect Unit truncate file len = mkEffect $ \_ -> runFn2 - fs.truncateSync file len + truncateSync_ file len -- | Changes the ownership of a file. chown :: FilePath @@ -104,7 +103,7 @@ chown :: FilePath -> Effect Unit chown file uid gid = mkEffect $ \_ -> runFn3 - fs.chownSync file uid gid + chownSync_ file uid gid -- | Changes the permissions of a file. chmod :: FilePath @@ -112,14 +111,14 @@ chmod :: FilePath -> Effect Unit chmod file perms = mkEffect $ \_ -> runFn2 - fs.chmodSync file (permsToString perms) + chmodSync_ file (permsToString perms) -- | Gets file statistics. stat :: FilePath -> Effect Stats stat file = map Stats $ mkEffect $ \_ -> runFn1 - fs.statSync file + statSync_ file -- | Creates a link to an existing file. link :: FilePath @@ -127,7 +126,7 @@ link :: FilePath -> Effect Unit link src dst = mkEffect $ \_ -> runFn2 - fs.linkSync src dst + linkSync_ src dst -- | Creates a symlink. symlink :: FilePath @@ -136,21 +135,21 @@ symlink :: FilePath -> Effect Unit symlink src dst ty = mkEffect $ \_ -> runFn3 - fs.symlinkSync src dst (symlinkTypeToNode ty) + symlinkSync_ src dst (symlinkTypeToNode ty) -- | Reads the value of a symlink. readlink :: FilePath -> Effect FilePath readlink path = mkEffect $ \_ -> runFn1 - fs.readlinkSync path + readlinkSync_ path -- | Find the canonicalized absolute location for a path. realpath :: FilePath -> Effect FilePath realpath path = mkEffect $ \_ -> runFn2 - fs.realpathSync path {} + realpathSync_ path {} -- | Find the canonicalized absolute location for a path using a cache object for -- | already resolved paths. @@ -159,21 +158,21 @@ realpath' :: forall cache. FilePath -> Effect FilePath realpath' path cache = mkEffect $ \_ -> runFn2 - fs.realpathSync path cache + realpathSync_ path cache -- | Deletes a file. unlink :: FilePath -> Effect Unit unlink file = mkEffect $ \_ -> runFn1 - fs.unlinkSync file + unlinkSync_ file -- | Deletes a directory. rmdir :: FilePath -> Effect Unit rmdir file = mkEffect $ \_ -> runFn1 - fs.rmdirSync file + rmdirSync_ file -- | Makes a new directory. mkdirRecursive @@ -187,7 +186,7 @@ mkdirRecursive' -> Perms -> Effect Unit mkdirRecursive' file perms = mkEffect $ \_ -> runFn2 - fs.mkdirSync file { recursive: true, mode: permsToString perms } + mkdirSync_ file { recursive: true, mode: permsToString perms } -- | Makes a new directory. mkdir :: FilePath @@ -201,14 +200,14 @@ mkdir' :: FilePath -> Effect Unit mkdir' file perms = mkEffect $ \_ -> runFn2 - fs.mkdirSync file { recursive: false, mode: permsToString perms } + mkdirSync_ file { recursive: false, mode: permsToString perms } -- | Reads the contents of a directory. readdir :: FilePath -> Effect (Array FilePath) readdir file = mkEffect $ \_ -> runFn1 - fs.readdirSync file + readdirSync_ file -- | Sets the accessed and modified times for the specified file. utimes :: FilePath @@ -217,7 +216,7 @@ utimes :: FilePath -> Effect Unit utimes file atime mtime = mkEffect $ \_ -> runFn3 - fs.utimesSync file + utimesSync_ file (fromDate atime) (fromDate mtime) where @@ -230,7 +229,7 @@ readFile :: FilePath -> Effect Buffer readFile file = mkEffect $ \_ -> runFn2 - fs.readFileSync file {} + readFileSync_ file {} -- | Reads the entire contents of a text file with the specified encoding. readTextFile :: Encoding @@ -238,7 +237,7 @@ readTextFile :: Encoding -> Effect String readTextFile encoding file = mkEffect $ \_ -> runFn2 - fs.readFileSync file { encoding: show encoding } + readFileSync_ file { encoding: show encoding } -- | Writes a buffer to a file. writeFile :: FilePath @@ -246,7 +245,7 @@ writeFile :: FilePath -> Effect Unit writeFile file buff = mkEffect $ \_ -> runFn3 - fs.writeFileSync file buff {} + writeFileSync_ file buff {} -- | Writes text to a file using the specified encoding. writeTextFile :: Encoding @@ -255,7 +254,7 @@ writeTextFile :: Encoding -> Effect Unit writeTextFile encoding file text = mkEffect $ \_ -> runFn3 - fs.writeFileSync file text { encoding: show encoding } + writeFileSync_ file text { encoding: show encoding } -- | Appends the contents of a buffer to a file. appendFile :: FilePath @@ -263,7 +262,7 @@ appendFile :: FilePath -> Effect Unit appendFile file buff = mkEffect $ \_ -> runFn3 - fs.appendFileSync file buff {} + appendFileSync_ file buff {} -- | Appends text to a file using the specified encoding. appendTextFile :: Encoding @@ -272,12 +271,12 @@ appendTextFile :: Encoding -> Effect Unit appendTextFile encoding file buff = mkEffect $ \_ -> runFn3 - fs.appendFileSync file buff { encoding: show encoding } + appendFileSync_ file buff { encoding: show encoding } -- | Check if the path exists. exists :: FilePath -> Effect Boolean -exists file = mkEffect $ \_ -> fs.existsSync file +exists file = mkEffect $ \_ -> existsSync_ file -- | Open a file synchronously. See the [Node documentation](http://nodejs.org/api/fs.html#fs_fs_opensync_path_flags_mode) -- | for details. @@ -286,7 +285,7 @@ fdOpen :: FilePath -> Maybe FileMode -> Effect FileDescriptor fdOpen file flags mode = mkEffect $ \_ -> - runFn3 fs.openSync file (fileFlagsToNode flags) (toNullable mode) + runFn3 openSync_ file (fileFlagsToNode flags) (toNullable mode) -- | Read from a file synchronously. See the [Node documentation](http://nodejs.org/api/fs.html#fs_fs_readsync_fd_buffer_offset_length_position) -- | for details. @@ -297,7 +296,7 @@ fdRead :: FileDescriptor -> Maybe FilePosition -> Effect ByteCount fdRead fd buff off len pos = - mkEffect $ \_ -> runFn5 fs.readSync fd buff off len (toNullable pos) + mkEffect $ \_ -> runFn5 readSync_ fd buff off len (toNullable pos) -- | Convenience function to fill the whole buffer from the current -- | file position. @@ -317,7 +316,7 @@ fdWrite :: FileDescriptor -> Maybe FilePosition -> Effect ByteCount fdWrite fd buff off len pos = - mkEffect $ \_ -> runFn5 fs.writeSync fd buff off len (toNullable pos) + mkEffect $ \_ -> runFn5 writeSync_ fd buff off len (toNullable pos) -- | Convenience function to append the whole buffer to the current -- | file position. @@ -332,10 +331,10 @@ fdAppend fd buff = do -- | for details. fdFlush :: FileDescriptor -> Effect Unit -fdFlush fd = mkEffect $ \_ -> runFn1 fs.fsyncSync fd +fdFlush fd = mkEffect $ \_ -> runFn1 fsyncSync_ fd -- | Close a file synchronously. See the [Node documentation](http://nodejs.org/api/fs.html#fs_fs_closesync_fd) -- | for details. fdClose :: FileDescriptor -> Effect Unit -fdClose fd = mkEffect $ \_ -> runFn1 fs.closeSync fd +fdClose fd = mkEffect $ \_ -> runFn1 closeSync_ fd From aa17701a2225b80ea186b74a784c38ae7f1e7283 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Tue, 22 Mar 2022 20:27:07 -0400 Subject: [PATCH 13/16] Update Stream.purs --- src/Node/FS/Stream.purs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Node/FS/Stream.purs b/src/Node/FS/Stream.purs index 53894a7..8c5df06 100644 --- a/src/Node/FS/Stream.purs +++ b/src/Node/FS/Stream.purs @@ -25,7 +25,6 @@ import Node.FS (FileDescriptor, FileFlags(..), fileFlagsToNode) import Node.FS.Perms (Perms()) import Node.FS.Perms as Perms import Node.FS.Internal (mkEffect) -import Node.FS.Internal as FS foreign import createReadStream_ :: forall opts. Fn2 (Nullable FilePath) { | opts } (Readable ()) foreign import createWriteStream_ :: forall opts. Fn2 (Nullable FilePath) { | opts } (Writable ()) From 71bbecb0aad00f1538aec38d950f7652e0900355 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Tue, 22 Mar 2022 20:27:53 -0400 Subject: [PATCH 14/16] Update Sync.purs --- src/Node/FS/Sync.purs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Node/FS/Sync.purs b/src/Node/FS/Sync.purs index 8b16305..a1ec58b 100644 --- a/src/Node/FS/Sync.purs +++ b/src/Node/FS/Sync.purs @@ -53,8 +53,6 @@ import Node.FS.Stats (StatsObj, Stats(..)) import Node.Path (FilePath()) import Node.FS.Perms (Perms, permsToString, all, mkPerms) import Node.FS.Internal (mkEffect) -import Node.FS.Internal as FS - foreign import renameSync_ :: Fn2 FilePath FilePath Unit foreign import truncateSync_ :: Fn2 FilePath Int Unit From d3a45354db06a646c2f22f5429e86f048210469d Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 09:53:27 +0000 Subject: [PATCH 15/16] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ece784..1699208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Breaking changes: New features: - Add bindings to `mkdir(path, { recursive: true })` via `mkdirRecursive` (#53, #55 by @JordanMartinez) +- Update project and deps to PureScript v0.15.0 (#59 by @JordanMartinez, @thomashoneyman, @sigma-andex) Bugfixes: From d828778d0abf2ba42e3d2480545406233f48af03 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 10:01:34 +0000 Subject: [PATCH 16/16] Rename ffi suffix to Impl --- src/Node/FS/Async.js | 44 ++++++++--------- src/Node/FS/Async.purs | 98 +++++++++++++++++++------------------- src/Node/FS/Stream.js | 4 +- src/Node/FS/Stream.purs | 12 ++--- src/Node/FS/Sync.js | 46 +++++++++--------- src/Node/FS/Sync.purs | 102 ++++++++++++++++++++-------------------- 6 files changed, 153 insertions(+), 153 deletions(-) diff --git a/src/Node/FS/Async.js b/src/Node/FS/Async.js index 93ab025..b14ec6f 100644 --- a/src/Node/FS/Async.js +++ b/src/Node/FS/Async.js @@ -1,26 +1,26 @@ export { - rename as rename_, - truncate as truncate_, - chown as chown_, - chmod as chmod_, - stat as stat_, - link as link_, - symlink as symlink_, - readlink as readlink_, - realpath as realpath_, - unlink as unlink_, - rmdir as rmdir_, - mkdir as mkdir_, - readdir as readdir_, - utimes as utimes_, - readFile as readFile_, - writeFile as writeFile_, - appendFile as appendFile_, - exists as exists_, - open as open_, - read as read_, - write as write_, - close as close_ + rename as renameImpl, + truncate as truncateImpl, + chown as chownImpl, + chmod as chmodImpl, + stat as statImpl, + link as linkImpl, + symlink as symlinkImpl, + readlink as readlinkImpl, + realpath as realpathImpl, + unlink as unlinkImpl, + rmdir as rmdirImpl, + mkdir as mkdirImpl, + readdir as readdirImpl, + utimes as utimesImpl, + readFile as readFileImpl, + writeFile as writeFileImpl, + appendFile as appendFileImpl, + exists as existsImpl, + open as openImpl, + read as readImpl, + write as writeImpl, + close as closeImpl } from "fs"; export function handleCallbackImpl(left, right, f) { diff --git a/src/Node/FS/Async.purs b/src/Node/FS/Async.purs index b94c326..d4ff0ff 100644 --- a/src/Node/FS/Async.purs +++ b/src/Node/FS/Async.purs @@ -68,28 +68,28 @@ handleCallback cb = runFn3 handleCallbackImpl Left Right cb -- | Type synonym for callback functions. type Callback a = Either Error a -> Effect Unit -foreign import rename_ :: Fn3 FilePath FilePath (JSCallback Unit) Unit -foreign import truncate_ :: Fn3 FilePath Int (JSCallback Unit) Unit -foreign import chown_ :: Fn4 FilePath Int Int (JSCallback Unit) Unit -foreign import chmod_ :: Fn3 FilePath String (JSCallback Unit) Unit -foreign import stat_ :: Fn2 FilePath (JSCallback StatsObj) Unit -foreign import link_ :: Fn3 FilePath FilePath (JSCallback Unit) Unit -foreign import symlink_ :: Fn4 FilePath FilePath String (JSCallback Unit) Unit -foreign import readlink_ :: Fn2 FilePath (JSCallback FilePath) Unit -foreign import realpath_ :: forall cache. Fn3 FilePath { | cache } (JSCallback FilePath) Unit -foreign import unlink_ :: Fn2 FilePath (JSCallback Unit) Unit -foreign import rmdir_ :: Fn2 FilePath (JSCallback Unit) Unit -foreign import mkdir_ :: Fn3 FilePath { recursive :: Boolean, mode :: String } (JSCallback Unit) Unit -foreign import readdir_ :: Fn2 FilePath (JSCallback (Array FilePath)) Unit -foreign import utimes_ :: Fn4 FilePath Int Int (JSCallback Unit) Unit -foreign import readFile_ :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit -foreign import writeFile_ :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit -foreign import appendFile_ :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit -foreign import exists_ :: forall a. Fn2 FilePath (Boolean -> a) Unit -foreign import open_ :: Fn4 FilePath String (Nullable FileMode) (JSCallback FileDescriptor) Unit -foreign import read_ :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit -foreign import write_ :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit -foreign import close_ :: Fn2 FileDescriptor (JSCallback Unit) Unit +foreign import renameImpl :: Fn3 FilePath FilePath (JSCallback Unit) Unit +foreign import truncateImpl :: Fn3 FilePath Int (JSCallback Unit) Unit +foreign import chownImpl :: Fn4 FilePath Int Int (JSCallback Unit) Unit +foreign import chmodImpl :: Fn3 FilePath String (JSCallback Unit) Unit +foreign import statImpl :: Fn2 FilePath (JSCallback StatsObj) Unit +foreign import linkImpl :: Fn3 FilePath FilePath (JSCallback Unit) Unit +foreign import symlinkImpl :: Fn4 FilePath FilePath String (JSCallback Unit) Unit +foreign import readlinkImpl :: Fn2 FilePath (JSCallback FilePath) Unit +foreign import realpathImpl :: forall cache. Fn3 FilePath { | cache } (JSCallback FilePath) Unit +foreign import unlinkImpl :: Fn2 FilePath (JSCallback Unit) Unit +foreign import rmdirImpl :: Fn2 FilePath (JSCallback Unit) Unit +foreign import mkdirImpl :: Fn3 FilePath { recursive :: Boolean, mode :: String } (JSCallback Unit) Unit +foreign import readdirImpl :: Fn2 FilePath (JSCallback (Array FilePath)) Unit +foreign import utimesImpl :: Fn4 FilePath Int Int (JSCallback Unit) Unit +foreign import readFileImpl :: forall a opts. Fn3 FilePath { | opts } (JSCallback a) Unit +foreign import writeFileImpl :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit +foreign import appendFileImpl :: forall a opts. Fn4 FilePath a { | opts } (JSCallback Unit) Unit +foreign import existsImpl :: forall a. Fn2 FilePath (Boolean -> a) Unit +foreign import openImpl :: Fn4 FilePath String (Nullable FileMode) (JSCallback FileDescriptor) Unit +foreign import readImpl :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit +foreign import writeImpl :: Fn6 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) (JSCallback ByteCount) Unit +foreign import closeImpl :: Fn2 FileDescriptor (JSCallback Unit) Unit -- | Renames a file. @@ -98,7 +98,7 @@ rename :: FilePath -> Callback Unit -> Effect Unit rename oldFile newFile cb = mkEffect $ \_ -> runFn3 - rename_ oldFile newFile (handleCallback cb) + renameImpl oldFile newFile (handleCallback cb) -- | Truncates a file to the specified length. truncate :: FilePath @@ -107,7 +107,7 @@ truncate :: FilePath -> Effect Unit truncate file len cb = mkEffect $ \_ -> runFn3 - truncate_ file len (handleCallback cb) + truncateImpl file len (handleCallback cb) -- | Changes the ownership of a file. chown :: FilePath @@ -117,7 +117,7 @@ chown :: FilePath -> Effect Unit chown file uid gid cb = mkEffect $ \_ -> runFn4 - chown_ file uid gid (handleCallback cb) + chownImpl file uid gid (handleCallback cb) -- | Changes the permissions of a file. chmod :: FilePath @@ -126,7 +126,7 @@ chmod :: FilePath -> Effect Unit chmod file perms cb = mkEffect $ \_ -> runFn3 - chmod_ file (permsToString perms) (handleCallback cb) + chmodImpl file (permsToString perms) (handleCallback cb) -- | Gets file statistics. stat :: FilePath @@ -134,7 +134,7 @@ stat :: FilePath -> Effect Unit stat file cb = mkEffect $ \_ -> runFn2 - stat_ file (handleCallback $ cb <<< (<$>) Stats) + statImpl file (handleCallback $ cb <<< (<$>) Stats) -- | Creates a link to an existing file. link :: FilePath @@ -143,7 +143,7 @@ link :: FilePath -> Effect Unit link src dst cb = mkEffect $ \_ -> runFn3 - link_ src dst (handleCallback cb) + linkImpl src dst (handleCallback cb) -- | Creates a symlink. symlink :: FilePath @@ -153,7 +153,7 @@ symlink :: FilePath -> Effect Unit symlink src dest ty cb = mkEffect $ \_ -> runFn4 - symlink_ src dest (symlinkTypeToNode ty) (handleCallback cb) + symlinkImpl src dest (symlinkTypeToNode ty) (handleCallback cb) -- | Reads the value of a symlink. readlink :: FilePath @@ -161,7 +161,7 @@ readlink :: FilePath -> Effect Unit readlink path cb = mkEffect $ \_ -> runFn2 - readlink_ path (handleCallback cb) + readlinkImpl path (handleCallback cb) -- | Find the canonicalized absolute location for a path. realpath :: FilePath @@ -169,7 +169,7 @@ realpath :: FilePath -> Effect Unit realpath path cb = mkEffect $ \_ -> runFn3 - realpath_ path {} (handleCallback cb) + realpathImpl path {} (handleCallback cb) -- | Find the canonicalized absolute location for a path using a cache object -- | for already resolved paths. @@ -179,7 +179,7 @@ realpath' :: forall cache. FilePath -> Effect Unit realpath' path cache cb = mkEffect $ \_ -> runFn3 - realpath_ path cache (handleCallback cb) + realpathImpl path cache (handleCallback cb) -- | Deletes a file. unlink :: FilePath @@ -187,7 +187,7 @@ unlink :: FilePath -> Effect Unit unlink file cb = mkEffect $ \_ -> runFn2 - unlink_ file (handleCallback cb) + unlinkImpl file (handleCallback cb) -- | Deletes a directory. rmdir :: FilePath @@ -195,7 +195,7 @@ rmdir :: FilePath -> Effect Unit rmdir file cb = mkEffect $ \_ -> runFn2 - rmdir_ file (handleCallback cb) + rmdirImpl file (handleCallback cb) -- | Makes a new directory. mkdir :: FilePath @@ -220,7 +220,7 @@ mkdirRecursive' -> Callback Unit -> Effect Unit mkdirRecursive' file perms cb = mkEffect $ \_ -> runFn3 - mkdir_ file { recursive: true, mode: permsToString perms } (handleCallback cb) + mkdirImpl file { recursive: true, mode: permsToString perms } (handleCallback cb) -- | Makes a new directory with the specified permissions. mkdir' :: FilePath @@ -228,7 +228,7 @@ mkdir' :: FilePath -> Callback Unit -> Effect Unit mkdir' file perms cb = mkEffect $ \_ -> runFn3 - mkdir_ file { recursive: false, mode: permsToString perms } (handleCallback cb) + mkdirImpl file { recursive: false, mode: permsToString perms } (handleCallback cb) -- | Reads the contents of a directory. readdir :: FilePath @@ -236,7 +236,7 @@ readdir :: FilePath -> Effect Unit readdir file cb = mkEffect $ \_ -> runFn2 - readdir_ file (handleCallback cb) + readdirImpl file (handleCallback cb) -- | Sets the accessed and modified times for the specified file. utimes :: FilePath @@ -246,7 +246,7 @@ utimes :: FilePath -> Effect Unit utimes file atime mtime cb = mkEffect $ \_ -> runFn4 - utimes_ file + utimesImpl file (fromDate atime) (fromDate mtime) (handleCallback cb) @@ -261,7 +261,7 @@ readFile :: FilePath -> Effect Unit readFile file cb = mkEffect $ \_ -> runFn3 - readFile_ file {} (handleCallback cb) + readFileImpl file {} (handleCallback cb) -- | Reads the entire contents of a text file with the specified encoding. readTextFile :: Encoding @@ -270,7 +270,7 @@ readTextFile :: Encoding -> Effect Unit readTextFile encoding file cb = mkEffect $ \_ -> runFn3 - readFile_ file { encoding: show encoding } (handleCallback cb) + readFileImpl file { encoding: show encoding } (handleCallback cb) -- | Writes a buffer to a file. writeFile :: FilePath @@ -279,7 +279,7 @@ writeFile :: FilePath -> Effect Unit writeFile file buff cb = mkEffect $ \_ -> runFn4 - writeFile_ file buff {} (handleCallback cb) + writeFileImpl file buff {} (handleCallback cb) -- | Writes text to a file using the specified encoding. writeTextFile :: Encoding @@ -289,7 +289,7 @@ writeTextFile :: Encoding -> Effect Unit writeTextFile encoding file buff cb = mkEffect $ \_ -> runFn4 - writeFile_ file buff { encoding: show encoding } (handleCallback cb) + writeFileImpl file buff { encoding: show encoding } (handleCallback cb) -- | Appends the contents of a buffer to a file. appendFile :: FilePath @@ -298,7 +298,7 @@ appendFile :: FilePath -> Effect Unit appendFile file buff cb = mkEffect $ \_ -> runFn4 - appendFile_ file buff {} (handleCallback cb) + appendFileImpl file buff {} (handleCallback cb) -- | Appends text to a file using the specified encoding. appendTextFile :: Encoding @@ -308,14 +308,14 @@ appendTextFile :: Encoding -> Effect Unit appendTextFile encoding file buff cb = mkEffect $ \_ -> runFn4 - appendFile_ file buff { encoding: show encoding } (handleCallback cb) + appendFileImpl file buff { encoding: show encoding } (handleCallback cb) -- | Check if the path exists. exists :: FilePath -> (Boolean -> Effect Unit) -> Effect Unit exists file cb = mkEffect $ \_ -> runFn2 - exists_ file $ \b -> unsafePerformEffect (cb b) + existsImpl file $ \b -> unsafePerformEffect (cb b) -- | Open a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback) -- | for details. @@ -324,7 +324,7 @@ fdOpen :: FilePath -> Maybe FileMode -> Callback FileDescriptor -> Effect Unit -fdOpen file flags mode cb = mkEffect $ \_ -> runFn4 open_ file (fileFlagsToNode flags) (toNullable mode) (handleCallback cb) +fdOpen file flags mode cb = mkEffect $ \_ -> runFn4 openImpl file (fileFlagsToNode flags) (toNullable mode) (handleCallback cb) -- | Read from a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback) -- | for details. @@ -335,7 +335,7 @@ fdRead :: FileDescriptor -> Maybe FilePosition -> Callback ByteCount -> Effect Unit -fdRead fd buff off len pos cb = mkEffect $ \_ -> runFn6 read_ fd buff off len (toNullable pos) (handleCallback cb) +fdRead fd buff off len pos cb = mkEffect $ \_ -> runFn6 readImpl fd buff off len (toNullable pos) (handleCallback cb) -- | Convenience function to fill the whole buffer from the current -- | file position. @@ -356,7 +356,7 @@ fdWrite :: FileDescriptor -> Maybe FilePosition -> Callback ByteCount -> Effect Unit -fdWrite fd buff off len pos cb = mkEffect $ \_ -> runFn6 write_ fd buff off len (toNullable pos) (handleCallback cb) +fdWrite fd buff off len pos cb = mkEffect $ \_ -> runFn6 writeImpl fd buff off len (toNullable pos) (handleCallback cb) -- | Convenience function to append the whole buffer to the current -- | file position. @@ -373,4 +373,4 @@ fdAppend fd buff cb = do fdClose :: FileDescriptor -> Callback Unit -> Effect Unit -fdClose fd cb = mkEffect $ \_ -> runFn2 close_ fd (handleCallback cb) +fdClose fd cb = mkEffect $ \_ -> runFn2 closeImpl fd (handleCallback cb) diff --git a/src/Node/FS/Stream.js b/src/Node/FS/Stream.js index 1440085..bfc7126 100644 --- a/src/Node/FS/Stream.js +++ b/src/Node/FS/Stream.js @@ -1,4 +1,4 @@ export { - createReadStream as createReadStream_, - createWriteStream as createWriteStream_ + createReadStream as createReadStreamImpl, + createWriteStream as createWriteStreamImpl } from "fs"; diff --git a/src/Node/FS/Stream.purs b/src/Node/FS/Stream.purs index 8c5df06..2c503a0 100644 --- a/src/Node/FS/Stream.purs +++ b/src/Node/FS/Stream.purs @@ -26,8 +26,8 @@ import Node.FS.Perms (Perms()) import Node.FS.Perms as Perms import Node.FS.Internal (mkEffect) -foreign import createReadStream_ :: forall opts. Fn2 (Nullable FilePath) { | opts } (Readable ()) -foreign import createWriteStream_ :: forall opts. Fn2 (Nullable FilePath) { | opts } (Writable ()) +foreign import createReadStreamImpl :: forall opts. Fn2 (Nullable FilePath) { | opts } (Readable ()) +foreign import createWriteStreamImpl :: forall opts. Fn2 (Nullable FilePath) { | opts } (Writable ()) readWrite :: Perms readWrite = Perms.mkPerms rw rw rw @@ -68,7 +68,7 @@ createWriteStreamWith :: WriteStreamOptions -> FilePath -> Effect (Writable ()) createWriteStreamWith opts file = mkEffect $ \_ -> runFn2 - createWriteStream_ (nonnull file) + createWriteStreamImpl (nonnull file) { mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags } @@ -78,7 +78,7 @@ fdCreateWriteStreamWith :: WriteStreamOptions -> FileDescriptor -> Effect (Writable ()) fdCreateWriteStreamWith opts fd = mkEffect $ \_ -> runFn2 - createWriteStream_ null + createWriteStreamImpl null { fd , mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags @@ -114,7 +114,7 @@ createReadStreamWith :: ReadStreamOptions -> FilePath -> Effect (Readable ()) createReadStreamWith opts file = mkEffect $ \_ -> runFn2 - createReadStream_ (nonnull file) + createReadStreamImpl (nonnull file) { mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags , autoClose: opts.autoClose @@ -125,7 +125,7 @@ fdCreateReadStreamWith :: ReadStreamOptions -> FileDescriptor -> Effect (Readable ()) fdCreateReadStreamWith opts fd = mkEffect $ \_ -> runFn2 - createReadStream_ null + createReadStreamImpl null { fd , mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags diff --git a/src/Node/FS/Sync.js b/src/Node/FS/Sync.js index 0748998..bd93b52 100644 --- a/src/Node/FS/Sync.js +++ b/src/Node/FS/Sync.js @@ -1,25 +1,25 @@ export { - renameSync as renameSync_, - truncateSync as truncateSync_, - chownSync as chownSync_, - chmodSync as chmodSync_, - statSync as statSync_, - linkSync as linkSync_, - symlinkSync as symlinkSync_, - readlinkSync as readlinkSync_, - realpathSync as realpathSync_, - unlinkSync as unlinkSync_, - rmdirSync as rmdirSync_, - mkdirSync as mkdirSync_, - readdirSync as readdirSync_, - utimesSync as utimesSync_, - readFileSync as readFileSync_, - writeFileSync as writeFileSync_, - appendFileSync as appendFileSync_, - existsSync as existsSync_, - openSync as openSync_, - readSync as readSync_, - writeSync as writeSync_, - fsyncSync as fsyncSync_, - closeSync as closeSync_ + renameSync as renameSyncImpl, + truncateSync as truncateSyncImpl, + chownSync as chownSyncImpl, + chmodSync as chmodSyncImpl, + statSync as statSyncImpl, + linkSync as linkSyncImpl, + symlinkSync as symlinkSyncImpl, + readlinkSync as readlinkSyncImpl, + realpathSync as realpathSyncImpl, + unlinkSync as unlinkSyncImpl, + rmdirSync as rmdirSyncImpl, + mkdirSync as mkdirSyncImpl, + readdirSync as readdirSyncImpl, + utimesSync as utimesSyncImpl, + readFileSync as readFileSyncImpl, + writeFileSync as writeFileSyncImpl, + appendFileSync as appendFileSyncImpl, + existsSync as existsSyncImpl, + openSync as openSyncImpl, + readSync as readSyncImpl, + writeSync as writeSyncImpl, + fsyncSync as fsyncSyncImpl, + closeSync as closeSyncImpl } from "fs"; diff --git a/src/Node/FS/Sync.purs b/src/Node/FS/Sync.purs index a1ec58b..9c9e40a 100644 --- a/src/Node/FS/Sync.purs +++ b/src/Node/FS/Sync.purs @@ -54,29 +54,29 @@ import Node.Path (FilePath()) import Node.FS.Perms (Perms, permsToString, all, mkPerms) import Node.FS.Internal (mkEffect) -foreign import renameSync_ :: Fn2 FilePath FilePath Unit -foreign import truncateSync_ :: Fn2 FilePath Int Unit -foreign import chownSync_ :: Fn3 FilePath Int Int Unit -foreign import chmodSync_ :: Fn2 FilePath String Unit -foreign import statSync_ :: Fn1 FilePath StatsObj -foreign import linkSync_ :: Fn2 FilePath FilePath Unit -foreign import symlinkSync_ :: Fn3 FilePath FilePath String Unit -foreign import readlinkSync_ :: Fn1 FilePath FilePath -foreign import realpathSync_ :: forall cache. Fn2 FilePath { | cache } FilePath -foreign import unlinkSync_ :: Fn1 FilePath Unit -foreign import rmdirSync_ :: Fn1 FilePath Unit -foreign import mkdirSync_ :: Fn2 FilePath { recursive :: Boolean, mode :: String } Unit -foreign import readdirSync_ :: Fn1 FilePath (Array FilePath) -foreign import utimesSync_ :: Fn3 FilePath Int Int Unit -foreign import readFileSync_ :: forall a opts. Fn2 FilePath { | opts } a -foreign import writeFileSync_ :: forall a opts. Fn3 FilePath a { | opts } Unit -foreign import appendFileSync_ :: forall a opts. Fn3 FilePath a { | opts } Unit -foreign import existsSync_ :: FilePath -> Boolean -foreign import openSync_ :: Fn3 FilePath String (Nullable FileMode) FileDescriptor -foreign import readSync_ :: Fn5 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) ByteCount -foreign import writeSync_ :: Fn5 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) ByteCount -foreign import fsyncSync_ :: Fn1 FileDescriptor Unit -foreign import closeSync_ :: Fn1 FileDescriptor Unit +foreign import renameSyncImpl :: Fn2 FilePath FilePath Unit +foreign import truncateSyncImpl :: Fn2 FilePath Int Unit +foreign import chownSyncImpl :: Fn3 FilePath Int Int Unit +foreign import chmodSyncImpl :: Fn2 FilePath String Unit +foreign import statSyncImpl :: Fn1 FilePath StatsObj +foreign import linkSyncImpl :: Fn2 FilePath FilePath Unit +foreign import symlinkSyncImpl :: Fn3 FilePath FilePath String Unit +foreign import readlinkSyncImpl :: Fn1 FilePath FilePath +foreign import realpathSyncImpl :: forall cache. Fn2 FilePath { | cache } FilePath +foreign import unlinkSyncImpl :: Fn1 FilePath Unit +foreign import rmdirSyncImpl :: Fn1 FilePath Unit +foreign import mkdirSyncImpl :: Fn2 FilePath { recursive :: Boolean, mode :: String } Unit +foreign import readdirSyncImpl :: Fn1 FilePath (Array FilePath) +foreign import utimesSyncImpl :: Fn3 FilePath Int Int Unit +foreign import readFileSyncImpl :: forall a opts. Fn2 FilePath { | opts } a +foreign import writeFileSyncImpl :: forall a opts. Fn3 FilePath a { | opts } Unit +foreign import appendFileSyncImpl :: forall a opts. Fn3 FilePath a { | opts } Unit +foreign import existsSyncImpl :: FilePath -> Boolean +foreign import openSyncImpl :: Fn3 FilePath String (Nullable FileMode) FileDescriptor +foreign import readSyncImpl :: Fn5 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) ByteCount +foreign import writeSyncImpl :: Fn5 FileDescriptor Buffer BufferOffset BufferLength (Nullable FilePosition) ByteCount +foreign import fsyncSyncImpl :: Fn1 FileDescriptor Unit +foreign import closeSyncImpl :: Fn1 FileDescriptor Unit -- | Renames a file. rename :: FilePath @@ -84,7 +84,7 @@ rename :: FilePath -> Effect Unit rename oldFile newFile = mkEffect $ \_ -> runFn2 - renameSync_ oldFile newFile + renameSyncImpl oldFile newFile -- | Truncates a file to the specified length. truncate :: FilePath @@ -92,7 +92,7 @@ truncate :: FilePath -> Effect Unit truncate file len = mkEffect $ \_ -> runFn2 - truncateSync_ file len + truncateSyncImpl file len -- | Changes the ownership of a file. chown :: FilePath @@ -101,7 +101,7 @@ chown :: FilePath -> Effect Unit chown file uid gid = mkEffect $ \_ -> runFn3 - chownSync_ file uid gid + chownSyncImpl file uid gid -- | Changes the permissions of a file. chmod :: FilePath @@ -109,14 +109,14 @@ chmod :: FilePath -> Effect Unit chmod file perms = mkEffect $ \_ -> runFn2 - chmodSync_ file (permsToString perms) + chmodSyncImpl file (permsToString perms) -- | Gets file statistics. stat :: FilePath -> Effect Stats stat file = map Stats $ mkEffect $ \_ -> runFn1 - statSync_ file + statSyncImpl file -- | Creates a link to an existing file. link :: FilePath @@ -124,7 +124,7 @@ link :: FilePath -> Effect Unit link src dst = mkEffect $ \_ -> runFn2 - linkSync_ src dst + linkSyncImpl src dst -- | Creates a symlink. symlink :: FilePath @@ -133,21 +133,21 @@ symlink :: FilePath -> Effect Unit symlink src dst ty = mkEffect $ \_ -> runFn3 - symlinkSync_ src dst (symlinkTypeToNode ty) + symlinkSyncImpl src dst (symlinkTypeToNode ty) -- | Reads the value of a symlink. readlink :: FilePath -> Effect FilePath readlink path = mkEffect $ \_ -> runFn1 - readlinkSync_ path + readlinkSyncImpl path -- | Find the canonicalized absolute location for a path. realpath :: FilePath -> Effect FilePath realpath path = mkEffect $ \_ -> runFn2 - realpathSync_ path {} + realpathSyncImpl path {} -- | Find the canonicalized absolute location for a path using a cache object for -- | already resolved paths. @@ -156,21 +156,21 @@ realpath' :: forall cache. FilePath -> Effect FilePath realpath' path cache = mkEffect $ \_ -> runFn2 - realpathSync_ path cache + realpathSyncImpl path cache -- | Deletes a file. unlink :: FilePath -> Effect Unit unlink file = mkEffect $ \_ -> runFn1 - unlinkSync_ file + unlinkSyncImpl file -- | Deletes a directory. rmdir :: FilePath -> Effect Unit rmdir file = mkEffect $ \_ -> runFn1 - rmdirSync_ file + rmdirSyncImpl file -- | Makes a new directory. mkdirRecursive @@ -184,7 +184,7 @@ mkdirRecursive' -> Perms -> Effect Unit mkdirRecursive' file perms = mkEffect $ \_ -> runFn2 - mkdirSync_ file { recursive: true, mode: permsToString perms } + mkdirSyncImpl file { recursive: true, mode: permsToString perms } -- | Makes a new directory. mkdir :: FilePath @@ -198,14 +198,14 @@ mkdir' :: FilePath -> Effect Unit mkdir' file perms = mkEffect $ \_ -> runFn2 - mkdirSync_ file { recursive: false, mode: permsToString perms } + mkdirSyncImpl file { recursive: false, mode: permsToString perms } -- | Reads the contents of a directory. readdir :: FilePath -> Effect (Array FilePath) readdir file = mkEffect $ \_ -> runFn1 - readdirSync_ file + readdirSyncImpl file -- | Sets the accessed and modified times for the specified file. utimes :: FilePath @@ -214,7 +214,7 @@ utimes :: FilePath -> Effect Unit utimes file atime mtime = mkEffect $ \_ -> runFn3 - utimesSync_ file + utimesSyncImpl file (fromDate atime) (fromDate mtime) where @@ -227,7 +227,7 @@ readFile :: FilePath -> Effect Buffer readFile file = mkEffect $ \_ -> runFn2 - readFileSync_ file {} + readFileSyncImpl file {} -- | Reads the entire contents of a text file with the specified encoding. readTextFile :: Encoding @@ -235,7 +235,7 @@ readTextFile :: Encoding -> Effect String readTextFile encoding file = mkEffect $ \_ -> runFn2 - readFileSync_ file { encoding: show encoding } + readFileSyncImpl file { encoding: show encoding } -- | Writes a buffer to a file. writeFile :: FilePath @@ -243,7 +243,7 @@ writeFile :: FilePath -> Effect Unit writeFile file buff = mkEffect $ \_ -> runFn3 - writeFileSync_ file buff {} + writeFileSyncImpl file buff {} -- | Writes text to a file using the specified encoding. writeTextFile :: Encoding @@ -252,7 +252,7 @@ writeTextFile :: Encoding -> Effect Unit writeTextFile encoding file text = mkEffect $ \_ -> runFn3 - writeFileSync_ file text { encoding: show encoding } + writeFileSyncImpl file text { encoding: show encoding } -- | Appends the contents of a buffer to a file. appendFile :: FilePath @@ -260,7 +260,7 @@ appendFile :: FilePath -> Effect Unit appendFile file buff = mkEffect $ \_ -> runFn3 - appendFileSync_ file buff {} + appendFileSyncImpl file buff {} -- | Appends text to a file using the specified encoding. appendTextFile :: Encoding @@ -269,12 +269,12 @@ appendTextFile :: Encoding -> Effect Unit appendTextFile encoding file buff = mkEffect $ \_ -> runFn3 - appendFileSync_ file buff { encoding: show encoding } + appendFileSyncImpl file buff { encoding: show encoding } -- | Check if the path exists. exists :: FilePath -> Effect Boolean -exists file = mkEffect $ \_ -> existsSync_ file +exists file = mkEffect $ \_ -> existsSyncImpl file -- | Open a file synchronously. See the [Node documentation](http://nodejs.org/api/fs.html#fs_fs_opensync_path_flags_mode) -- | for details. @@ -283,7 +283,7 @@ fdOpen :: FilePath -> Maybe FileMode -> Effect FileDescriptor fdOpen file flags mode = mkEffect $ \_ -> - runFn3 openSync_ file (fileFlagsToNode flags) (toNullable mode) + runFn3 openSyncImpl file (fileFlagsToNode flags) (toNullable mode) -- | Read from a file synchronously. See the [Node documentation](http://nodejs.org/api/fs.html#fs_fs_readsync_fd_buffer_offset_length_position) -- | for details. @@ -294,7 +294,7 @@ fdRead :: FileDescriptor -> Maybe FilePosition -> Effect ByteCount fdRead fd buff off len pos = - mkEffect $ \_ -> runFn5 readSync_ fd buff off len (toNullable pos) + mkEffect $ \_ -> runFn5 readSyncImpl fd buff off len (toNullable pos) -- | Convenience function to fill the whole buffer from the current -- | file position. @@ -314,7 +314,7 @@ fdWrite :: FileDescriptor -> Maybe FilePosition -> Effect ByteCount fdWrite fd buff off len pos = - mkEffect $ \_ -> runFn5 writeSync_ fd buff off len (toNullable pos) + mkEffect $ \_ -> runFn5 writeSyncImpl fd buff off len (toNullable pos) -- | Convenience function to append the whole buffer to the current -- | file position. @@ -329,10 +329,10 @@ fdAppend fd buff = do -- | for details. fdFlush :: FileDescriptor -> Effect Unit -fdFlush fd = mkEffect $ \_ -> runFn1 fsyncSync_ fd +fdFlush fd = mkEffect $ \_ -> runFn1 fsyncSyncImpl fd -- | Close a file synchronously. See the [Node documentation](http://nodejs.org/api/fs.html#fs_fs_closesync_fd) -- | for details. fdClose :: FileDescriptor -> Effect Unit -fdClose fd = mkEffect $ \_ -> runFn1 closeSync_ fd +fdClose fd = mkEffect $ \_ -> runFn1 closeSyncImpl fd