From b89841e39af8cf27dc8127da1d82b4601ec70ea7 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Tue, 25 Oct 2022 00:09:34 +0600 Subject: [PATCH] Filesystem fixes --- DTLib.Network/FSP.cs | 8 +++++++- DTLib/Filesystem/File.cs | 11 +++++++---- build.sh | 6 ------ 3 files changed, 14 insertions(+), 11 deletions(-) delete mode 100644 build.sh diff --git a/DTLib.Network/FSP.cs b/DTLib.Network/FSP.cs index bff6aaf..fae6fa2 100644 --- a/DTLib.Network/FSP.cs +++ b/DTLib.Network/FSP.cs @@ -54,7 +54,7 @@ public class FSP { using var fileStream = new System.IO.MemoryStream(); Download_SharedCode(fileStream, false); - byte[] output = fileStream.GetBuffer(); + byte[] output = fileStream.ToArray(); fileStream.Close(); Debug("g", $" downloaded {BytesDownloaded} of {Filesize} bytes"); return output; @@ -177,6 +177,12 @@ public class FSP public static void CreateManifest(string dir) { + if(!Directory.Exists(dir)) + { + Directory.Create(dir); + Log("y", $"can't create manifest, dir <{dir}> doesn't exist"); + return; + } if (!dir.EndsWith(Путь.Разд)) dir += Путь.Разд; Log($"b", $"creating manifest of {dir}"); diff --git a/DTLib/Filesystem/File.cs b/DTLib/Filesystem/File.cs index 364e35a..8ed8912 100644 --- a/DTLib/Filesystem/File.cs +++ b/DTLib/Filesystem/File.cs @@ -1,4 +1,5 @@ -namespace DTLib.Filesystem; + +namespace DTLib.Filesystem; public static class File { @@ -59,18 +60,20 @@ public static class File public static void AppendAllText(string file, string content) => AppendAllBytes(file, content.ToBytes()); public static System.IO.FileStream OpenRead(string file) => - Exists(file) ? System.IO.File.OpenRead(file) : throw new Exception($"file not found: <{file}>"); + Exists(file) + ? System.IO.File.Open(file, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite) + : throw new Exception($"file not found: <{file}>"); public static System.IO.FileStream OpenWrite(string file) { if (Exists(file)) Delete(file); Create(file); - return System.IO.File.Open(file, System.IO.FileMode.OpenOrCreate); + return System.IO.File.Open(file, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite); } public static System.IO.FileStream OpenAppend(string file) { Create(file); - return System.IO.File.Open(file, System.IO.FileMode.Append); + return System.IO.File.Open(file, System.IO.FileMode.Append, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite); } public static void CreateSymlink(string sourceName, string symlinkName) diff --git a/build.sh b/build.sh deleted file mode 100644 index 55390ab..0000000 --- a/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -dotnet build -c Release -dotnet build -c Debug -rm -rf bin -mkdir bin -cp -rv DTLib.Tests/bin/* bin/