예제 #1
0
        /// <summary>
        /// Tries to find the GPG installation directory and configures the wrapper to use it.
        /// </summary>
        /// <param name="gpgExePath">Path to the GPG executable. When set to null,
        /// the default location will be used.</param>
        public void FindGpgInstallation(string gpgExePath = null)
        {
            Log.Send("Attempting to detect the GPG installation directory");
            if (gpgExePath == string.Empty)
            {
                throw new ArgumentException("The GPG installation path is invalid.");
            }
            GpgExePath = gpgExePath;

            string installDir = null;

            if (gpgExePath == null)
            {
                Log.Send("No GPG executable path set, assuming GPG to be in its default installation directory.");
                // No executable path is set, assume GPG to be in its default installation directory.
                installDir = gpgDefaultInstallDir;
            }
            else
            {
                if (File.Exists(gpgExePath))
                {
                    var directory = Path.GetDirectoryName(gpgExePath);
                    Log.Send("GPG executable found at the configured path. Assuming installation dir to be " + installDir);
                    installDir = Path.GetFullPath(directory);
                }
                else
                {
                    Log.Send("GPG executable not found. Restarting the GPG agent will not be possible.", LogLevel.Info);
                }
            }
            if (installDir != null)
            {
                gpgAgent = new GpgAgent(installDir);
            }
        }
예제 #2
0
        /// <summary>
        /// Tries to find the GPG installation directory and configures the wrapper to use it.
        /// </summary>
        /// <param name="gpgExePath">Path to the GPG executable. When set to null,
        /// the default location will be used.</param>
        public void FindGpgInstallation(string gpgExePath = null)
        {
            Log.Send("Attempting to detect the GPG installation directory");
            if (gpgExePath == string.Empty)
            {
                throw new ArgumentException("The GPG installation path is invalid.");
            }
            GpgExePath = gpgExePath;

            string installDir = null;

            if (gpgExePath == null)
            {
                Log.Send("No GPG executable path set, assuming GPG to be in its default installation directory.");
                // No executable path is set, assume GPG to be in its default installation directory.
                installDir = gpgDefaultInstallDir;
                GpgExePath = Path.Combine(installDir, gpgExeName);
            }
            else
            {
                var resolved = Helpers.ResolveExecutableName(gpgExePath);
                if (resolved == null || !File.Exists(resolved))
                {
                    // Executable couldn't be found, most likely it doesn't exist. This is probably an error.
                    throw new ArgumentException("The GPG installation path is invalid.");
                }
                GpgExePath = resolved;
                installDir = Path.GetDirectoryName(resolved);
                Log.Send("GPG executable found at the configured path. Assuming installation dir to be " + installDir);
            }
            gpgAgent = new GpgAgent(installDir);
        }