Skip to content

Commit

Permalink
add uuids to TiffFile (#67)
Browse files Browse the repository at this point in the history
This field is helpful for OMETIFF because it allows proper tracking of
files even if filenames have been changed. Needed for
tlnagy/OMETIFF.jl#12
  • Loading branch information
tlnagy authored Oct 19, 2021
1 parent a197766 commit bbd032d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ Inflate = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
PkgVersion = "eebad327-c553-4316-9ea0-9fa01ccd7688"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
ColorTypes = "0.10, 0.11"
DataStructures = "0.18"
DocStringExtensions = "0.8.3"
FileIO = "1"
FixedPointNumbers = "0.8"
IndirectArrays = "0.5.1, 1"
Inflate = "0.1.2"
OffsetArrays = "1"
DataStructures = "0.18"
PkgVersion = "0.1.1"
ProgressMeter = "1"
julia = "1.3"
1 change: 1 addition & 0 deletions src/TiffImages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ using PkgVersion
using ProgressMeter
using Base.Iterators
using Inflate
using UUIDs

const PKGVERSION = @PkgVersion.Version 0

Expand Down
7 changes: 5 additions & 2 deletions src/files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Wrap `io` with helper parameters to keep track of file attributes.
$(FIELDS)
"""
mutable struct TiffFile{O <: Unsigned, S <: Stream}
"""A unique identifier for this file"""
uuid::Union{UUID, Nothing}

"""The relative path to this file"""
filepath::String

Expand All @@ -19,7 +22,7 @@ mutable struct TiffFile{O <: Unsigned, S <: Stream}
need_bswap::Bool
end

TiffFile{O}(s::Stream) where O <: Unsigned = TiffFile{O, typeof(s)}("", s, -1, false)
TiffFile{O}(s::Stream) where O <: Unsigned = TiffFile{O, typeof(s)}(nothing, "", s, -1, false)
TiffFile{O}(io::IO) where O <: Unsigned = TiffFile{O}(getstream(format"TIFF", io))
TiffFile{O}() where O <: Unsigned = TiffFile{O}(IOBuffer())

Expand All @@ -30,7 +33,7 @@ function Base.read(io::Stream, ::Type{TiffFile})
offset_size = offsetsize(io)
first_offset_raw = read(io, offset_size)
first_offset = Int(bs ? bswap(first_offset_raw) : first_offset_raw)
TiffFile{offset_size, typeof(io)}(filepath, io, first_offset, bs)
TiffFile{offset_size, typeof(io)}(nothing, filepath, io, first_offset, bs)
end

Base.read(io::IOStream, t::Type{TiffFile}) = read(getstream(format"TIFF", io, extract_filename(io)), t)
Expand Down

2 comments on commit bbd032d

@tlnagy
Copy link
Owner Author

@tlnagy tlnagy commented on bbd032d Oct 20, 2021

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/47141

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.0 -m "<description of version>" bbd032d666d87487df1836097f8b5e65c5f3739e
git push origin v0.5.0

Please sign in to comment.