//------------------------------------------------------------------------------------------- public static P4Result P4Checkout(string filePath, int changelist = -1) { if (System.IO.Directory.Exists(filePath)) { P4CheckoutDirectory(filePath, changelist); return(null); } else { char separtor = System.IO.Path.DirectorySeparatorChar; if (!filePath.Contains(separtor.ToString())) { separtor = System.IO.Path.AltDirectorySeparatorChar; } int lastSlashIndex = filePath.LastIndexOf(separtor) + 1; string directory = filePath.Substring(0, lastSlashIndex); string fileName = filePath.Substring(lastSlashIndex, filePath.Length - lastSlashIndex); if (changelist == -1) { return(Perforce.P4Command(directory, "edit " + fileName)); } else { Perforce.P4Command(directory, "edit -c " + changelist + " " + fileName); return(Perforce.P4Command(directory, "reopen -c " + changelist + " " + fileName)); } } }
//--------------------------------------------------------------------------------- public static P4Result P4RevertUnchanged(int changelist = -1) { if (changelist == -1) { return(Perforce.P4Command(Application.dataPath, "revert -a", false)); } else { return(Perforce.P4Command(Application.dataPath, "revert -a -c " + changelist, false)); } }
//------------------------------------------------------------------------------------------- public static P4Result P4Checkout(string workingDirectory, string filename, int changelist = -1) { if (changelist == -1) { return(Perforce.P4Command(workingDirectory, "edit " + filename)); } else { Perforce.P4Command(workingDirectory, "edit -c " + changelist + " " + filename); return(Perforce.P4Command(workingDirectory, "reopen -c " + changelist + " " + filename)); } }
//------------------------------------------------------------------------------------------- public static P4Result P4Add(string filePath, int changelist = -1) { char separtor = System.IO.Path.DirectorySeparatorChar; if (!filePath.Contains(separtor.ToString())) { separtor = System.IO.Path.AltDirectorySeparatorChar; } int lastSlashIndex = filePath.LastIndexOf(separtor) + 1; string directory = filePath.Substring(0, lastSlashIndex); string fileName = filePath.Substring(lastSlashIndex, filePath.Length - lastSlashIndex); if (changelist == -1) { return(Perforce.P4Command(directory, "add -f " + fileName)); } else { return(Perforce.P4Command(directory, "add -c " + changelist + " -f " + fileName)); } }
//------------------------------------------------------------------------------------------- public static void P4CheckoutDirectory(string dirPath, int changelist = -1) { string path = dirPath; if (!System.IO.Directory.Exists(path)) { return; } if (!path.EndsWith("/")) { path += "/"; } if (changelist == -1) { Perforce.P4Command(path, "edit " + path + "..."); } else { Perforce.P4Command(path, "edit -c " + changelist + " " + path + "...", false); Perforce.P4Command(path, "reopen -c " + changelist + " " + path + "...", false); //reopen so that any already open files are moved there } }