~ruther/Nostale-Anonymizer

ref: dc8f4e8b5cc4e48d7f686f226c2ad863db15e6e8 Nostale-Anonymizer/src/Anonymizer/Sinks/FileSink.cs -rw-r--r-- 1.6 KiB
dc8f4e8b — František Boháček feat: add message filter 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
//  FileSink.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Text.RegularExpressions;
using NosSmooth.PacketSerializer.Abstractions.Attributes;

namespace Anonymizer.Sinks;

/// <summary>
/// A sink that supports reading from a file and writing to a file.
/// </summary>
public class FileSink : IDisposable, IPacketSource, IPacketDestination
{
    private readonly FileSinkOptions _options;
    private readonly FileStream _sourceStream;
    private readonly FileStream _destinationStream;

    /// <summary>
    /// Initializes a new instance of the <see cref="FileSink"/> class.
    /// </summary>
    /// <param name="sourceFile">The source file path.</param>
    /// <param name="destinationFile">The destination file path.</param>
    /// <param name="options">The options.</param>
    public FileSink(string sourceFile, string destinationFile, FileSinkOptions options)
    {
        _options = options;
        _sourceStream = File.OpenRead(sourceFile);
        _destinationStream = File.OpenWrite(destinationFile);
    }

    /// <inheritdoc />
    public long Cursor { get; private set; }

    /// <inheritdoc />
    public Task<bool> TryGetNextPacketAsync(out PacketInfo packetInfo, CancellationToken ct = default)
    {
        throw new NotImplementedException();
    }

    /// <inheritdoc />
    public Task WritePacketAsync(string packetString)
    {
        throw new NotImplementedException();
    }

    /// <inheritdoc />
    public void Dispose()
    {
        _sourceStream.Dispose();
        _destinationStream.Dispose();
    }
}
Do not follow this link