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

Should there be a load! function? #171

Closed
2 of 6 tasks
evetion opened this issue Jan 10, 2018 · 1 comment
Closed
2 of 6 tasks

Should there be a load! function? #171

evetion opened this issue Jan 10, 2018 · 1 comment

Comments

@evetion
Copy link

evetion commented Jan 10, 2018

FileIO now implements following modes of open() by using load() and save()

  • r | read
  • r+ | read, write
  • w | write, create, truncate
  • w+ | read, write, create, truncate
  • a | write, create, append
  • a+ | read, write, create, append

I'd like to implement load!() in my packages for opening files in (at least) r+ mode. This helps with large, streamed, files that I don't want to duplicate by using load and save.

At the moment I would do:

function load(f::File{format"example"}; mutable=false)
     # file, readable, writable, create, truncate, append
     open(f, true, mutable, false, false, false) do s
       ..etc..

load!(f::File{format"") = load(f, mutable=true)

But should FileIO also export FileIO.load!? I guess the same can be asked for #78, where my use case is partly implemented (streaming). We could in theory also export a loadstreaming! method.

@timholy
Copy link
Member

timholy commented Mar 3, 2021

If you still want this, a keyword argument would be the way to go to pass the file-opening mode. But of course you can do this manually by opening the file and passing a stream.

Since this may already be possible, I'll close this pending a PR.

@timholy timholy closed this as completed Mar 3, 2021
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

No branches or pull requests

2 participants