/// <summary> /// Decodes BXL's adaptive huffman encoded data from file and returns its text representation. /// </summary> public static async Task <string> DecodeFileAsync(string fileName, BxlFileType fileType = BxlFileType.FromExtension) { if (IsBinary(fileName, fileType)) { return(DecodeBxl(await File.ReadAllBytesAsync(fileName))); } else { return(await File.ReadAllTextAsync(fileName)); } }
/// <summary> /// Decodes BXL's adaptive huffman encoded data from file and returns its text representation. /// </summary> public static string DecodeFile(string fileName, BxlFileType fileType = BxlFileType.FromExtension) { if (IsBinary(fileName, fileType)) { return(DecodeBxl(File.ReadAllBytes(fileName))); } else { return(File.ReadAllText(fileName)); } }
/// <summary> /// Returns a BxlDocument from parsing a BXL file. /// </summary> /// <param name="fileName">File to be read.</param> /// <param name="fileType">Indicates the file type.</param> /// <param name="progress">Allows reporting progress for large files.</param> public static async Task <BxlDocument> ReadFromFileAsync(string fileName, BxlFileType fileType = BxlFileType.FromExtension, IProgress <int> progress = null) { var text = await DecodeFileAsync(fileName, fileType); return(ReadFromText(text, fileName, progress)); }
/// <summary> /// Returns a BxlDocument from parsing a BXL file. /// </summary> /// <param name="fileName">File to be read.</param> /// <param name="fileType">Indicates the file type.</param> /// <param name="progress">Allows reporting progress for large files.</param> public static BxlDocument ReadFromFile(string fileName, BxlFileType fileType = BxlFileType.FromExtension, IProgress <int> progress = null) { return(ReadFromFile(fileName, fileType, out _, progress)); }
/// <summary> /// Returns a BxlDocument from parsing a BXL file. /// </summary> /// <param name="fileName">File to be read.</param> /// <param name="fileType">Indicates the file type.</param> /// <param name="logs">Information gathered during the parsing process, including errors.</param> /// <param name="progress">Allows reporting progress for large files.</param> public static BxlDocument ReadFromFile(string fileName, BxlFileType fileType, out Logs logs, IProgress <int> progress = null) { var text = DecodeFile(fileName, fileType); return(ReadFromText(text, fileName, out logs, progress)); }
private static bool IsBinary(string fileName, BxlFileType fileType = BxlFileType.FromExtension) { // assume possible binary BXL if the extension is DIFFERENT from .XLR return(fileType == BxlFileType.Binary || (fileType == BxlFileType.FromExtension && Path.GetExtension(fileName) != ".xlr")); }