public bool Run(PerforceConnection Perforce, TextWriter Log, out string ErrorMessage)
            {
                PerforceConnection PerforceClient = new PerforceConnection(Perforce.UserName, ClientName, Perforce.ServerAndPort);

                PerforceSpec ClientSpec;

                if (!PerforceClient.TryGetClientSpec(Perforce.ClientName, out ClientSpec, Log))
                {
                    ErrorMessage = String.Format("Unable to get client spec for {0}", ClientName);
                    return(false);
                }

                string ClientRoot = ClientSpec.GetField("Root");

                if (String.IsNullOrEmpty(ClientRoot))
                {
                    ErrorMessage = String.Format("Client '{0}' does not have a valid root directory.", ClientName);
                    return(false);
                }

                List <PerforceFileRecord> FileRecords = new List <PerforceFileRecord>();

                foreach (string Pattern in Patterns)
                {
                    string Filter = String.Format("//{0}/{1}", ClientName, Pattern);

                    List <PerforceFileRecord> WildcardFileRecords = new List <PerforceFileRecord>();
                    if (!PerforceClient.FindFiles(Filter, out WildcardFileRecords, Log))
                    {
                        ErrorMessage = String.Format("Unable to enumerate files matching {0}", Filter);
                        return(false);
                    }

                    FileRecords.AddRange(WildcardFileRecords);
                }

                string ClientPrefix = ClientRoot + Path.DirectorySeparatorChar;

                Paths = new List <string>();
                foreach (PerforceFileRecord FileRecord in FileRecords)
                {
                    if (FileRecord.ClientPath.StartsWith(ClientPrefix, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Paths.Add(FileRecord.ClientPath.Substring(ClientRoot.Length).Replace(Path.DirectorySeparatorChar, '/'));
                    }
                }

                ErrorMessage = null;
                return(true);
            }
Exemple #2
0
            public bool Run(PerforceConnection Perforce, TextWriter Log, out string ErrorMessage)
            {
                this.ServerAndPort = Perforce.ServerAndPort;
                this.UserName      = Perforce.UserName;

                PerforceSpec Spec;

                if (!Perforce.TryGetClientSpec(WorkspaceName, out Spec, Log))
                {
                    ErrorMessage = String.Format("Unable to get info for client '{0}'", WorkspaceName);
                    return(false);
                }

                string CurrentStreamName = Spec.GetField("Stream");

                if (CurrentStreamName == null || CurrentStreamName != StreamName)
                {
                    bRequiresStreamSwitch = true;
                    bHasOpenFiles         = Perforce.HasOpenFiles(Log);
                }

                ErrorMessage = null;
                return(true);
            }