示例#1
0
 private static ProcessResult CallPowershellCommand(string command)
 {
     return(ProcessHelper.Run("powershell.exe", "-NonInteractive -NoProfile -Command \"& { " + command + " }\""));
 }
 public static string CurrentGVFSVersion()
 {
     return(ProcessHelper.GetCurrentProcessVersion());
 }
示例#3
0
        /// <summary>
        /// Allows external callers (non-GVFS) to acquire the lock.
        /// </summary>
        /// <param name="requester">The data for the external acquisition request.</param>
        /// <param name="holder">
        /// The current holder of the lock if the acquisition fails, or
        /// the input request if it succeeds.
        /// </param>
        /// <returns>True if the lock was acquired, false otherwise.</returns>
        public bool TryAcquireLock(
            NamedPipeMessages.LockData requester,
            out NamedPipeMessages.LockData holder)
        {
            EventMetadata metadata   = new EventMetadata();
            EventLevel    eventLevel = EventLevel.Verbose;

            metadata.Add("LockRequest", requester.ToString());
            try
            {
                lock (this.acquisitionLock)
                {
                    if (this.IsLockedByGVFS)
                    {
                        holder = null;
                        metadata.Add("CurrentLockHolder", "GVFS");
                        metadata.Add("Result", "Denied");

                        return(false);
                    }

                    if (this.lockHolder != null &&
                        this.lockHolder.PID != requester.PID)
                    {
                        holder = this.lockHolder;

                        metadata.Add("CurrentLockHolder", this.lockHolder.ToString());
                        metadata.Add("Result", "Denied");
                        return(false);
                    }

                    metadata.Add("Result", "Accepted");
                    eventLevel = EventLevel.Informational;

                    Process process;
                    if (ProcessHelper.TryGetProcess(requester.PID, out process))
                    {
                        this.processWatcher.WatchForTermination(requester.PID, GVFSConstants.CommandParentExePrefix);

                        process.Dispose();
                        this.lockHolder = requester;
                        holder          = requester;
                        this.externalLockReleased.Reset();

                        return(true);
                    }
                    else
                    {
                        // Process is no longer running so let it
                        // succeed since the process non-existence
                        // signals the lock release.
                        if (process != null)
                        {
                            process.Dispose();
                        }

                        holder = null;
                        return(true);
                    }
                }
            }
            finally
            {
                this.tracer.RelatedEvent(eventLevel, "TryAcquireLockExternal", metadata);
            }
        }
示例#4
0
        public static bool IsDevelopmentVersion()
        {
            Version currentVersion = new Version(ProcessHelper.GetCurrentProcessVersion());

            return(currentVersion.Major == 0);
        }