Skip to content

feat: implement glob, cp, opendir and other methods #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
791cefe
feat: implement glob, cp, opendir and other methods
srghma-old Oct 4, 2024
86c67eb
feat: use FilePath instead of String where needed, AutodetectLink
srghma-old Oct 4, 2024
efebe33
feat: node-buffer-blob
srghma-old Oct 4, 2024
2e5f45c
feat: spago build --offline --censor-stats --strict --pedantic-packages
srghma-old Oct 4, 2024
ddd6a47
fix: tests
srghma-old Oct 5, 2024
e98b91c
rm -rdf .spago spago.lock output && spago upgrade --migrate && spago …
srghma-old Oct 5, 2024
2cc9b29
feat: opendirOptionsDefault
srghma-old Oct 5, 2024
13cf95d
refactor: tests -> move, use Test dir like specified in spago documen…
srghma-old Oct 6, 2024
e48eea5
feat: move Options to separate file
srghma-old Oct 6, 2024
4216697
feat: sync -> implement
srghma-old Oct 6, 2024
b226943
feat: aff -> forgot some functions
srghma-old Oct 6, 2024
1319b6b
fix: suggestions
srghma-old Oct 6, 2024
6f00cdf
feat: remove Node.FS.Sync.fdFlush
srghma-old Oct 6, 2024
602a6a8
fix: write
srghma-old Oct 6, 2024
9b146de
fix(#81): add copyFile_NO_FLAGS, make it default
srghma-old Oct 6, 2024
6575fd1
fix: --strict
srghma-old Oct 6, 2024
b0a8cca
fix: futimes, feat: add readlinkBuffer
srghma-old Oct 6, 2024
20f566a
feat: show for Dir, fix: show for Dirent
srghma-old Oct 8, 2024
43d512b
feat: reproduce TypeError [ERR_INVALID_ARG_TYPE]: The "options.filter…
srghma-old Oct 11, 2024
1df3ebd
fix: TypeError [ERR_INVALID_ARG_TYPE]: The "options.filter" property …
srghma-old Oct 11, 2024
84bba38
fix: cp options -> should be CopyMode
srghma-old Oct 11, 2024
50972ba
fix: cp -> split on cpFile and cpDir bc recursive is required for dirs
srghma-old Oct 11, 2024
3e2e675
feat: DirentType and getType -> add
srghma-old Oct 13, 2024
fcfddf9
feat: rename using sd -F 'DirentNameType' 'DirentName' $(fd --type file)
srghma-old Oct 13, 2024
bc7c327
feat: Dirent -> dont export isXXX
srghma-old Oct 13, 2024
4710e21
feat: move Callbacks
srghma-old Oct 13, 2024
111d26e
feat: Dir -> split
srghma-old Oct 13, 2024
3a1dc6f
refactor: tests -> wrong names
srghma-old Oct 13, 2024
4732d1b
refactor: Dir.Sync -> wrong names
srghma-old Oct 13, 2024
b9195f5
refactor: Dir -> explicit export
srghma-old Oct 13, 2024
622d56b
refactor: rename module
srghma-old Oct 13, 2024
0a1796a
feat: DirentType -> add derive
srghma-old Oct 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: futimes, feat: add readlinkBuffer
  • Loading branch information
srghma-old committed Oct 6, 2024
commit b0a8cca30aa77f5803a3dff98e330f6e267d0a0a
6 changes: 5 additions & 1 deletion src/Node/FS/Aff.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Node.FS.Aff
, link
, symlink
, readlink
, readlinkBuffer
, realpath
, realpath'
, unlink
Expand Down Expand Up @@ -179,6 +180,9 @@ symlink = toAff3 A.symlink
readlink :: FilePath -> Aff FilePath
readlink = toAff1 A.readlink

readlinkBuffer :: FilePath -> Aff Buffer
readlinkBuffer = toAff1 A.readlinkBuffer

-- |
-- | Find the canonicalized absolute location for a path.
-- |
Expand Down Expand Up @@ -442,7 +446,7 @@ ftruncate = toAff2 A.ftruncate

-- | Change file timestamps for a file descriptor. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_futimes_fd_atime_mtime_callback)
-- | for details.
futimes :: FilePath -> DateTime -> DateTime -> Aff Unit
futimes :: FileDescriptor -> DateTime -> DateTime -> Aff Unit
futimes = toAff3 A.futimes

-- | Perform pattern matching in file paths. See the [Node Documentation](https://nodejs.org/api/glob.html#globglob_pattern_options_callback)
Expand Down
21 changes: 14 additions & 7 deletions src/Node/FS/Async.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Node.FS.Async
, link
, symlink
, readlink
, readlinkBuffer
, realpath
, realpath'
, unlink
Expand Down Expand Up @@ -114,6 +115,10 @@ foreign import lstatImpl :: EffectFn2 FilePath (JSCallback1 Stats) Unit
foreign import linkImpl :: EffectFn3 FilePath FilePath JSCallback0 Unit
foreign import symlinkImpl :: EffectFn4 FilePath FilePath (Nullable String) JSCallback0 Unit
foreign import readlinkImpl :: EffectFn2 FilePath (JSCallback1 FilePath) Unit

readlinkBufferImpl :: EffectFn3 FilePath String (JSCallback1 Buffer) Unit
readlinkBufferImpl = unsafeCoerce readlinkImpl

foreign import realpathImpl :: EffectFn3 FilePath RealpathOptionsInternal (JSCallback1 FilePath) Unit
foreign import unlinkImpl :: EffectFn2 FilePath JSCallback0 Unit
foreign import rmdirImpl :: EffectFn3 FilePath RmdirOptions JSCallback0 Unit
Expand Down Expand Up @@ -254,6 +259,13 @@ readlink
-> Effect Unit
readlink path cb = runEffectFn2 readlinkImpl path (handleCallback1 cb)

-- | Reads the value of a symlink, returns buffer.
readlinkBuffer
:: FilePath
-> Callback1 Buffer
-> Effect Unit
readlinkBuffer path cb = runEffectFn3 readlinkBufferImpl path "buffer" (handleCallback1 cb)

-- | Find the canonicalized absolute location for a path.
realpath
:: FilePath
Expand Down Expand Up @@ -619,13 +631,8 @@ ftruncate fd len cb = runEffectFn3 ftruncateImpl fd len (handleCallback0 cb)

-- | Change file timestamps for a file descriptor. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_futimes_fd_atime_mtime_callback)
-- | for details.
futimes
:: FilePath
-> DateTime
-> DateTime
-> Callback0
-> Effect Unit
futimes file atime mtime cb = runEffectFn4 lutimesImpl file (datetimeToUnixEpochTimeInSeconds atime) (datetimeToUnixEpochTimeInSeconds mtime) (handleCallback0 cb)
futimes :: FileDescriptor -> DateTime -> DateTime -> Callback0 -> Effect Unit
futimes fd atime mtime cb = runEffectFn4 futimesImpl fd (datetimeToUnixEpochTimeInSeconds atime) (datetimeToUnixEpochTimeInSeconds mtime) (handleCallback0 cb)

-- | Perform pattern matching in file paths. See the [Node Documentation](https://nodejs.org/api/glob.html#globglob_pattern_options_callback)
-- | for details.
Expand Down
16 changes: 10 additions & 6 deletions src/Node/FS/Sync.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Node.FS.Sync
, link
, symlink
, readlink
, readlinkBuffer
, realpath
, realpath'
, unlink
Expand Down Expand Up @@ -114,6 +115,10 @@ foreign import lstatSyncImpl :: EffectFn1 FilePath Stats
foreign import linkSyncImpl :: EffectFn2 FilePath FilePath Unit
foreign import symlinkSyncImpl :: EffectFn3 FilePath FilePath (Nullable String) Unit
foreign import readlinkSyncImpl :: EffectFn1 FilePath FilePath

readlinkBufferSyncImpl :: EffectFn2 FilePath String Buffer
readlinkBufferSyncImpl = unsafeCoerce readlinkSyncImpl

foreign import realpathSyncImpl :: EffectFn2 FilePath RealpathOptionsInternal FilePath
foreign import unlinkSyncImpl :: EffectFn1 FilePath Unit
foreign import rmdirSyncImpl :: EffectFn2 FilePath RmdirOptions Unit
Expand Down Expand Up @@ -239,6 +244,9 @@ readlink
-> Effect FilePath
readlink path = runEffectFn1 readlinkSyncImpl path

readlinkBuffer :: FilePath -> Effect Buffer
readlinkBuffer path = runEffectFn2 readlinkBufferSyncImpl path "buffer"

-- | Find the canonicalized absolute location for a path.
realpath
:: FilePath
Expand Down Expand Up @@ -569,12 +577,8 @@ ftruncate fd len = runEffectFn2 ftruncateSyncImpl fd len

-- | Change file timestamps for a file descriptor. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_futimes_fd_atime_mtime_callback)
-- | for details.
futimes
:: FilePath
-> DateTime
-> DateTime
-> Effect Unit
futimes file atime mtime = runEffectFn3 lutimesSyncImpl file (datetimeToUnixEpochTimeInSeconds atime) (datetimeToUnixEpochTimeInSeconds mtime)
futimes :: FileDescriptor -> DateTime -> DateTime -> Effect Unit
futimes fd atime mtime = runEffectFn3 futimesSyncImpl fd (datetimeToUnixEpochTimeInSeconds atime) (datetimeToUnixEpochTimeInSeconds mtime)

-- | Perform pattern matching in file paths. See the [Node Documentation](https://nodejs.org/api/glob.html#globglob_pattern_options_callback)
-- | for details.
Expand Down