tgstation-server 6.18.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
IIOManager.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.IO.Abstractions;
5using System.Threading;
6using System.Threading.Tasks;
7
9{
13 public interface IIOManager
14 {
19
24
30 IIOManager CreateResolverForSubdirectory(string subdirectoryPath);
31
36 string ResolvePath();
37
43 string ResolvePath(string path);
44
50 string GetFileName(string path);
51
57 string GetFileNameWithoutExtension(string path);
58
64 bool PathContainsParentAccess(string path);
65
73 Task<bool> PathIsChildOf(string parentPath, string childPath, CancellationToken cancellationToken);
74
85 ValueTask CopyDirectory(
86 IEnumerable<string>? ignore,
87 Func<string, string, ValueTask>? postCopyCallback,
88 string src,
89 string dest,
90 int? taskThrottle,
91 CancellationToken cancellationToken);
92
99 Task<bool> FileExists(string path, CancellationToken cancellationToken);
100
107 Task<bool> DirectoryExists(string path, CancellationToken cancellationToken);
108
116 ValueTask<byte[]> ReadAllBytes(string path, CancellationToken cancellationToken);
117
124 Task<IReadOnlyList<string>> GetDirectories(string path, CancellationToken cancellationToken);
125
132 Task<IReadOnlyList<string>> GetFiles(string path, CancellationToken cancellationToken);
133
140
148 Stream CreateAsyncReadStream(string path, bool sequential, bool shareWrite);
149
157 ValueTask WriteAllBytes(string path, byte[] contents, CancellationToken cancellationToken);
158
166 ValueTask CopyFile(string src, string dest, CancellationToken cancellationToken);
167
174 string GetDirectoryName(string path);
175
184 Task<List<string>> GetFilesWithExtension(string path, string extension, bool recursive, CancellationToken cancellationToken);
185
192 Task DeleteFile(string path, CancellationToken cancellationToken);
193
200 Task CreateDirectory(string path, CancellationToken cancellationToken);
201
208 Task DeleteDirectory(string path, CancellationToken cancellationToken);
209
215 string ConcatPath(params string[] paths);
216
224 Task MoveFile(string source, string destination, CancellationToken cancellationToken);
225
233 Task MoveDirectory(string source, string destination, CancellationToken cancellationToken);
234
242 Task ZipToDirectory(string path, Stream zipFile, CancellationToken cancellationToken);
243
250 Task<DateTimeOffset> GetLastModified(string path, CancellationToken cancellationToken);
251
258 Task<IDirectoryInfo> DirectoryInfo(string path, CancellationToken cancellationToken);
259
265 bool IsPathRooted(string path);
266 }
267}
Interface for using filesystems.
Definition IIOManager.cs:14
Stream CreateAsyncReadStream(string path, bool sequential, bool shareWrite)
Creates an asynchronous FileStream for sequential reading.
Task< IReadOnlyList< string > > GetFiles(string path, CancellationToken cancellationToken)
Returns full file names in a given path .
string GetFileName(string path)
Gets the file name portion of a path .
Task< bool > PathIsChildOf(string parentPath, string childPath, CancellationToken cancellationToken)
Check if a given parentPath is a parent of a given parentPath .
string ResolvePath()
Retrieve the full path of the current working directory.
Task< IDirectoryInfo > DirectoryInfo(string path, CancellationToken cancellationToken)
Gets a IDirectoryInfo for the given path .
ValueTask< byte[]> ReadAllBytes(string path, CancellationToken cancellationToken)
Returns all the contents of a file at path as a byte array.
string ConcatPath(params string[] paths)
Combines an array of strings into a path.
Task MoveFile(string source, string destination, CancellationToken cancellationToken)
Moves a file at source to destination .
Task< IReadOnlyList< string > > GetDirectories(string path, CancellationToken cancellationToken)
Returns full directory names in a given path .
bool IsPathRooted(string path)
Check if a given path is at the root level of the filesystem.
string GetDirectoryName(string path)
Gets the directory portion of a given path .
Task CreateDirectory(string path, CancellationToken cancellationToken)
Create a directory at path .
Task DeleteFile(string path, CancellationToken cancellationToken)
Deletes a file at path .
ValueTask CopyFile(string src, string dest, CancellationToken cancellationToken)
Copy a file from src to dest .
Task< DateTimeOffset > GetLastModified(string path, CancellationToken cancellationToken)
Get the DateTimeOffset of when a given path was last modified.
Task ZipToDirectory(string path, Stream zipFile, CancellationToken cancellationToken)
Extract a set of zipFile to a given path .
ValueTask WriteAllBytes(string path, byte[] contents, CancellationToken cancellationToken)
Writes some contents to a file at path overwriting previous content.
Stream CreateAsyncSequentialWriteStream(string path)
Creates an asynchronous FileStream for sequential writing.
string GetFileNameWithoutExtension(string path)
Gets the file name portion of a path with.
IIOManager CreateResolverForSubdirectory(string subdirectoryPath)
Create a new IIOManager that resolves paths to the specified subdirectoryPath .
char AltDirectorySeparatorChar
Gets the alternative directory separator character.
Definition IIOManager.cs:23
char DirectorySeparatorChar
Gets the primary directory separator character.
Definition IIOManager.cs:18
Task DeleteDirectory(string path, CancellationToken cancellationToken)
Recursively delete a directory, removes and does not enter any symlinks encounterd.
Task< bool > FileExists(string path, CancellationToken cancellationToken)
Check that the file at path exists.
Task< List< string > > GetFilesWithExtension(string path, string extension, bool recursive, CancellationToken cancellationToken)
Gets a list of files in path with the given extension .
Task MoveDirectory(string source, string destination, CancellationToken cancellationToken)
Moves a directory at source to destination .
ValueTask CopyDirectory(IEnumerable< string >? ignore, Func< string, string, ValueTask >? postCopyCallback, string src, string dest, int? taskThrottle, CancellationToken cancellationToken)
Copies a directory from src to dest .
Task< bool > DirectoryExists(string path, CancellationToken cancellationToken)
Check that the directory at path exists.
string ResolvePath(string path)
Retrieve the full path of some path given a relative path. Must be used before passing relative path...
bool PathContainsParentAccess(string path)
Check if a path contains the '..' parent directory accessor.