public static StreamReader OpenText(string filename, Encoding Enc) { Stream fStream; int errorCode = FileStream.OpenFileRead(filename, out fStream); return(errorCode != 0 ? null : new StreamReader(fStream, Enc)); }
public static int CheckFile(RvFile file, string directory) { string filename = Path.Combine(directory, file.Name); string ext = Path.GetExtension(filename).ToLower(); if (ext != ".chd") { return(0); } if (file.Size < MaxHeader) { return(0); } Stream s; int retval = FileStream.OpenFileRead(filename, out s); if (retval != 0) { return(retval); } if (s == null) { return(1); } CheckFile(s, out file.AltSHA1, out file.AltMD5, out file.CHDVersion); file.FileStatusSet( (file.AltSHA1 != null ? FileStatus.AltSHA1FromHeader : 0) | (file.AltMD5 != null ? FileStatus.AltMD5FromHeader : 0) ); s.Close(); s.Dispose(); return(0); }
public static int CheckFile(FileInfo ofile, out byte[] SHA1CHD, out byte[] MD5CHD, out uint?version) { SHA1CHD = null; MD5CHD = null; version = null; string ext = Path.GetExtension(ofile.Name).ToLower(); if (ext != ".chd") { return(0); } if (ofile.Length < MaxHeader) { return(0); } Stream s; int retval = FileStream.OpenFileRead(ofile.FullName, out s); if (retval != 0) { return(retval); } if (s == null) { return(1); } CheckFile(s, out SHA1CHD, out MD5CHD, out version); s.Close(); s.Dispose(); return(0); }