Exemplo n.º 1
0
        /// <summary>
        /// Used to get all profile file names for the current or all hosts and for the current or all users.
        /// </summary>
        /// <param name="shellId">null for all hosts, not null for the specified host</param>
        /// <param name="forCurrentUser">false for all users, true for the current user.</param>
        /// <param name="useTestProfile">used from test not to overwrite the profile file names from development boxes</param>
        /// <returns>The profile file name matching the parameters.</returns>
        internal static string GetFullProfileFileName(string shellId, bool forCurrentUser, bool useTestProfile)
        {
            string basePath = null;

            if (forCurrentUser)
            {
#if UNIX
                basePath = Platform.SelectProductNameForDirectory(Platform.XDG_Type.CONFIG);
#else
                basePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                basePath = IO.Path.Combine(basePath, Utils.ProductNameForDirectory);
#endif
            }
            else
            {
                basePath = GetAllUsersFolderPath(shellId);
                if (string.IsNullOrEmpty(basePath))
                {
                    return("");
                }
            }

            string profileName = useTestProfile ? "profile_test.ps1" : "profile.ps1";

            if (!string.IsNullOrEmpty(shellId))
            {
                profileName = shellId + "_" + profileName;
            }

            string fullPath = basePath = IO.Path.Combine(basePath, profileName);

            return(fullPath);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the path to $HOME.
        /// </summary>
        internal static string GetUserHomeHelpSearchPath()
        {
            if (userHomeHelpPath == null)
            {
#if UNIX
                var    userModuleFolder  = Platform.SelectProductNameForDirectory(Platform.XDG_Type.USER_MODULES);
                string userScopeRootPath = System.IO.Path.GetDirectoryName(userModuleFolder);
#else
                string userScopeRootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "PowerShell");
#endif
                userHomeHelpPath = Path.Combine(userScopeRootPath, "Help");
            }

            return(userHomeHelpPath);
        }