fi
}
-# Generate unique name - a bit more readable than mktemp creates. We assume
-# that we exclusively own the directory where we create the temporary file.
-seq_name()
+# Generate unique name for a file or directory in the "$1" subdirectory.
+# Currently we use the same format: <date>_<suffix>-<counter>, where <date> is
+# the current date (taken from the global $date variable), <suffix> is the
+# a suffix supplied by the caller via "$2", and <counter> is usually 0, but if
+# there is alreay a file with such name, it gets increased to 1, and so on.
+generate_file_name()
{
local where="$1"; shift
local suffix="$1"; shift
queue_mboxfile()
{
- local fname="$(seq_name "$queue" "$n")"
+ local fname="$(generate_file_name "$queue" "$n")"
cp $verbose -- "$mbox" "$queue_saved/${fname##*/}" >&2
mv $verbose -- "$mbox" "$fname" >&2
}
if [ -z "$staging_relatives" ] && [ -z "$series_relatives" ]; then
# Save the file in the staging area
- fname="$(seq_name "$staging" "$m-of-$n")"
+ fname="$(generate_file_name "$staging" "$m-of-$n")"
verbose "No relatives found, temporarily save in staging"
mv $verbose -- "$mbox" "$fname" >&2
return
if [ -z "$series_relatives" ]; then
# The series directory does not exist yet - create it
- dir="$(seq_name "$series" "$n")"
+ dir="$(generate_file_name "$series" "$n")"
verbose "Creating the series directory \"$dir\""
mkdir $verbose -- "$dir" >&2
else