mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Replaced all File.OpenWrite calls /w .Open(FileMode.Create)
File.OpenWrite is equivalent to FileMode.OpenOrCreate, which caused errors when replacing a file that was larger previously
This commit is contained in:
parent
3bac5d2f00
commit
5db84a6ee6
@ -3,6 +3,7 @@
|
||||
* Progress ring displays when downloading modlist images
|
||||
* GUI releases memory of download modlists better when navigating around
|
||||
* Fixed phrasing after failed installations to say "failed".
|
||||
* Fixed download bug that was marking some modlists as corrupted if they were replacing older versions.
|
||||
|
||||
#### Version - 1.0 beta 15 - 1/6/2020
|
||||
* Don't delete the download folder when deleting empty folders during an update
|
||||
|
@ -110,7 +110,7 @@ namespace Compression.BSA.Test
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(absName));
|
||||
|
||||
|
||||
using (var fs = File.OpenWrite(absName))
|
||||
using (var fs = File.Open(absName, FileMode.Create))
|
||||
{
|
||||
file.CopyDataTo(fs);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace Compression.BSA
|
||||
public void Build(string filename)
|
||||
{
|
||||
SortEntries();
|
||||
using (var fs = File.OpenWrite(filename))
|
||||
using (var fs = File.Open(filename, FileMode.Create))
|
||||
using (var bw = new BinaryWriter(fs))
|
||||
{
|
||||
bw.Write(Encoding.ASCII.GetBytes(_state.HeaderMagic));
|
||||
|
@ -90,9 +90,7 @@ namespace Compression.BSA
|
||||
public void Build(string outputName)
|
||||
{
|
||||
RegenFolderRecords();
|
||||
if (File.Exists(outputName)) File.Delete(outputName);
|
||||
|
||||
using (var fs = File.OpenWrite(outputName))
|
||||
using (var fs = File.Open(outputName, FileMode.Create))
|
||||
using (var wtr = new BinaryWriter(fs))
|
||||
{
|
||||
wtr.Write(_fileId);
|
||||
|
@ -27,10 +27,7 @@ namespace Wabbajack.Common
|
||||
|
||||
private static void ExtractResource(string from, string to)
|
||||
{
|
||||
if (File.Exists(to))
|
||||
File.Delete(to);
|
||||
|
||||
using (var ous = File.OpenWrite(to))
|
||||
using (var ous = File.Open(to, System.IO.FileMode.Create))
|
||||
using (var ins = new GZipInputStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(from)))
|
||||
{
|
||||
ins.CopyTo(ous);
|
||||
@ -144,7 +141,7 @@ namespace Wabbajack.Common
|
||||
if (!Directory.Exists(parent))
|
||||
Directory.CreateDirectory(parent);
|
||||
|
||||
using (var fs = File.OpenWrite(outPath))
|
||||
using (var fs = File.Open(outPath, System.IO.FileMode.Create))
|
||||
{
|
||||
f.CopyDataTo(fs);
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ namespace Wabbajack.Common
|
||||
/*
|
||||
public static void ToBSON<T>(this T obj, string filename)
|
||||
{
|
||||
using (var fo = File.OpenWrite(filename))
|
||||
using (var fo = File.Open(filename, System.IO.FileMode.Create))
|
||||
using (var br = new BsonDataWriter(fo))
|
||||
{
|
||||
fo.SetLength(0);
|
||||
@ -518,7 +518,7 @@ namespace Wabbajack.Common
|
||||
|
||||
public static void BZip2ExtractToFile(this Stream src, string dest)
|
||||
{
|
||||
using (var os = File.OpenWrite(dest))
|
||||
using (var os = File.Open(dest, System.IO.FileMode.Create))
|
||||
{
|
||||
os.SetLength(0);
|
||||
using (var bz = new BZip2InputStream(src))
|
||||
@ -828,7 +828,7 @@ namespace Wabbajack.Common
|
||||
{
|
||||
var tmpName = Path.Combine("patch_cache", Guid.NewGuid() + ".tmp");
|
||||
|
||||
using (var f = File.OpenWrite(tmpName))
|
||||
using (var f = File.Open(tmpName, System.IO.FileMode.Create))
|
||||
{
|
||||
Status("Creating Patch");
|
||||
BSDiff.Create(a, b, f);
|
||||
@ -947,7 +947,7 @@ namespace Wabbajack.Common
|
||||
long size = 0;
|
||||
byte[] buffer = new byte[1024 * 8];
|
||||
random.NextBytes(buffer);
|
||||
using (var fs = File.OpenWrite(file))
|
||||
using (var fs = File.Open(file, System.IO.FileMode.Create))
|
||||
{
|
||||
while (DateTime.Now < startTime + new TimeSpan(0, 0, seconds))
|
||||
{
|
||||
|
@ -179,7 +179,7 @@ namespace Wabbajack.Lib
|
||||
}
|
||||
}
|
||||
|
||||
using (var fs = File.OpenWrite($"{ModList.Name}.md"))
|
||||
using (var fs = File.Open($"{ModList.Name}.md", System.IO.FileMode.Create))
|
||||
{
|
||||
fs.SetLength(0);
|
||||
using (var reporter = new ReportBuilder(fs, ModListOutputFolder))
|
||||
|
@ -214,7 +214,7 @@ namespace Wabbajack.Lib
|
||||
File.Delete(toFile);
|
||||
|
||||
// Patch it
|
||||
using (var outStream = File.OpenWrite(toFile))
|
||||
using (var outStream = File.Open(toFile, FileMode.Create))
|
||||
{
|
||||
BSDiff.Apply(oldData, () => new MemoryStream(patchData), outStream);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
public override async Task<bool> Download(Archive a, string destination)
|
||||
{
|
||||
var stream = await ResolveDownloadStream();
|
||||
using (var file = File.OpenWrite(destination))
|
||||
using (var file = File.Open(destination, FileMode.Create))
|
||||
{
|
||||
stream.CopyTo(file);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
public override async Task<bool> Download(Archive a, string destination)
|
||||
{
|
||||
using(var src = File.OpenRead(SourcePath))
|
||||
using (var dest = File.OpenWrite(destination))
|
||||
using (var dest = File.Open(destination, System.IO.FileMode.Create))
|
||||
{
|
||||
var size = new FileInfo(SourcePath).Length;
|
||||
src.CopyToWithStatus(size, dest, "Copying from Game folder");
|
||||
|
@ -84,7 +84,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
Directory.CreateDirectory(parent.FullName);
|
||||
}
|
||||
|
||||
using (var fs = download ? File.OpenWrite(destination) : null)
|
||||
using (var fs = download ? File.Open(destination, FileMode.Create) : null)
|
||||
{
|
||||
var client = Client ?? new HttpClient();
|
||||
client.DefaultRequestHeaders.Add("User-Agent", Consts.UserAgent);
|
||||
@ -103,11 +103,11 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
Utils.Status($"Starting Download {a?.Name ?? Url}", 0);
|
||||
var response = await client.GetAsync(Url, HttpCompletionOption.ResponseHeadersRead);
|
||||
TOP:
|
||||
TOP:
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
throw new HttpException((int)response.StatusCode, response.ReasonPhrase);
|
||||
|
||||
|
||||
Stream stream;
|
||||
try
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ namespace Wabbajack.Lib.LibCefHelpers
|
||||
{
|
||||
if (File.Exists("cefsharp.7z") && File.Exists("libcef.dll")) return;
|
||||
|
||||
using (var fs = File.OpenWrite("cefsharp.7z"))
|
||||
using (var fs = File.Open("cefsharp.7z", System.IO.FileMode.Create))
|
||||
using (var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Wabbajack.Lib.LibCefHelpers.cefsharp.7z"))
|
||||
{
|
||||
rs.CopyTo(fs);
|
||||
|
@ -259,7 +259,7 @@ namespace Wabbajack.Lib
|
||||
var patchData = LoadBytesFromPath(directive.SourceDataID);
|
||||
var toFile = Path.Combine(OutputFolder, directive.To);
|
||||
Status($"Patching {filename}");
|
||||
using (var output = File.OpenWrite(toFile))
|
||||
using (var output = File.Open(toFile, FileMode.Create))
|
||||
using (var input = File.OpenRead(gameFile))
|
||||
{
|
||||
BSDiff.Apply(input, () => new MemoryStream(patchData), output);
|
||||
|
@ -175,7 +175,7 @@ namespace Wabbajack.Lib
|
||||
|
||||
var patch_data = installer.LoadBytesFromPath(m.PatchID);
|
||||
|
||||
using (var fs = File.OpenWrite(Path.Combine(installer.OutputFolder, m.To)))
|
||||
using (var fs = File.Open(Path.Combine(installer.OutputFolder, m.To), FileMode.Create))
|
||||
BSDiff.Apply(new MemoryStream(src_data), () => new MemoryStream(patch_data), fs);
|
||||
});
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ namespace Wabbajack.VirtualFileSystem
|
||||
|
||||
public async Task WriteToFile(string filename)
|
||||
{
|
||||
using (var fs = File.OpenWrite(filename))
|
||||
using (var fs = File.Open(filename, FileMode.Create))
|
||||
using (var bw = new BinaryWriter(fs, Encoding.UTF8, true))
|
||||
{
|
||||
fs.SetLength(0);
|
||||
|
Loading…
Reference in New Issue
Block a user