public override bool Equals(object obj) { FileWithVersionInfo info = obj as FileWithVersionInfo; if (info == null) { return(false); } return((string.Equals(this.FilePath, info.FilePath, StringComparison.InvariantCultureIgnoreCase) && (this.LastWriteTimeUtc == info.LastWriteTimeUtc)) && (this.Length == info.Length)); }
private void CopyFileToShadow(string lastShadow, FileWithVersionInfo r) { string fileName = Path.GetFileName(r.FilePath); string destFileName = Path.Combine(this._shadowFolder, fileName); if (lastShadow != null) { try { string str3 = Path.Combine(lastShadow, fileName); FileInfo info = new FileInfo(str3); if ((info.Exists && (info.LastWriteTimeUtc == r.LastWriteTimeUtc)) && (info.Length == r.Length)) { using (File.Open(str3, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { } File.Move(str3, destFileName); return; } } catch { } } try { File.Copy(r.FilePath, destFileName); } catch (IOException exception) { if (!exception.Message.Contains(destFileName)) { throw; } string message = "Shadow-copy error: " + exception.Message; try { FileInfo info2 = new FileInfo(r.FilePath); FileInfo info3 = new FileInfo(destFileName); if (info3.Exists) { object obj2 = message; message = string.Concat(new object[] { obj2, " [new:", info3.LastWriteTime, ",", info3.Length, "]" }); obj2 = message; message = string.Concat(new object[] { obj2, " [old:", info2.LastWriteTime, ",", info2.Length, "]" }); } } catch { } throw new Exception(message, exception); } }
private void GetAssemblyReferenceMap(out FileWithVersionInfo[] volatileRefs, out FileWithVersionInfo[] nonvolatileRefs) { string fileName = null; UniqueStringCollection strings = new UniqueStringCollection(base.AllFileReferences, new FileNameComparer()); strings.AddRange(PluginAssembly.GetCompatibleAssemblies(base.IsMyExtensions)); if ((base.Repository != null) && !base.Repository.DynamicSchema) { strings.Add(base.Repository.CustomAssemblyPath); strings.AddRange(base.Repository.GetDriverAssemblies()); if (base.Repository.DriverLoader.IsValid && (base.Repository.DriverLoader.InternalID == null)) { try { fileName = Path.GetFileName(base.Repository.DriverLoader.GetAssemblyPath()); } catch { } } } List<FileWithVersionInfo> list = new List<FileWithVersionInfo>(); List<string> assemblyFilePaths = new List<string>(); foreach (string str2 in strings) { try { if (Path.IsPathRooted(str2) && File.Exists(str2)) { if (!(ShadowAssemblyManager.IsShadowable(str2) && !Path.GetFileName(str2).Equals(fileName, StringComparison.OrdinalIgnoreCase))) { list.Add(new FileWithVersionInfo(str2)); } else { assemblyFilePaths.Add(str2); } } } catch { } } nonvolatileRefs = (from r in list orderby r.FilePath select r).ToArray<FileWithVersionInfo>(); volatileRefs = AssemblyProber.GetSameFolderAssemblyReferenceChain(assemblyFilePaths); }
private bool NeedsRefresh(FileWithVersionInfo[] oldRefs, FileWithVersionInfo[] newRefs) { if (oldRefs == null) { return true; } HashSet<string> oldNames = new HashSet<string>(from r in oldRefs select r.FilePath, StringComparer.InvariantCultureIgnoreCase); return !(from r in newRefs where oldNames.Contains(r.FilePath) select r).SequenceEqual<FileWithVersionInfo>(oldRefs); }
private void CopyFileToShadow(string lastShadow, FileWithVersionInfo r) { string fileName = Path.GetFileName(r.FilePath); string destFileName = Path.Combine(this._shadowFolder, fileName); if (lastShadow != null) { try { string str3 = Path.Combine(lastShadow, fileName); FileInfo info = new FileInfo(str3); if ((info.Exists && (info.LastWriteTimeUtc == r.LastWriteTimeUtc)) && (info.Length == r.Length)) { using (File.Open(str3, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { } File.Move(str3, destFileName); return; } } catch { } } try { File.Copy(r.FilePath, destFileName); } catch (IOException exception) { if (!exception.Message.Contains(destFileName)) { throw; } string message = "Shadow-copy error: " + exception.Message; try { FileInfo info2 = new FileInfo(r.FilePath); FileInfo info3 = new FileInfo(destFileName); if (info3.Exists) { object obj2 = message; message = string.Concat(new object[] { obj2, " [new:", info3.LastWriteTime, ",", info3.Length, "]" }); obj2 = message; message = string.Concat(new object[] { obj2, " [old:", info2.LastWriteTime, ",", info2.Length, "]" }); } } catch { } throw new Exception(message, exception); } }