14 public static bool Exists(
string path,
bool cloud)
23 public static void Delete(
string path,
bool cloud,
bool forceDeleteFile =
false)
29 else if (forceDeleteFile)
65 fileStream.CopyTo(destination2);
75 public static void Move(
string source,
string destination,
bool cloud,
bool overwrite =
true,
bool forceDeleteSourceFile =
false)
112 Write(path, data, data.Length, cloud);
115 public static void Write(
string path,
byte[] data,
int length,
bool cloud)
123 if (parentFolderPath !=
"")
129 while (fileStream.Position <
length)
131 fileStream.Write(data, (
int)fileStream.Position,
Math.
Min(
length - (
int)fileStream.Position, 2048));
155 public static bool MoveToCloud(
string localPath,
string cloudPath)
162 Delete(localPath, cloud:
false);
166 public static bool MoveToLocal(
string cloudPath,
string localPath)
173 Delete(cloudPath, cloud:
true);
177 public static bool CopyToLocal(
string cloudPath,
string localPath)
187 public static string GetFileName(
string path,
bool includeExtension =
true)
190 if (
match ==
null ||
match.Groups[
"fileName"] ==
null)
194 includeExtension &=
match.Groups[
"extension"] !=
null;
195 return match.Groups[
"fileName"].Value + (includeExtension ?
match.Groups[
"extension"].Value :
"");
201 if (
match ==
null ||
match.Groups[
"path"] ==
null)
205 return match.Groups[
"path"].Value;
208 public static void CopyFolder(
string sourcePath,
string destinationPath)
212 for (
int i = 0;
i < directories.Length;
i++)
217 foreach (
string obj in directories)
219 File.
Copy(
obj,
obj.Replace(sourcePath, destinationPath), overwrite:
true);
228 Thread.CurrentThread.IsBackground =
false;
233 Thread.CurrentThread.IsBackground = isBackground;
static string[] GetDirectories(string path)
static DirectoryInfo CreateDirectory(string path)
static string[] GetFiles(string path)
static void SetAttributes(string path, FileAttributes fileAttributes)
static FileStream Create(string path)
static bool Exists([NotNullWhen(true)] string? path)
static FileStream OpenRead(string path)
static FileStream Open(string path, FileMode mode)
static void Copy(string sourceFileName, string destFileName)
static byte[] ReadAllBytes(string path)
static void Delete(string path)
static FileAttributes GetAttributes(string path)
static string GetFullPath(string path)
static byte Min(byte val1, byte val2)
static Thread CurrentThread
static Terraria.Social.Base.CloudSocialModule Cloud
static bool Exists(string path, bool cloud)
static bool MoveToCloud(string localPath, string cloudPath)
static int GetFileSize(string path, bool cloud)
static void RemoveReadOnlyAttribute(string path)
static string GetFileName(string path, bool includeExtension=true)
static void ProtectedInvoke(Action action)
static void Write(string path, byte[] data, int length, bool cloud)
static byte[] ReadAllBytes(string path, bool cloud)
static void Move(string source, string destination, bool cloud, bool overwrite=true, bool forceDeleteSourceFile=false)
static void Copy(string source, string destination, bool cloud, bool overwrite=true)
static string GetParentFolderPath(string path, bool includeExtension=true)
static string GetFullPath(string path, bool cloud)
static Regex FileNameRegex
static void CopyFolder(string sourcePath, string destinationPath)
static bool MoveToLocal(string cloudPath, string localPath)
static void Read(string path, byte[] buffer, int length, bool cloud)
static void Delete(string path, bool cloud, bool forceDeleteFile=false)
static void WriteAllBytes(string path, byte[] data, bool cloud)
static bool CopyToLocal(string cloudPath, string localPath)
static bool TryCreatingDirectory(string folderPath)