-# Internal functions. {{{
-# Internal: stack of entered (and handled) directories. {{{
-typeset -g -a _autoenv_stack_entered
-# -g: make it global, this is required when used with antigen.
-typeset -g -A _autoenv_stack_entered_mtime
-
-# Add an entry to the stack, and remember its mtime.
-_autoenv_stack_entered_add() {
- local env_file=$1
-
- # Remove any existing entry.
- _autoenv_stack_entered_remove $env_file
-
- _autoenv_debug "[stack] adding: $env_file" 2
-
- # Append it to the stack, and remember its mtime.
- _autoenv_stack_entered+=($env_file)
- _autoenv_stack_entered_mtime[$env_file]=$(_autoenv_get_file_mtime $env_file)
-}
-
-
-# zstat_mime helper, conditionally defined.
-# Load zstat module, but only its builtin `zstat`.
-if ! zmodload -F zsh/stat b:zstat 2>/dev/null; then
- # If the module is not available, define a wrapper around `stat`, and use its
- # terse output instead of format, which is not supported by busybox.
- # Assume '+mtime' as $1.
- _autoenv_get_file_mtime() {
- # setopt localoptions pipefail
- local stat
- stat=$(stat -t $1 2>/dev/null)
- if [[ -n $stat ]]; then
- echo ${${(s: :)stat}[13]}
- else
- echo 0
- fi
- }
-else
- _autoenv_get_file_mtime() {
- zstat +mtime $1 2>/dev/null || echo 0
- }
-fi
-
-
-# Remove an entry from the stack.