Class | ChefConfig::PathHelper |
In: |
lib/chef-config/path_helper.rb
|
Parent: | Object |
WIN_MAX_PATH | = | 259 | Maximum characters in a standard Windows path (260 including drive letter and NUL) | |
BACKSLASH | = | '\\'.freeze |
See self.home. This method performs a similar operation except that it yields all the different possible values of ‘HOME’ that one could have on this platform. Hence, on windows, if HOMEDRIVE\HOMEPATH and USERPROFILE are different, the provided block will be called twice. This method goes out and checks the existence of each location at the time of the call.
The return is a list of all the returned values from each block invocation or a list of paths if no block is provided.
This is the INVERSE of Pathname#cleanpath, it converts forward slashes to backwhacks for Windows. Since the Ruby API and the Windows APIs all consume forward slashes, this helper function should only be used for DISPLAY logic to send strings back to the user with backwhacks. Internally, filename paths should generally be stored with forward slashes for consistency. It is not necessary or desired to blindly convert pathnames to have backwhacks on Windows.
Generally, if the user isn‘t going to be seeing it, you should be using Pathname#cleanpath intead of this function.
@deprecated this method is deprecated. Please use escape_glob_dirs Paths which may contain glob-reserved characters need to be escaped before globbing can be done. stackoverflow.com/questions/14127343
This function does not switch to backslashes for windows This is because only forwardslashes should be used with dir (even for windows)
Retrieves the "home directory" of the current user while trying to ascertain the existence of said directory. The path returned uses / for all separators (the ruby standard format). If the home directory doesn‘t exist or an error is otherwise encountered, nil is returned.
If a set of path elements is provided, they are appended as-is to the home path if the homepath exists.
If an optional block is provided, the joined path is passed to that block if the home path is valid and the result of the block is returned instead.
Home-path discovery is performed once. If a path is discovered, that value is memoized so that subsequent calls to home_dir don‘t bounce around.
@see all_homes @param args [Array<String>] Path components to look for under the home directory. @return [String]
Splits a string into an array of tokens as commands and arguments
str = ‘command with "some arguments"’ split_args(str) => ["command", "with", "\"some arguments\""]