-
Notifications
You must be signed in to change notification settings - Fork 5
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
Tries to parse non-existent file #68
Comments
The lack of check is actually an intentional design decision: Line 297 in 19e8549
This way, we can support anything that Calling On checking the content of the EDF ... well, trying to parse the file is in some sense the ultimate check of its content. 😄 |
That all definitely makes sense. But at the same time, trying to read the contents of a local folder definitely is nonsensical and not physically possible, so I think it confuses the situation to get an error message back complaining about a timestamp that couldn't be parsed. Maybe the fault here is with Base.open then. I can't see how you'd ever be able to get a stream of binary or textual data from a folder on any major OS, except some weirdness like reading the extended attributes.
|
Indeed, you can't: julia> open(read, "Downloads/")
UInt8[] But the ability to The issue here is that EDF.jl is calling initial_bytes = read(io, n)
length(initial_bytes) < n && throw(EOFError())
whatever = String(initial_bytes) An end of file error could at least be less cryptic than complaining about not being able to parse a date. |
I was thinking along the same lines. Let's say a file doesn't exist, or we open /dev/null, or the cases mentioned above - if the behaviour of Base.open is not necessarily ideal here, I think the lowest common denominator is that an EDF file, whether we read it all in or not, has a header and the length of that header is fixed or at least has a minimum (correct me if I'm wrong). We need a minimal number of bytes to be able to try and parse it; if we can't read in enough (or any) bytes to perform these steps then I think that is the point we can throw an error saying there's been some issue that is down to the filesystem/other storage backend and not due to reading bytes but not getting a valid EDF file. |
After hitting #66 and trying again using Ruby, I realise the path I actually gave
EDF.read
was a folder, and not a file! Checks on the path and basic opening of the file's content should be made before trying to parse the structures inside.The text was updated successfully, but these errors were encountered: