private static void ReplaceX64(InstallationInfo info) { /////////////////////////////////////// // Patch the x64 version ReplaceX86(info); /////////////////////////////////////// // Patch the SysWow64 (x86) version // I can't tell an easy way to get the exact SysWow64 path... so just use an ugly hardhack String srcFilename = P.Combine(info.ExtractDirectory, GetUxFilename(Install.NT522English)); String sysWow64Path = Environment.GetFolderPath(Environment.SpecialFolder.System); sysWow64Path = Directory.GetParent(sysWow64Path).FullName; sysWow64Path = P.Combine(sysWow64Path, "SysWow64"); String dstFilename = P.Combine(sysWow64Path, GetUxFilename(info.Install)); File.Move(srcFilename, dstFilename); String finalName = P.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "UxTheme.dll"); PackageUtility.AddPfroEntry(dstFilename, finalName); }
private void ExecuteRegularFileNT5(String fileName) { // copy the file first // there used to be support for the SaveTo attribute, but I removed it in the current version of the schema String workOnThis = fileName + ".anofp"; // "Anolis File Pending" if (File.Exists(workOnThis)) { Package.Log.Add(LogSeverity.Warning, "Overwritten *.anofp: " + workOnThis); } File.Copy(fileName, workOnThis, true); if (PatchFile(workOnThis)) { if (Package.ExecutionInfo.MakeBackup) { Backup(Package.ExecutionInfo.BackupGroup, fileName, workOnThis); } // if it throws, this won't be encountered PackageUtility.AddPfroEntry(workOnThis, fileName); Package.ExecutionInfo.RequiresRestart = true; #if !DEBUG Package.Log.Add(new LogItem(LogSeverity.Info, "Patched: " + fileName)); #endif } else { Package.Log.Add(new LogItem(LogSeverity.Error, "Didn't patch: " + fileName + ", deleted " + workOnThis)); File.Delete(workOnThis); } }
public override void Execute() { if (Package.ExecutionInfo.ExecutionMode != PackageExecutionMode.Regular) { return; } switch (Operation) { case FileOperationType.Delete: DirectoryInfo dirToDelete = new DirectoryInfo(Path); if (!dirToDelete.Exists) { Package.Log.Add(LogSeverity.Error, "Could not find directory to delete: " + Path); return; } //Directory.Delete( Path, true ); PackageUtility.AddPfroEntry(dirToDelete); break; case FileOperationType.Copy: case FileOperationType.Replace: String sourceDir = P.Combine(Package.RootDirectory.FullName, SourceDirectory); DirectoryInfo source = new DirectoryInfo(sourceDir); if (!source.Exists) { Package.Log.Add(LogSeverity.Error, "Could not find source directory: " + sourceDir); return; } if (Directory.Exists(Path) && Operation != FileOperationType.Replace) { Package.Log.Add(LogSeverity.Error, "Will not overwrite: " + Path); return; } source.CopyTo(Path); break; case FileOperationType.None: default: return; } }
private void ExecuteRegularFileNT6(String fileName) { // it's the shame the more elegant NT5 system doesn't work on NT6 // ah well String workOnThis = fileName + ".anorp"; // "Anolis Rename Pending" if (File.Exists(workOnThis)) { Package.Log.Add(LogSeverity.Warning, "Overwritten *.anorp: " + workOnThis); } File.Copy(fileName, workOnThis, true); // problem: the file replacement system is working fine... the resources just aren't being replaced in the anorp file, wtf if (PatchFile(workOnThis)) { // Take Control of the original file PackageUtility.TakeOwnershipAndFullControl(fileName); String holdingName = fileName + ".anodp"; // "Anolis Delete Pending" if (File.Exists(holdingName)) { File.Delete(holdingName); Package.Log.Add(LogSeverity.Warning, "Deleted anodp file: " + holdingName); } File.Move(fileName, holdingName); // apparently you can do this for files currently in use File.Move(workOnThis, fileName); PackageUtility.AddPfroEntry(holdingName, null); // delete the *.anodp file on reboot Package.ExecutionInfo.RequiresRestart = true; PackageUtility.ResetOwnershipAndRelinquishControl(fileName); #if !DEBUG Package.Log.Add(new LogItem(LogSeverity.Info, "Patched: " + fileName)); #endif } else { Package.Log.Add(new LogItem(LogSeverity.Error, "Didn't patch: " + fileName + ", deleted " + workOnThis)); File.Delete(workOnThis); } }
private static void ReplaceX86(InstallationInfo info) { String srcFilename = P.Combine(info.ExtractDirectory, GetUxFilename(info.Install)); String dstFilename = P.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), GetUxFilename(info.Install)); if (File.Exists(dstFilename)) { File.Delete(dstFilename); } File.Move(srcFilename, dstFilename); String finalName = P.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "UxTheme.dll"); PackageUtility.AddPfroEntry(dstFilename, finalName); }
private void ExecuteRegular() { Backup(Package.ExecutionInfo.BackupGroup); // remember, the Package.Execute method sets AllowProtectedRenames already switch (Operation) { case FileOperationType.Delete: PackageUtility.AddPfroEntry(Path, null); Package.ExecutionInfo.RequiresRestart = true; break; case FileOperationType.Copy: case FileOperationType.Replace: if (Operation == FileOperationType.Replace) { if (!File.Exists(Path)) { return; } } String pendingFileName = Path + ".anofp"; pendingFileName = PackageUtility.GetUnusedFileName(pendingFileName); File.Copy(SourceFile, pendingFileName, true); PackageUtility.AddPfroEntry(pendingFileName, Path); // overwrite the file, this deletes the original methinks Package.ExecutionInfo.RequiresRestart = true; break; case FileOperationType.None: default: return; } }
public void DeleteFiles() { if (IsBusy) { throw new InvalidOperationException("Cannot delete files whilst the package is executing"); } RootDirectory.Refresh(); if (!RootDirectory.Exists) { return; // this is because .DeleteFiles is called twice } FileInfo logFile = RootDirectory.GetFile("Anolis.Installer.log"); String logFileDest = RootDirectory.Parent.GetFile(logFile.Name).FullName; if (logFile.Exists) { if (File.Exists(logFileDest)) { File.Delete(logFileDest); } logFile.MoveTo(logFileDest); } String[] undeletable = RootDirectory.DeleteSafely(); if (undeletable.Length > 0) { // certain files might be undeletable, like Uninstall.exe // so use PFRO PackageUtility.AddPfroEntry(RootDirectory); } } //void