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

Prototype for magic numbers #13

Closed
SimonDanisch opened this issue May 4, 2015 · 1 comment
Closed

Prototype for magic numbers #13

SimonDanisch opened this issue May 4, 2015 · 1 comment

Comments

@SimonDanisch
Copy link
Member

Hi, what do you all think of this way of loading and registering file extensions?
https://github.com/JuliaIO/FileIO.jl/blob/master/src/core_prototype.jl
It's just a crude prototype by now:

# Example taken from MeshIO
#Registering a file format
#Mime(unique_identifier, file_ending, magic_number)
const ply_binary = Mime(:ply_binary, :ply, b"ply\nformat binary_little_endian 1.0\n")
const ply_ascii  = Mime(:ply_ascii,  :ply, b"ply\nformat ascii 1.0\n")

file = file"test_ascii.ply" #just wraps the path in the file type
obj = load(file) # tries to find mime and opens io stream and returns appropriate julia object
obj = load(file, GLNormalMesh) # tries to return a GLNormalMesh while loading
obj = GLNormalMesh(file) # just works if defined in the mesh package, as call(::Type{Any}, ::File) leads
# to millions of ambiguity warnings

this is heavily inspired by the approach taken in Images.jl ( I'm not sure who wrote this particular code, but probably @timholy can say something about this)

Best,
Simon

@timholy
Copy link
Member

timholy commented Aug 9, 2015

Closed by #15

@timholy timholy closed this as completed Aug 9, 2015
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