|
| 1 | +#if FEATURE_ASYNC_FILE |
| 2 | + |
| 3 | +using System; |
| 4 | +using System.Collections.Generic; |
| 5 | +using System.Text; |
| 6 | +using System.Threading.Tasks; |
| 7 | +using System.Threading; |
| 8 | + |
| 9 | +namespace InkSoft.SmbAbstraction |
| 10 | +{ |
| 11 | + partial class SmbFile |
| 12 | + { |
| 13 | + /// <inheritdoc /> |
| 14 | + public override Task AppendAllLinesAsync(string path, IEnumerable<string> contents, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => AppendAllLines(path, contents), cancellationToken) : base.AppendAllLinesAsync(path, contents, cancellationToken); |
| 15 | + |
| 16 | + /// <inheritdoc /> |
| 17 | + public override Task AppendAllLinesAsync(string path, IEnumerable<string> contents, Encoding encoding, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => AppendAllLines(path, contents, encoding), cancellationToken) : base.AppendAllLinesAsync(path, contents, encoding, cancellationToken); |
| 18 | + |
| 19 | + /// <inheritdoc /> |
| 20 | + public override Task AppendAllTextAsync(string path, string contents, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => AppendAllText(path, contents), cancellationToken) : base.AppendAllTextAsync(path, contents, cancellationToken); |
| 21 | + |
| 22 | + /// <inheritdoc /> |
| 23 | + public override Task AppendAllTextAsync(string path, string contents, Encoding encoding, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => AppendAllText(path, contents, encoding), cancellationToken) : base.AppendAllTextAsync(path, contents, encoding, cancellationToken); |
| 24 | + |
| 25 | + /// <inheritdoc /> |
| 26 | + public override Task<byte[]> ReadAllBytesAsync(string path, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => ReadAllBytes(path), cancellationToken) : base.ReadAllBytesAsync(path, cancellationToken); |
| 27 | + |
| 28 | + /// <inheritdoc /> |
| 29 | + public override Task<string[]> ReadAllLinesAsync(string path, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => ReadAllLines(path), cancellationToken) : base.ReadAllLinesAsync(path, cancellationToken); |
| 30 | + |
| 31 | + /// <inheritdoc /> |
| 32 | + public override Task<string[]> ReadAllLinesAsync(string path, Encoding encoding, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => ReadAllLines(path, encoding), cancellationToken) : base.ReadAllLinesAsync(path, encoding, cancellationToken); |
| 33 | + |
| 34 | + /// <inheritdoc /> |
| 35 | + public override Task<string> ReadAllTextAsync(string path, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => ReadAllText(path), cancellationToken) : base.ReadAllTextAsync(path, cancellationToken); |
| 36 | + |
| 37 | + /// <inheritdoc /> |
| 38 | + public override Task<string> ReadAllTextAsync(string path, Encoding encoding, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => ReadAllText(path, encoding), cancellationToken) : base.ReadAllTextAsync(path, encoding, cancellationToken); |
| 39 | + |
| 40 | +#if FEATURE_READ_LINES_ASYNC |
| 41 | + /// <inheritdoc /> |
| 42 | + public override IAsyncEnumerable<string> ReadLinesAsync(string path, CancellationToken cancellationToken = default) => path.IsSharePath() ? throw new NotImplementedException() : base.ReadLinesAsync(path, cancellationToken); |
| 43 | + |
| 44 | + /// <inheritdoc /> |
| 45 | + public override IAsyncEnumerable<string> ReadLinesAsync(string path, Encoding encoding, CancellationToken cancellationToken = default) => path.IsSharePath() ? throw new NotImplementedException() : base.ReadLinesAsync(path, encoding, cancellationToken); |
| 46 | +#endif |
| 47 | + |
| 48 | + /// <inheritdoc /> |
| 49 | + public override Task WriteAllBytesAsync(string path, byte[] bytes, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => WriteAllBytes(path, bytes), cancellationToken) : base.WriteAllBytesAsync(path, bytes, cancellationToken); |
| 50 | + |
| 51 | + /// <inheritdoc /> |
| 52 | + public override Task WriteAllLinesAsync(string path, IEnumerable<string> contents, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => WriteAllLines(path, contents), cancellationToken) : base.WriteAllLinesAsync(path, contents, cancellationToken); |
| 53 | + |
| 54 | + /// <inheritdoc /> |
| 55 | + public override Task WriteAllLinesAsync(string path, IEnumerable<string> contents, Encoding encoding, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => WriteAllLines(path, contents, encoding), cancellationToken) : base.WriteAllLinesAsync(path, contents, encoding, cancellationToken); |
| 56 | + |
| 57 | + /// <inheritdoc /> |
| 58 | + public override Task WriteAllTextAsync(string path, string contents, CancellationToken cancellationToken = default) => path.IsSharePath() ? new(() => WriteAllText(path, contents), cancellationToken) : base.WriteAllTextAsync(path, contents, cancellationToken); |
| 59 | + |
| 60 | + /// <inheritdoc /> |
| 61 | + public override Task WriteAllTextAsync(string path, string contents, Encoding encoding, CancellationToken cancellationToken = default) => !path.IsSharePath() ? base.WriteAllTextAsync(path, contents, encoding, cancellationToken) : new(() => WriteAllText(path, contents, encoding), cancellationToken); |
| 62 | + } |
| 63 | +} |
| 64 | +#endif |
0 commit comments