mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-15 19:22:19 +08:00
Fix File.Open
This commit is contained in:
parent
cc32fbc86c
commit
ba847cf28d
|
@ -265,7 +265,7 @@ namespace BililiveRecorder.Core.Recording
|
|||
this.OnNewFile = onNewFile ?? throw new ArgumentNullException(nameof(onNewFile));
|
||||
}
|
||||
|
||||
public (Stream stream, object state) CreateOutputStream()
|
||||
public (Stream stream, object? state) CreateOutputStream()
|
||||
{
|
||||
var paths = this.task.CreateFileName();
|
||||
|
||||
|
@ -290,7 +290,7 @@ namespace BililiveRecorder.Core.Recording
|
|||
{ Directory.CreateDirectory(Path.GetDirectoryName(path)); }
|
||||
catch (Exception) { }
|
||||
|
||||
var stream = new FileStream(path, FileMode.Append, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
var stream = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read);
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace BililiveRecorder.Flv
|
|||
{
|
||||
public interface IFlvWriterTargetProvider
|
||||
{
|
||||
(Stream stream, object state) CreateOutputStream();
|
||||
(Stream stream, object? state) CreateOutputStream();
|
||||
|
||||
Stream CreateAlternativeHeaderStream();
|
||||
}
|
||||
|
|
|
@ -312,16 +312,16 @@ namespace BililiveRecorder.ToolBox.Commands
|
|||
public Stream CreateAlternativeHeaderStream()
|
||||
{
|
||||
var path = Path.ChangeExtension(this.pathTemplate, "header.txt");
|
||||
return File.Open(path, FileMode.Append, FileAccess.Write, FileShare.None);
|
||||
return new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Read);
|
||||
}
|
||||
|
||||
public (Stream stream, object state) CreateOutputStream()
|
||||
public (Stream stream, object? state) CreateOutputStream()
|
||||
{
|
||||
var i = this.fileIndex++;
|
||||
var path = Path.ChangeExtension(this.pathTemplate, $"fix_p{i:D3}.flv");
|
||||
var fileStream = File.Open(path, FileMode.CreateNew, FileAccess.Write, FileShare.Read);
|
||||
BeforeFileOpen?.Invoke(this, path);
|
||||
return (fileStream, null!);
|
||||
return (fileStream, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace BililiveRecorder.Flv.UnitTests.Grouping
|
|||
public class TestOutputProvider : IFlvWriterTargetProvider
|
||||
{
|
||||
public Stream CreateAlternativeHeaderStream() => throw new NotImplementedException();
|
||||
public (Stream, object) CreateOutputStream() => (File.Open(Path.Combine(TEST_OUTPUT_PATH, DateTimeOffset.Now.ToString("s").Replace(':', '-') + ".flv"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None), null!);
|
||||
public (Stream, object?) CreateOutputStream() => (File.Open(Path.Combine(TEST_OUTPUT_PATH, DateTimeOffset.Now.ToString("s").Replace(':', '-') + ".flv"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None), null);
|
||||
}
|
||||
|
||||
[Fact(Skip = "Not ready")]
|
||||
|
|
Loading…
Reference in New Issue
Block a user