From e3cdf7a5e0f8b1bc179effce49bdd34374fa9d2d Mon Sep 17 00:00:00 2001 From: Giorgio Calderone Date: Sun, 29 Mar 2020 14:21:11 +0200 Subject: [PATCH] Implemented cleanup of binary files --- src/Gnuplot.jl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Gnuplot.jl b/src/Gnuplot.jl index f6e4e4d..312bc39 100644 --- a/src/Gnuplot.jl +++ b/src/Gnuplot.jl @@ -444,6 +444,7 @@ end # ╰───────────────────────────────────────────────────────────────────╯ # --------------------------------------------------------------------- function reset(gp::DrySession) + delete_binaries(gp) gp.datas = Dict{String, DataSet}() gp.plots = [SinglePlot()] gp.curmid = 1 @@ -486,7 +487,7 @@ function add_dataset(gp::DrySession, name::String, args...) return gpsource catch err if isa(err, MethodError) - @warn "No method to handle binary data, resort to inline datablock..." + @warn "No method to write data as a binary file, resort to inline datablock..." else rethrow() end @@ -517,8 +518,19 @@ function add_plot(gp::DrySession, plotspec) end +# --------------------------------------------------------------------- +function delete_binaries(gp::DrySession) + for (name, d) in gp.datas + if d.file != "" # delete binary files + rm(d.file, force=true) + end + end +end + + # --------------------------------------------------------------------- function quit(gp::DrySession) + delete_binaries(gp) delete!(sessions, gp.sid) return 0 end