diff --git a/README.md b/README.md index d06533c..051c3ca 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ following Mix config: ```elixir config :briefly, directory: [{:system, "TMPDIR"}, {:system, "TMP"}, {:system, "TEMP"}, "/tmp"], + sub_directory: "briefly", default_prefix: "briefly", default_extname: "" ``` diff --git a/lib/briefly/config.ex b/lib/briefly/config.ex index 7b7d0d2..3e141aa 100644 --- a/lib/briefly/config.ex +++ b/lib/briefly/config.ex @@ -3,6 +3,8 @@ defmodule Briefly.Config do def directory, do: get(:directory) + def sub_directory, do: get(:sub_directory) + def default_prefix, do: get(:default_prefix) def default_extname, do: get(:default_extname) diff --git a/lib/briefly/entry.ex b/lib/briefly/entry.ex index 211d717..c38f0e9 100644 --- a/lib/briefly/entry.ex +++ b/lib/briefly/entry.ex @@ -18,9 +18,10 @@ defmodule Briefly.Entry do def init(_init_arg) do tmp = Briefly.Config.directory() + sub = Briefly.Config.sub_directory() cwd = Path.join(File.cwd!(), "tmp") ets = :ets.new(:briefly, [:private]) - {:ok, {[tmp, cwd], ets}} + {:ok, {[tmp, cwd, sub], ets}} end def handle_call({:create, opts}, {caller_pid, _ref}, {tmps, ets} = state) do @@ -68,7 +69,8 @@ defmodule Briefly.Entry do defp ensure_tmp_dir(tmps) do {mega, _, _} = :os.timestamp() - subdir = "briefly-" <> i(mega) + [_tmp, _cwd, sub] = tmps + subdir = sub <> "-" <> i(mega) Enum.find_value(tmps, &write_tmp_dir(&1 <> subdir)) end diff --git a/mix.exs b/mix.exs index 6cfbdf7..c4025a1 100644 --- a/mix.exs +++ b/mix.exs @@ -49,6 +49,7 @@ defmodule Briefly.Mixfile do defp default_env do [ directory: [{:system, "TMPDIR"}, {:system, "TMP"}, {:system, "TEMP"}, "/tmp"], + sub_directory: "briefly", default_prefix: "briefly", default_extname: "" ]