You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- | Read from a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback)
316
318
-- | for details.
319
+
-- |
320
+
-- | The use of an Int as FilePosition restricts this API to reading
321
+
-- | files < 2GB. The call is retained to not break existing code.
322
+
-- | fdReadLarge does not have this restriction.
317
323
fdRead::foralleff.
318
324
FileDescriptor
319
325
->Buffer
@@ -322,7 +328,28 @@ fdRead :: forall eff.
322
328
->MaybeFilePosition
323
329
->Callback (buffer::BUFFER | eff) ByteCount
324
330
->Eff (buffer::BUFFER, fs::FS | eff) Unit
325
-
fdRead fd buff off len pos cb = mkEff $ \_ -> runFn6 fs.read fd buff off len (toNullable pos) (handleCallback cb)
331
+
fdRead fd buff off len pos cb =
332
+
let
333
+
off' = toNumber off
334
+
len' = toNumber len
335
+
pos' = map toNumber pos
336
+
cb' x = cb (unsafePartial fromJust <<< fromNumber <$> x)
337
+
in
338
+
fdReadLarge fd buff off' len' pos' cb'
339
+
340
+
-- | Read from a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback)
341
+
-- | for details.
342
+
-- |
343
+
-- | This version takes and returns Number. It can read any file Node can.
344
+
fdReadLarge::foralleff.
345
+
FileDescriptor
346
+
->Buffer
347
+
->Number
348
+
->Number
349
+
->MaybeNumber
350
+
->Callback (buffer::BUFFER | eff) Number
351
+
->Eff (buffer::BUFFER, fs::FS | eff) Unit
352
+
fdReadLarge fd buff off len pos cb = mkEff $ \_ -> runFn6 fs.read fd buff off len (toNullable pos) (handleCallback cb)
326
353
327
354
-- | Convenience function to fill the whole buffer from the current
328
355
-- | file position.
@@ -337,6 +364,10 @@ fdNext fd buff cb = do
337
364
338
365
-- | Write to a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback)
339
366
-- | for details.
367
+
-- |
368
+
-- | The use of an Int as FilePosition restricts this API to writing
369
+
-- | files < 2GB. The call is retained to not break existing code.
370
+
-- | fdWriteLarge does not have this restriction.
340
371
fdWrite::foralleff.
341
372
FileDescriptor
342
373
->Buffer
@@ -345,7 +376,29 @@ fdWrite :: forall eff.
345
376
->MaybeFilePosition
346
377
->Callback (buffer::BUFFER | eff) ByteCount
347
378
->Eff (buffer::BUFFER, fs::FS | eff) Unit
348
-
fdWrite fd buff off len pos cb = mkEff $ \_ -> runFn6 fs.write fd buff off len (toNullable pos) (handleCallback cb)
379
+
fdWrite fd buff off len pos cb =
380
+
let
381
+
off' = toNumber off
382
+
len' = toNumber len
383
+
pos' = map toNumber pos
384
+
cb' x = cb (unsafePartial fromJust <<< fromNumber <$> x)
385
+
in
386
+
fdWriteLarge fd buff off' len' pos' cb'
387
+
388
+
-- | Write to a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback)
389
+
-- | for details.
390
+
-- |
391
+
-- | This version takes and returns Number. It can write any file Node can.
392
+
fdWriteLarge::foralleff.
393
+
FileDescriptor
394
+
->Buffer
395
+
->Number
396
+
->Number
397
+
->MaybeNumber
398
+
->Callback (buffer::BUFFER | eff) Number
399
+
->Eff (buffer::BUFFER, fs::FS | eff) Unit
400
+
fdWriteLarge fd buff off len pos cb = mkEff $ \_ -> runFn6 fs.write fd buff off len (toNullable pos) (handleCallback cb)
401
+
349
402
350
403
-- | Convenience function to append the whole buffer to the current
0 commit comments