private void CacheModule(IodineModule module) { try { string cacheDir = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(Path), ".iodine_cache" ); if (!Directory.Exists(cacheDir)) { Directory.CreateDirectory(cacheDir); } string filePath = System.IO.Path.Combine( cacheDir, System.IO.Path.GetFileNameWithoutExtension(Path) + ".bytecode" ); using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate)) { BytecodeFile testFile = new BytecodeFile(fs, Path); testFile.WriteModule(module as ModuleBuilder); } } catch (UnauthorizedAccessException) { } }
private bool LoadCachedModule(ref IodineModule module) { string cacheDir = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(Path), ".iodine_cache" ); if (!Directory.Exists(cacheDir)) { return(false); } string filePath = System.IO.Path.Combine( cacheDir, System.IO.Path.GetFileNameWithoutExtension(Path) + ".bytecode" ); if (!File.Exists(filePath)) { return(false); } using (FileStream fs = new FileStream(filePath, FileMode.Open)) { BytecodeFile testFile = new BytecodeFile(fs, Path); return(testFile.TryReadModule(ref module)); } }