-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
IFileSystem.cs
216 lines (183 loc) · 9.14 KB
/
IFileSystem.cs
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#pragma warning disable CS1591
using System;
using System.Collections.Generic;
namespace MediaBrowser.Model.IO
{
/// <summary>
/// Interface IFileSystem.
/// </summary>
public interface IFileSystem
{
/// <summary>
/// Determines whether the specified filename is shortcut.
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns><c>true</c> if the specified filename is shortcut; otherwise, <c>false</c>.</returns>
bool IsShortcut(string filename);
/// <summary>
/// Resolves the shortcut.
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
string? ResolveShortcut(string filename);
/// <summary>
/// Creates the shortcut.
/// </summary>
/// <param name="shortcutPath">The shortcut path.</param>
/// <param name="target">The target.</param>
void CreateShortcut(string shortcutPath, string target);
string MakeAbsolutePath(string folderPath, string filePath);
/// <summary>
/// Moves a directory to a new location.
/// </summary>
/// <param name="source">Source directory.</param>
/// <param name="destination">Destination directory.</param>
void MoveDirectory(string source, string destination);
/// <summary>
/// Returns a <see cref="FileSystemMetadata" /> object for the specified file or directory path.
/// </summary>
/// <param name="path">A path to a file or directory.</param>
/// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
/// <remarks>If the specified path points to a directory, the returned <see cref="FileSystemMetadata" /> object's
/// <see cref="FileSystemMetadata.IsDirectory" /> property will be set to true and all other properties will reflect the properties of the directory.</remarks>
FileSystemMetadata GetFileSystemInfo(string path);
/// <summary>
/// Returns a <see cref="FileSystemMetadata" /> object for the specified file path.
/// </summary>
/// <param name="path">A path to a file.</param>
/// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
/// <remarks><para>If the specified path points to a directory, the returned <see cref="FileSystemMetadata" /> object's
/// <see cref="FileSystemMetadata.IsDirectory" /> property and the <see cref="FileSystemMetadata.Exists" /> property will both be set to false.</para>
/// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo(string)" />.</para></remarks>
FileSystemMetadata GetFileInfo(string path);
/// <summary>
/// Returns a <see cref="FileSystemMetadata" /> object for the specified directory path.
/// </summary>
/// <param name="path">A path to a directory.</param>
/// <returns>A <see cref="FileSystemMetadata" /> object.</returns>
/// <remarks><para>If the specified path points to a file, the returned <see cref="FileSystemMetadata" /> object's
/// <see cref="FileSystemMetadata.IsDirectory" /> property will be set to true and the <see cref="FileSystemMetadata.Exists" /> property will be set to false.</para>
/// <para>For automatic handling of files <b>and</b> directories, use <see cref="GetFileSystemInfo(string)" />.</para></remarks>
FileSystemMetadata GetDirectoryInfo(string path);
/// <summary>
/// Gets the valid filename.
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>System.String.</returns>
string GetValidFilename(string filename);
/// <summary>
/// Gets the creation time UTC.
/// </summary>
/// <param name="info">The information.</param>
/// <returns>DateTime.</returns>
DateTime GetCreationTimeUtc(FileSystemMetadata info);
/// <summary>
/// Gets the creation time UTC.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>DateTime.</returns>
DateTime GetCreationTimeUtc(string path);
/// <summary>
/// Gets the last write time UTC.
/// </summary>
/// <param name="info">The information.</param>
/// <returns>DateTime.</returns>
DateTime GetLastWriteTimeUtc(FileSystemMetadata info);
/// <summary>
/// Gets the last write time UTC.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>DateTime.</returns>
DateTime GetLastWriteTimeUtc(string path);
/// <summary>
/// Swaps the files.
/// </summary>
/// <param name="file1">The file1.</param>
/// <param name="file2">The file2.</param>
void SwapFiles(string file1, string file2);
bool AreEqual(string path1, string path2);
/// <summary>
/// Determines whether [contains sub path] [the specified parent path].
/// </summary>
/// <param name="parentPath">The parent path.</param>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [contains sub path] [the specified parent path]; otherwise, <c>false</c>.</returns>
bool ContainsSubPath(string parentPath, string path);
/// <summary>
/// Gets the file name without extension.
/// </summary>
/// <param name="info">The information.</param>
/// <returns>System.String.</returns>
string GetFileNameWithoutExtension(FileSystemMetadata info);
/// <summary>
/// Determines whether [is path file] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is path file] [the specified path]; otherwise, <c>false</c>.</returns>
bool IsPathFile(string path);
/// <summary>
/// Deletes the file.
/// </summary>
/// <param name="path">The path.</param>
void DeleteFile(string path);
/// <summary>
/// Gets the directories.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">If set to <c>true</c> also searches in subdirectiories.</param>
/// <returns>All found directories.</returns>
IEnumerable<FileSystemMetadata> GetDirectories(string path, bool recursive = false);
/// <summary>
/// Gets the files.
/// </summary>
/// <param name="path">The path in which to search.</param>
/// <param name="recursive">If set to <c>true</c> also searches in subdirectiories.</param>
/// <returns>All found files.</returns>
IEnumerable<FileSystemMetadata> GetFiles(string path, bool recursive = false);
IEnumerable<FileSystemMetadata> GetFiles(string path, IReadOnlyList<string>? extensions, bool enableCaseSensitiveExtensions, bool recursive);
/// <summary>
/// Gets the file system entries.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable<FileSystemMetadata>.</returns>
IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool recursive = false);
/// <summary>
/// Gets the directory paths.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable<System.String>.</returns>
IEnumerable<string> GetDirectoryPaths(string path, bool recursive = false);
/// <summary>
/// Gets the file paths.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable<System.String>.</returns>
IEnumerable<string> GetFilePaths(string path, bool recursive = false);
IEnumerable<string> GetFilePaths(string path, string[]? extensions, bool enableCaseSensitiveExtensions, bool recursive);
/// <summary>
/// Gets the file system entry paths.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <returns>IEnumerable<System.String>.</returns>
IEnumerable<string> GetFileSystemEntryPaths(string path, bool recursive = false);
void SetHidden(string path, bool isHidden);
void SetAttributes(string path, bool isHidden, bool readOnly);
IEnumerable<FileSystemMetadata> GetDrives();
/// <summary>
/// Determines whether the directory exists.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>Whether the path exists.</returns>
bool DirectoryExists(string path);
/// <summary>
/// Determines whether the file exists.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>Whether the path exists.</returns>
bool FileExists(string path);
}
}