/// <summary> /// Manually deserialize a file reference from a binary stream. /// </summary> /// <param name="Reader">Binary reader to read from</param> /// <returns>New FileReference object</returns> public static FileReference ReadFileReference(this BinaryReader Reader) { string FullName = Reader.ReadString(); return((FullName.Length == 0) ? null : FileReference.MakeFromNormalizedFullPath(FullName)); }
/// <summary> /// Manually serialize a file reference to a binary stream. /// </summary> /// <param name="Writer">Binary writer to write to</param> public static void Write(this BinaryWriter Writer, FileReference File) { Writer.Write((File == null) ? String.Empty : File.FullName); }
/// <summary> /// Gets the parent directory for a file /// </summary> /// <param name="File">The file to get directory for</param> /// <returns>The full directory name containing the given file</returns> public static DirectoryReference GetParentDirectory(FileReference File) { int ParentLength = File.CanonicalName.LastIndexOf(Path.DirectorySeparatorChar); return(new DirectoryReference(File.FullName.Substring(0, ParentLength), File.CanonicalName.Substring(0, ParentLength))); }
/// <summary> /// Gets the parent directory for a file, or returns null if it's null. /// </summary> /// <param name="File">The file to create a directory reference for</param> /// <returns>The directory containing the file </returns> public static DirectoryReference FromFile(FileReference File) { return((File == null)? null : File.Directory); }
/// <summary> /// Adds a rule which matches a filename relative to a given base directory. /// </summary> /// <param name="FileName">The filename to add a rule for</param> /// <param name="BaseDirectoryName">Base directory for the rule</param> /// <param name="Type">Whether to add an include or exclude rule</param> public void AddRuleForFile(FileReference File, DirectoryReference BaseDirectory, FileFilterType Type) { AddRuleForFiles(new FileReference[] { File }, BaseDirectory, Type); }