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

Remove as much dependencies as possible #172

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ authors = ["Rory Finnegan"]
version = "0.9.21"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[weakdeps]
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"

[extensions]
FilePathsBaseMmapExt = "Mmap"

[compat]
Compat = "3.33, 4"
longemen3000 marked this conversation as resolved.
Show resolved Hide resolved
julia = "1"
Mmap = "<0.0.1, 1"

[extras]
JLSO = "9da8a3cd-07a3-59c0-a743-3fdc52c30d11"
Expand Down
7 changes: 7 additions & 0 deletions ext/FilePathsBaseMmapExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module FilePathsBaseMmapExt
using Mmap
using FilePathsBase

Mmap.mmap(fp::FilePathsBase.SystemPath, args...; kwargs...) = Mmap.mmap(string(fp), args...; kwargs...)

end #module
10 changes: 6 additions & 4 deletions src/FilePathsBase.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
module FilePathsBase

using Compat
using Dates
using Mmap
using Printf
using UUIDs

import Base: ==
import Base: UUID

export
# Types
AbstractPath,
Expand Down Expand Up @@ -134,4 +132,8 @@ include("windows.jl")
include("test.jl")
include("deprecates.jl")

if !isdefined(Base,:get_extension)
include("../ext/FilePathsBaseMmapExt.jl")
end

end # end of module
9 changes: 7 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
function uuid4(rng::AbstractRNG=Random.RandomDevice())
longemen3000 marked this conversation as resolved.
Show resolved Hide resolved
u = rand(rng, UInt128)
u &= 0xffffffffffff0fff3fffffffffffffff
u |= 0x00000000000040008000000000000000
UUID(u)
end
# Mostly copied from https://github.com/IainNZ/Humanize.jl/blob/master/src/Humanize.jl#L27
function _datasize(bytes::Number)
base = 1024.0
Expand All @@ -13,6 +19,5 @@ function _datasize(bytes::Number)
break
end
end

return @sprintf("%.1f%s", (base * nbytes / unit), suffix)
return string(round(base * nbytes / unit,digits = 1)) * suffix
end