diff --git a/Project.toml b/Project.toml index a09126e..191201d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LoopFieldCalc" uuid = "896acac2-5fe1-47fe-8ead-27e3a9bc5c85" authors = ["Thomas Marks and contributors"] -version = "0.2.3" +version = "0.2.4" [deps] Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" diff --git a/src/LoopFieldCalc.jl b/src/LoopFieldCalc.jl index 89f167e..b5f9006 100644 --- a/src/LoopFieldCalc.jl +++ b/src/LoopFieldCalc.jl @@ -112,7 +112,10 @@ end Write magnetic field to Tecplot ASCII datafile for two-dimensional data """ function write_field(filename, xs, ys, Bx, By) - mkpath(joinpath(splitpath(filename)[1:end-1]...)) + split_fname = splitpath(filename) + if length(split_fname) > 1 # If file is in folder, make sure that folder exists + mkpath(joinpath(split_fname[1:end-1]...)) + end Nx, Ny= length(xs), length(ys) open(filename, "w") do f println(f, "VARIABLES = \"X\" \"Y\" \"Bx\" \"By\"") @@ -129,7 +132,10 @@ end Write magnetic field to Tecplot ASCII datafile for three-dimensional data """ function write_field(filename, xs, ys, zs, Bx, By, Bz) - mkpath(joinpath(splitpath(filename)[1:end-1]...)) + split_fname = splitpath(filename) + if length(split_fname) > 1 # If file is in folder, make sure that folder exists + mkpath(joinpath(split_fname[1:end-1]...)) + end Nx, Ny, Nz = length(xs), length(ys), length(zs) open(filename, "w") do f println(f, "VARIABLES = \"X\" \"Y\" \"Z\" \"Bx\" \"By\" \"Bz\"")