using UnityEditor; using UnityEngine; using Perforce.P4; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace P4Connect { public class OpenedConnection { public PerforceConnection Connection { get { return _Connection; } } public IList<File> Files { get { return _Files; } } // Give read-only access to the server we're connected to public Server P4Server { get { return _Connection.P4Server; } } // Give read-only access to the current depot public Repository P4Depot { get { return _Connection.P4Depot; } } // Give read-only access to the current connection public Connection P4Connection { get { return _Connection.P4Depot.Connection; } } // Give read-only access to the current client public Client P4Client { get { return _Connection.P4Depot.Connection.Client; } } public IEnumerable<string> LocalOpenedFiles { get { if (_Files != null) { for (int i = 0; i < _Files.Count; ++i) { yield return Utils.ClientPathToLocalPath(_Files[i].ClientPath.Path); } } } } PerforceConnection _Connection; List<File> _Files; public OpenedConnection(PerforceConnection aOpenedConnection) { _Connection = aOpenedConnection; Options opts = new Options(); opts["-c"] = "default"; opts["-C"] = Config.Workspace; IList<File> allOpenedFiles = aOpenedConnection.P4Depot.GetOpenedFiles(null, opts); if (allOpenedFiles != null) { _Files = new List<File>(allOpenedFiles); } else { _Files = new List<File>(); } } /// <summary> /// Helper method to check if a file is in the depot list /// </summary> /// <param name="arOpenedFiles"></param> /// <param name="match"></param> /// <returns></returns> public bool Contains(Predicate<File> aMatch) { if (Files == null) { return false; } else { foreach (File file in Files) { if (aMatch(file)) return true; } return false; } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 16210 | Norman Morse | Remove files from old locations | ||
#2 | 12512 | Norman Morse | Integrate from Dev branch, preparing for Beta3 release | ||
#1 | 10940 | Norman Morse |
Inital Workshop release of P4Connect. Released under BSD-2 license |