protected override SRFile CreateFromStream(string path, Stream stream) { var file = new SCUMM1File(path, (XorStream)stream); ; if (!CheckFormat(path, file)) { file.Close(); file = null; } return(file); }
private bool CheckFormat(string path, SCUMM1File file) { // Detection here is a bit hacky: // - We NEED the file to be named xx.LFL // - We NEED the file to be stored along with the 00.LFL directory (it provides our check) // - We NEED it to use the same encryption as the directory if (!String.Equals(Path.GetExtension(path), ".lfl", StringComparison.OrdinalIgnoreCase)) { // Not the correct file extension return(false); } int fileNumber; string strFileNumber = Path.GetFileNameWithoutExtension(path); if (!Int32.TryParse(strFileNumber, out fileNumber)) { // Not the correct file name (decimal digits) return(false); } if (fileNumber == 0) { // Directory file file.IsDirectory = true; file.FileVersion = GetDirectoryVersion(file); } else { // Resource file - determine version through Directory file var directoryFile = SCUMM1File.OpenDirectory(path); if (directoryFile == null) { return(false); } file.FileVersion = GetDirectoryVersion(directoryFile); file.Encryption = directoryFile.Encryption; directoryFile.Close(); } return(true); }