mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Process attach improvements
This commit is contained in:
parent
5146a92f2e
commit
2746a53839
5 changed files with 67 additions and 52 deletions
|
@ -82,7 +82,7 @@ namespace System.Diagnostics
|
|||
return .Ok;
|
||||
}
|
||||
|
||||
public Result<void> AttachStandardInput(FileStream stream)
|
||||
public Result<void> AttachStandardInput(IFileStream stream)
|
||||
{
|
||||
if (mSpawn == null)
|
||||
return .Err;
|
||||
|
@ -94,7 +94,7 @@ namespace System.Diagnostics
|
|||
return .Ok;
|
||||
}
|
||||
|
||||
public Result<void> AttachStandardOutput(FileStream stream)
|
||||
public Result<void> AttachStandardOutput(IFileStream stream)
|
||||
{
|
||||
if (mSpawn == null)
|
||||
return .Err;
|
||||
|
@ -106,7 +106,7 @@ namespace System.Diagnostics
|
|||
return .Ok;
|
||||
}
|
||||
|
||||
public Result<void> AttachStandardError(FileStream stream)
|
||||
public Result<void> AttachStandardError(IFileStream stream)
|
||||
{
|
||||
if (mSpawn == null)
|
||||
return .Err;
|
||||
|
|
|
@ -6,7 +6,7 @@ using System;
|
|||
|
||||
namespace System.IO
|
||||
{
|
||||
public enum FileMode
|
||||
public enum FileMode : int32
|
||||
{
|
||||
/// Creates a new file. Fails if the file already exists.
|
||||
CreateNew = 1,
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace System.IO
|
|||
// Note these values currently match the values for FILE_SHARE_READ,
|
||||
// FILE_SHARE_WRITE, and FILE_SHARE_DELETE in winnt.h
|
||||
//
|
||||
public enum FileShare
|
||||
public enum FileShare : int32
|
||||
{
|
||||
/// No sharing. Any request to open the file (by this process or another
|
||||
/// process) will fail until the file is closed.
|
||||
|
|
|
@ -109,7 +109,12 @@ namespace System.IO
|
|||
}
|
||||
}
|
||||
|
||||
class UnbufferedFileStream : FileStreamBase
|
||||
interface IFileStream
|
||||
{
|
||||
Result<void> Attach(Platform.BfpFile* bfpFile, FileAccess access = .ReadWrite);
|
||||
}
|
||||
|
||||
class UnbufferedFileStream : FileStreamBase, IFileStream
|
||||
{
|
||||
FileAccess mFileAccess;
|
||||
|
||||
|
@ -230,11 +235,12 @@ namespace System.IO
|
|||
return .Ok;
|
||||
}
|
||||
|
||||
public void Attach(Platform.BfpFile* bfpFile, FileAccess access = .ReadWrite)
|
||||
public Result<void> Attach(Platform.BfpFile* bfpFile, FileAccess access = .ReadWrite)
|
||||
{
|
||||
Close();
|
||||
mBfpFile = bfpFile;
|
||||
mFileAccess = access;
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public override Result<void> Close()
|
||||
|
@ -272,7 +278,7 @@ namespace System.IO
|
|||
}
|
||||
}
|
||||
|
||||
class BufferedFileStream : BufferedStream
|
||||
class BufferedFileStream : BufferedStream, IFileStream
|
||||
{
|
||||
protected Platform.BfpFile* mBfpFile;
|
||||
protected int64 mBfpFilePos;
|
||||
|
@ -426,11 +432,12 @@ namespace System.IO
|
|||
return .Ok;
|
||||
}
|
||||
|
||||
public void Attach(Platform.BfpFile* bfpFile, FileAccess access = .ReadWrite)
|
||||
public Result<void> Attach(Platform.BfpFile* bfpFile, FileAccess access = .ReadWrite)
|
||||
{
|
||||
Close();
|
||||
mBfpFile = bfpFile;
|
||||
mFileAccess = access;
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public override Result<void> Seek(int64 pos, SeekKind seekKind = .Absolute)
|
||||
|
@ -559,6 +566,14 @@ namespace System.IO
|
|||
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
public override Result<void> Flush()
|
||||
{
|
||||
var result = base.Flush();
|
||||
if (mBfpFile != null)
|
||||
Platform.BfpFile_Flush(mBfpFile);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class FileStream : BufferedFileStream
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue