Skip to content

Commit

Permalink
Restructured code location. Fixed render_view returned path.
Browse files Browse the repository at this point in the history
  • Loading branch information
aptmcl committed Nov 23, 2023
1 parent e04de0b commit c58ddea
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
33 changes: 31 additions & 2 deletions src/Backend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1234,12 +1234,41 @@ export b_render_pathname, b_render_inital_setup, b_render_final_setup, b_setup_r
b_setup_render(b::Backend, kind) = kind

b_render_view(b::Backend, name) =
let path = b_render_pathname(b, name)
let path = prepare_for_saving_file(b_render_pathname(b, name))
b_render_final_setup(b, render_kind())
b_render_and_save_view(b, prepare_for_saving_file(path))
b_render_and_save_view(b, path)
path
end

#=
prepare_for_saving_file(path::String) =
let p = normpath(path)
mkpath(dirname(p))
rm(p, force=true)
isfile(p) ? # rm failed because file is locked
let (base, ext) = splitext(path)
prepare_for_saving_file(base*"_"*ext)
end :
p
end
=#
prepare_for_saving_file(path::String) =
let p = normpath(path)
mkpath(dirname(p))
try
rm(p, force=true)
p
catch e
if isa(e, Base.IOError)
let (base, ext) = splitext(path)
if ext == ".pdf"
prepare_for_saving_file(base*"_"*ext)
end
end
end
end
end

b_render_pathname(::Backend, name::String) = render_default_pathname(name)
b_render_initial_setup(::Backend, kind) = kind
b_render_final_setup(::Backend, kind) = kind
Expand Down
17 changes: 0 additions & 17 deletions src/Camera.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,6 @@ render_size() =
render_size(width::Integer, heigth::Integer) =
(render_width(width), render_height(heigth))

prepare_for_saving_file(path::String) =
let p = normpath(path)
mkpath(dirname(p))
try
rm(p, force=true)
p
catch e
if isa(e, Base.IOError)
let (base, ext) = splitext(path)
if ext == ".pdf"
prepare_for_saving_file(base*"_"*ext)
end
end
end
end
end

export film_active,
film_filename,
film_frame,
Expand Down

0 comments on commit c58ddea

Please sign in to comment.