pragmatic v0.1.7 Pragmatic.Windows
Utility functions for dealing with issues which arise when using Elixir on Windows.
Summary
Functions
Return the name of the user the current process is running under. This is handy for logging errors
Take a long Windows path or a path with spaces in it and return the 8.3 version of that name
Is the currently logged-in user an admin?
Functions
Specs
get_current_user([{:show_domain, boolean}]) :: String.t
Return the name of the user the current process is running under. This is handy for logging errors.
Parameters
show_domain: (boolean)
- if true, return the current user in the domain\user format. Otherwise, just return user.
Examples
iex> Pragmatic.Windows.get_current_user(show_domain: false)
"ocatenacci"
iex> Pragmatic.Windows.get_current_user(show_domain: true)
"RIIS\\ocatenacci"
Take a long Windows path or a path with spaces in it and return the 8.3 version of that name
A runtime error will also be thrown if you attempt to run this function on a non-Windows OS. Also, the function will throw a runtime error if you attempt to invoke it on a path that doesn’t exist. Otherwise, you should specify the directory in the format drive:/dir/dir/dir etc. Contrary to the common, mistaken believe forward slashes can be used as a directory separator on Windows.
Examples
iex> Pragmatic.Windows.get_short_name("c:/nosuchpath")
** (RuntimeError) The specified directory "c:/nosuchpath" does not exist
iex> Pragmatic.Windows.get_short_name("c:/program files")
"c:/PROGRA~1"
iex> Pragmatic.Windows.get_short_name("c:/users")
"c:/Users"