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

Corrupted magicbytes #19

Closed
SimonDanisch opened this issue Aug 19, 2015 · 4 comments
Closed

Corrupted magicbytes #19

SimonDanisch opened this issue Aug 19, 2015 · 4 comments

Comments

@SimonDanisch
Copy link
Member

Right now this happens:

f = "test.nrrd" #empty file
load(f) 
#ERROR: No load function defined for format FileIO.DataFormat{:UNKNOWN} with filename test.nrrd
save(f) 
#ERROR: No save function defined for format FileIO.DataFormat{:UNKNOWN} with filename test.nrrd

For load we should probably fall back to the file ending or have something like DataFormat{:NRRD_CORRUPTED}.
For save it should probably just work and overwrite it. Or do we want to warn the user and make them use e.g. save! for overwriting?!

@timholy
Copy link
Member

timholy commented Aug 19, 2015

It already does:

FileIO.jl/src/query.jl

Lines 246 to 250 in cdffe63

if (length(len) == 1 && all(x->x==0, len)) || !isfile(filename)
# If there are no magic bytes, trust the extension
# Also, if we're about to create the file, it won't exist yet
return File{DataFormat{sym}}(filename)
end
. But nothing will happen if the format hasn't been registered.

@SimonDanisch
Copy link
Member Author

But not if there is an empty file with the name, as isfile becomes true...

@timholy
Copy link
Member

timholy commented Aug 19, 2015

Oh, I see. Sure, we should fall back on the extension more readily, then.

@timholy
Copy link
Member

timholy commented Mar 3, 2021

I think this is fixed.

@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