| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- namespace Lua.IO
- {
- /// <summary>
- /// Wrapper for standard IO streams that prevents closing
- /// </summary>
- internal sealed class StandardIOStream(ILuaStream innerStream) : ILuaStream
- {
- public LuaFileOpenMode Mode => innerStream.Mode;
- public ValueTask<string> ReadAllAsync(CancellationToken cancellationToken)
- => innerStream.ReadAllAsync(cancellationToken);
- public ValueTask<string?> ReadLineAsync(CancellationToken cancellationToken)
- => innerStream.ReadLineAsync(cancellationToken);
- public ValueTask<string?> ReadStringAsync(int count, CancellationToken cancellationToken)
- => innerStream.ReadStringAsync(count, cancellationToken);
- public ValueTask WriteAsync(ReadOnlyMemory<char> content, CancellationToken cancellationToken)
- => innerStream.WriteAsync(content, cancellationToken);
- public ValueTask FlushAsync(CancellationToken cancellationToken)
- => innerStream.FlushAsync(cancellationToken);
- public void SetVBuf(LuaFileBufferingMode mode, int size)
- => innerStream.SetVBuf(mode, size);
- public long Seek(long offset, SeekOrigin origin)
- => innerStream.Seek(offset, origin);
- public void Close()
- {
- throw new IOException("cannot close standard file");
- }
- public void Dispose()
- {
- // Do not dispose inner stream to prevent closing standard IO streams
- innerStream.Dispose();
- }
- }
- }
|