private static string FileAttributesToString(P4FileAttributes Attributes) { var AllAttributes = GetEnumValuesAndKeywords(typeof(P4FileAttributes)); string Text = ""; foreach (var Attr in AllAttributes) { var AttrValue = (P4FileAttributes)Attr.Key; if ((Attributes & AttrValue) == AttrValue) { Text += Attr.Value; } } if (String.IsNullOrEmpty(Text) == false) { Text = "+" + Text; } return Text; }
/// <summary> /// Set file attributes (additively) /// </summary> /// <param name="Filename">File to change the attributes of.</param> /// <param name="Attributes">Attributes to set.</param> public static void ChangeFileType(string Filename, P4FileAttributes Attributes, string Changelist = null) { Log("ChangeFileType({0}, {1}, {2})", Filename, Attributes, String.IsNullOrEmpty(Changelist) ? "null" : Changelist); var Stat = FStat(Filename); if (String.IsNullOrEmpty(Changelist)) { Changelist = (Stat.Action != P4Action.None) ? Stat.Change : "default"; } // Only update attributes if necessary if ((Stat.Attributes & Attributes) != Attributes) { var CmdLine = String.Format("{0} -c {1} -t {2} {3}", (Stat.Action != P4Action.None) ? "reopen" : "open", Changelist, FileAttributesToString(Attributes | Stat.Attributes), Filename); LogP4(CmdLine); } }
public P4FileStat(P4FileType Type, P4FileAttributes Attributes, P4Action Action) { this.Type = Type; this.Attributes = Attributes; this.Action = Action; this.Change = String.Empty; this.IsOldType = false; }