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