pragmatic v0.1.3 Pragmatic.Windows

Utility functions specifically for dealing with issues which arise when using Elixir on Windows.

Summary

Functions

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

get_short_name(path)

Specs

get_short_name(Path.t) :: Path.t

Take a long Windows path or a path with spaces in it and return the 8.3 version of that name

The function will throw a runtime error if you attempt to invoke it on a path that doesn’t exist. E. g.

Examples

iex> Pragmatic.Windows.get_short_name("c:/nosuchpath")
** (RuntimeError) The specified directory "c:/nosuchpath" does not exist

A runtime error will also be thrown if you attempt to run this function on a non-Windows OS.

Otherwise, you want to pass a directory using forward slashes as the path separator (yes, this does work on Windows)

iex> Pragmatic.Windows.get_short_name("c:/program files")
"c:/PROGRA~1"

iex> Pragmatic.Windows.get_short_name("c:/users")
"c:/Users"
user_is_admin?()

Specs

user_is_admin? :: boolean

Is the currently logged-in user an admin?