Skip to content
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

Add copyFile/copyFileSync (and remove unused fbs table WriteFileSync) #863

Merged
merged 2 commits into from
Sep 30, 2018

Conversation

kevinkassimo
Copy link
Contributor

What is in this PR

  • Add deno.copyFile(from, to) and deno.copyFileSync(from, to)
  • Delete unused flatbuffers table WriteFileSync

Implementation reference

  • Go: open file and then io.Copy(to, from)
  • Node: fs.copyFile(src, dest[, flags], callback)
  • Rust: std::fs::copy(from: P, to: Q)
  • Ruby: FileUtils.copy_file(src, dest, preserve = false, dereference = true)

Details

Implemented copyFile since it is a handy call.
An alternative implementation could have been done by using deno.File, open 2 files and do copy between file descriptors, but would require multiple serialization/deserialization instead of once.

Removed table WriteFileSync { ... } from msg.fbs since I could not found where it is used. It was introduced in #846, probably due to a rebase/merge error.

@kevinkassimo kevinkassimo changed the title Add copyFile/copyFileSync (and remove unused WriteFileSync) Add copyFile/copyFileSync (and remove unused fbs table WriteFileSync) Sep 30, 2018
@ry
Copy link
Member

ry commented Sep 30, 2018

Thanks

io.Copy is not this function in Go. It doesn't exist in Go. I'm slightly concerned about adding it because of that fact.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hesitant to add this because Go doesn't have it - but I think it's useful functionality to have and your implementation is well tested and simple. LGTM (but please split the commit into two - see comment below)

src/msg.fbs Outdated
perm: uint;
// perm specified by https://godoc.org/os#FileMode
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - thanks - can you remove this in a standalone commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ry ry merged commit 50a9c2b into denoland:master Sep 30, 2018
ry added a commit to ry/deno that referenced this pull request Oct 4, 2018
- Improve fetch headers (denoland#853)
- Add deno.truncate (denoland#805)
- Add copyFile/copyFileSync (denoland#863)
- Limit depth of output in console.log for nested objects, and add
  console.dir (denoland#826)
- Guess extensions on extension not provided (denoland#859)
- Renames:
  deno.platform -> deno.platform.os
  deno.arch -> deno.platform.arch
- Upgrade TS to 3.0.3
- Add readDirSync(), readDir()
- Add support for TCP servers and clients. (denoland#884)
  Adds deno.listen(), deno.dial(), deno.Listener and deno.Conn.
@ry ry mentioned this pull request Oct 4, 2018
ry added a commit that referenced this pull request Oct 4, 2018
- Improve fetch headers (#853)
- Add deno.truncate (#805)
- Add copyFile/copyFileSync (#863)
- Limit depth of output in console.log for nested objects, and add
  console.dir (#826)
- Guess extensions on extension not provided (#859)
- Renames:
  deno.platform -> deno.platform.os
  deno.arch -> deno.platform.arch
- Upgrade TS to 3.0.3
- Add readDirSync(), readDir()
- Add support for TCP servers and clients. (#884)
  Adds deno.listen(), deno.dial(), deno.Listener and deno.Conn.
@kevinkassimo kevinkassimo deleted the fs/copy_file branch December 27, 2019 07:52
hardfist pushed a commit to hardfist/deno that referenced this pull request Aug 7, 2024
Bumped versions for 0.302.0

Please ensure:
- [x] Crate versions are bumped correctly
To make edits to this PR:
```shell
git fetch upstream release_0_302.0 && git checkout -b release_0_302.0 upstream/release_0_302.0
```

cc @devsnek

Co-authored-by: devsnek <devsnek@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants