Filesystem fixes

This commit is contained in:
Timerix22 2022-10-25 00:09:34 +06:00
parent ce4d716a52
commit b89841e39a
3 changed files with 14 additions and 11 deletions

View File

@ -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}");

View File

@ -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)

View File

@ -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/