diff --git a/Directory.Build.props b/Directory.Build.props
index e3b78f63c4..09d5cb0bc1 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -24,7 +24,7 @@
changes!
-->
3.0.25
- 453
+ 454
$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)
diff --git a/private/Nitrocid.Tests/Files/FilesystemNeutralizationTests.cs b/private/Nitrocid.Tests/Files/FilesystemNeutralizationTests.cs
index 231d9f5dc1..ea128819c7 100644
--- a/private/Nitrocid.Tests/Files/FilesystemNeutralizationTests.cs
+++ b/private/Nitrocid.Tests/Files/FilesystemNeutralizationTests.cs
@@ -67,31 +67,5 @@ public void TestNeutralizePathsCustom()
NeutPath.ShouldBe(TargetPath + "/" + TestPath);
}
}
-
- ///
- /// Tests throwing on invalid path
- ///
- [TestMethod]
- [DataRow(null)]
- [DataRow("")]
- [DataRow("/usr/lib")]
- [DataRow("C:/Program Files")]
- [DataRow("Music")]
- [Description("Neutralization")]
- public void TestThrowOnInvalidPathValid(string path) =>
- Should.NotThrow(() => FilesystemTools.ThrowOnInvalidPath(path));
-
- ///
- /// Tests throwing on invalid path
- ///
- [TestMethod]
- [DataRow("\\\\.\\globalroot\\device\\condrv\\kernelconnect")]
- [DataRow("C:\\$i30")]
- [Description("Neutralization")]
- public void TestThrowOnInvalidPathInvalid(string path)
- {
- if (KernelPlatform.IsOnWindows())
- Should.Throw(() => FilesystemTools.ThrowOnInvalidPath(path), typeof(KernelException));
- }
}
}
diff --git a/public/Nitrocid.Addons/Nitrocid.Extras.Calendar/Calendar/Events/EventManager.cs b/public/Nitrocid.Addons/Nitrocid.Extras.Calendar/Calendar/Events/EventManager.cs
index 1bc06f9da4..c14512377a 100644
--- a/public/Nitrocid.Addons/Nitrocid.Extras.Calendar/Calendar/Events/EventManager.cs
+++ b/public/Nitrocid.Addons/Nitrocid.Extras.Calendar/Calendar/Events/EventManager.cs
@@ -166,7 +166,6 @@ public static void LoadEvents()
{
lock (EventManagerLock)
{
- FilesystemTools.ThrowOnInvalidPath(EventFile);
EventFile = FilesystemTools.NeutralizePath(EventFile);
DebugWriter.WriteDebug(DebugLevel.I, "Loading event {0}...", EventFile);
@@ -197,7 +196,6 @@ public static void SaveEvents() =>
///
public static void SaveEvents(string Path, bool Destructive)
{
- FilesystemTools.ThrowOnInvalidPath(Path);
Path = FilesystemTools.NeutralizePath(Path);
DebugWriter.WriteDebug(DebugLevel.I, "Saving events to {0}...", Path);
@@ -239,7 +237,6 @@ public static void SaveEvent(EventInfo EventInstance) =>
///
public static void SaveEvent(EventInfo EventInstance, string File)
{
- FilesystemTools.ThrowOnInvalidPath(File);
File = FilesystemTools.NeutralizePath(File);
DebugWriter.WriteDebug(DebugLevel.I, "Saving event to {0}...", File);
var contents = JsonConvert.SerializeObject(EventInstance, Formatting.Indented);
diff --git a/public/Nitrocid.Addons/Nitrocid.Extras.Calendar/Calendar/Reminders/ReminderManager.cs b/public/Nitrocid.Addons/Nitrocid.Extras.Calendar/Calendar/Reminders/ReminderManager.cs
index e7b20a4b7c..c76edbd58a 100644
--- a/public/Nitrocid.Addons/Nitrocid.Extras.Calendar/Calendar/Reminders/ReminderManager.cs
+++ b/public/Nitrocid.Addons/Nitrocid.Extras.Calendar/Calendar/Reminders/ReminderManager.cs
@@ -175,7 +175,6 @@ public static void LoadReminders()
{
lock (ReminderManagerLock)
{
- FilesystemTools.ThrowOnInvalidPath(ReminderFile);
ReminderFile = FilesystemTools.NeutralizePath(ReminderFile);
DebugWriter.WriteDebug(DebugLevel.I, "Loading reminder {0}...", ReminderFile);
@@ -206,7 +205,6 @@ public static void SaveReminders() =>
///
public static void SaveReminders(string Path, bool Destructive)
{
- FilesystemTools.ThrowOnInvalidPath(Path);
Path = FilesystemTools.NeutralizePath(Path);
DebugWriter.WriteDebug(DebugLevel.I, "Saving reminders to {0}...", Path);
@@ -248,7 +246,6 @@ public static void SaveReminder(ReminderInfo ReminderInstance) =>
///
public static void SaveReminder(ReminderInfo ReminderInstance, string File)
{
- FilesystemTools.ThrowOnInvalidPath(File);
File = FilesystemTools.NeutralizePath(File);
DebugWriter.WriteDebug(DebugLevel.I, "Saving reminder to {0}...", File);
var contents = JsonConvert.SerializeObject(ReminderInstance, Formatting.Indented);
diff --git a/public/Nitrocid.Addons/Nitrocid.Extras.FtpShell/Tools/Filesystem/FTPFilesystem.cs b/public/Nitrocid.Addons/Nitrocid.Extras.FtpShell/Tools/Filesystem/FTPFilesystem.cs
index a4f6978828..6a8ff7b657 100644
--- a/public/Nitrocid.Addons/Nitrocid.Extras.FtpShell/Tools/Filesystem/FTPFilesystem.cs
+++ b/public/Nitrocid.Addons/Nitrocid.Extras.FtpShell/Tools/Filesystem/FTPFilesystem.cs
@@ -195,7 +195,6 @@ public static bool FTPChangeLocalDir(string Directory)
{
string targetDir;
targetDir = $"{FTPShellCommon.FtpCurrentDirectory}/{Directory}";
- FilesystemTools.ThrowOnInvalidPath(targetDir);
// Check if folder exists
if (Checking.FolderExists(targetDir))
diff --git a/public/Nitrocid.Addons/Nitrocid.Extras.SftpShell/Tools/Filesystem/SFTPFilesystem.cs b/public/Nitrocid.Addons/Nitrocid.Extras.SftpShell/Tools/Filesystem/SFTPFilesystem.cs
index 6a549e8de1..d43164711f 100644
--- a/public/Nitrocid.Addons/Nitrocid.Extras.SftpShell/Tools/Filesystem/SFTPFilesystem.cs
+++ b/public/Nitrocid.Addons/Nitrocid.Extras.SftpShell/Tools/Filesystem/SFTPFilesystem.cs
@@ -167,7 +167,6 @@ public static bool SFTPChangeLocalDir(string Directory)
{
string targetDir;
targetDir = $"{SFTPShellCommon.SFTPCurrDirect}/{Directory}";
- FilesystemTools.ThrowOnInvalidPath(targetDir);
// Check if folder exists
if (Checking.FolderExists(targetDir))
diff --git a/public/Nitrocid.Addons/Nitrocid.Extras.SqlShell/Sql/SqlShellCommon.cs b/public/Nitrocid.Addons/Nitrocid.Extras.SqlShell/Sql/SqlShellCommon.cs
index abb21822d0..6c525edba9 100644
--- a/public/Nitrocid.Addons/Nitrocid.Extras.SqlShell/Sql/SqlShellCommon.cs
+++ b/public/Nitrocid.Addons/Nitrocid.Extras.SqlShell/Sql/SqlShellCommon.cs
@@ -60,7 +60,6 @@ public static bool IsSql(string Path)
try
{
// Neutralize path
- FilesystemTools.ThrowOnInvalidPath(Path);
Path = FilesystemTools.NeutralizePath(Path);
// Try to open an SQL connection
diff --git a/public/Nitrocid.Templates/templates/KSMod/ModName.cs b/public/Nitrocid.Templates/templates/KSMod/ModName.cs
index 70fec2035c..56143daf73 100644
--- a/public/Nitrocid.Templates/templates/KSMod/ModName.cs
+++ b/public/Nitrocid.Templates/templates/KSMod/ModName.cs
@@ -10,7 +10,7 @@ public class ModName : IMod
public string Name { get; set; } = "My Mod";
public string Version { get; set; } = "1.0.0";
- public Version MinimumSupportedApiVersion => new(3, 0, 25, 453);
+ public Version MinimumSupportedApiVersion => new(3, 0, 25, 454);
public ReadOnlyDictionary PubliclyAvailableFunctions => null;
diff --git a/public/Nitrocid/Drivers/Filesystem/BaseFilesystemDriver.cs b/public/Nitrocid/Drivers/Filesystem/BaseFilesystemDriver.cs
index 8775161104..13d3d67b15 100644
--- a/public/Nitrocid/Drivers/Filesystem/BaseFilesystemDriver.cs
+++ b/public/Nitrocid/Drivers/Filesystem/BaseFilesystemDriver.cs
@@ -72,7 +72,6 @@ public abstract class BaseFilesystemDriver : IFilesystemDriver
///
public virtual void AddAttributeToFile(string FilePath, FileAttributes Attributes)
{
- FS.ThrowOnInvalidPath(FilePath);
FilePath = FS.NeutralizePath(FilePath);
DebugWriter.WriteDebug(DebugLevel.I, "Setting file attribute to {0}...", Attributes);
File.SetAttributes(FilePath, Attributes);
@@ -84,7 +83,6 @@ public virtual void AddAttributeToFile(string FilePath, FileAttributes Attribute
///
public virtual void AddToPathLookup(string Path)
{
- FS.ThrowOnInvalidPath(Path);
var LookupPaths = GetPathList();
Path = FS.NeutralizePath(Path);
LookupPaths.Add(Path);
@@ -94,8 +92,6 @@ public virtual void AddToPathLookup(string Path)
///
public virtual void AddToPathLookup(string Path, string RootPath)
{
- FS.ThrowOnInvalidPath(Path);
- FS.ThrowOnInvalidPath(RootPath);
var LookupPaths = GetPathList();
Path = FS.NeutralizePath(Path, RootPath);
LookupPaths.Add(Path);
@@ -105,7 +101,6 @@ public virtual void AddToPathLookup(string Path, string RootPath)
///
public virtual void ClearFile(string Path)
{
- FS.ThrowOnInvalidPath(Path);
FileStream clearer = new(Path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
clearer.SetLength(0);
clearer.Close();
@@ -119,8 +114,7 @@ public virtual byte[] CombineBinaryFiles(string Input, string[] TargetInputs)
var CombinedContents = new List();
// Add the input contents
- FS.ThrowOnInvalidPath(Input);
- if (!Parsing.IsBinaryFile(Input))
+ if (!Parsing.IsBinaryFile(Input))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("To combine text files, use the appropriate function.") + " " + nameof(CombineTextFiles) + "(" + Input + ")");
CombinedContents.AddRange(Reading.ReadAllBytes(Input));
@@ -128,8 +122,7 @@ public virtual byte[] CombineBinaryFiles(string Input, string[] TargetInputs)
for (int i = 0; i < TargetInputs.Length; i++)
{
string TargetInput = TargetInputs[i];
- FS.ThrowOnInvalidPath(TargetInput);
- if (!Parsing.IsBinaryFile(TargetInput))
+ if (!Parsing.IsBinaryFile(TargetInput))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("To combine text files, use the appropriate function.") + " " + nameof(CombineTextFiles) + "(" + TargetInput + ")");
ProgressManager.ReportProgress((i + 1) / TargetInputs.Length, nameof(CombineBinaryFiles), $"{Input} + {TargetInput}");
CombinedContents.AddRange(Reading.ReadAllBytes(TargetInput));
@@ -154,8 +147,7 @@ public virtual string[] CombineTextFiles(string Input, string[] TargetInputs)
var CombinedContents = new List();
// Add the input contents
- FS.ThrowOnInvalidPath(Input);
- if (Parsing.IsBinaryFile(Input))
+ if (Parsing.IsBinaryFile(Input))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("To combine binary files, use the appropriate function.") + " " + nameof(CombineBinaryFiles) + "(" + Input + ")");
CombinedContents.AddRange(Reading.ReadContents(Input));
@@ -163,8 +155,7 @@ public virtual string[] CombineTextFiles(string Input, string[] TargetInputs)
for (int i = 0; i < TargetInputs.Length; i++)
{
string TargetInput = TargetInputs[i];
- FS.ThrowOnInvalidPath(TargetInput);
- if (Parsing.IsBinaryFile(TargetInput))
+ if (Parsing.IsBinaryFile(TargetInput))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("To combine binary files, use the appropriate function.") + " " + nameof(CombineBinaryFiles) + "(" + TargetInput + ")");
ProgressManager.ReportProgress((i + 1) / TargetInputs.Length, nameof(CombineTextFiles), $"{Input} + {TargetInput}");
CombinedContents.AddRange(Reading.ReadContents(TargetInput));
@@ -188,7 +179,6 @@ public virtual void ConvertLineEndings(string TextFile) =>
///
public virtual void ConvertLineEndings(string TextFile, FilesystemNewlineStyle LineEndingStyle)
{
- FS.ThrowOnInvalidPath(TextFile);
TextFile = FS.NeutralizePath(TextFile);
if (!Checking.FileExists(TextFile))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("File {0} not found."), TextFile);
@@ -220,8 +210,6 @@ public virtual void CopyDirectory(string Source, string Destination) =>
///
public virtual void CopyDirectory(string Source, string Destination, bool ShowProgress)
{
- FS.ThrowOnInvalidPath(Source);
- FS.ThrowOnInvalidPath(Destination);
if (!Checking.FolderExists(Source))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("Directory {0} not found."), Source);
@@ -267,8 +255,6 @@ public virtual void CopyDirectory(string Source, string Destination, bool ShowPr
///
public virtual void CopyFile(string Source, string Destination)
{
- FS.ThrowOnInvalidPath(Source);
- FS.ThrowOnInvalidPath(Destination);
Source = FS.NeutralizePath(Source);
DebugWriter.WriteDebug(DebugLevel.I, "Source directory: {0}", Source);
Destination = FS.NeutralizePath(Destination);
@@ -301,8 +287,6 @@ public virtual void CopyFile(string Source, string Destination)
///
public virtual void CopyFileOrDir(string Source, string Destination)
{
- FS.ThrowOnInvalidPath(Source);
- FS.ThrowOnInvalidPath(Destination);
Source = FS.NeutralizePath(Source);
DebugWriter.WriteDebug(DebugLevel.I, "Source directory: {0}", Source);
Destination = FS.NeutralizePath(Destination);
@@ -343,7 +327,6 @@ public virtual void CopyFileOrDir(string Source, string Destination)
///
public virtual List CreateList(string folder, bool Sorted = false, bool Recursive = false)
{
- FS.ThrowOnInvalidPath(folder);
DebugWriter.WriteDebug(DebugLevel.I, "Folder {0} will be listed...", folder);
var FilesystemEntries = new List();
@@ -688,7 +671,6 @@ public virtual string RenderContentsInHex(long ByteHighlight, long StartByte, lo
///
public virtual bool FileExists(string File, bool Neutralize = false)
{
- FS.ThrowOnInvalidPath(File);
if (Neutralize)
File = FS.NeutralizePath(File);
bool exists = System.IO.File.Exists(File);
@@ -699,7 +681,6 @@ public virtual bool FileExists(string File, bool Neutralize = false)
///
public virtual bool FileExistsInPath(string FilePath, ref string? Result)
{
- FS.ThrowOnInvalidPath(FilePath);
var LookupPaths = GetPathList();
string ResultingPath;
foreach (string LookupPath in LookupPaths)
@@ -717,7 +698,6 @@ public virtual bool FileExistsInPath(string FilePath, ref string? Result)
///
public virtual bool FolderExists(string Folder, bool Neutralize = false)
{
- FS.ThrowOnInvalidPath(Folder);
if (Neutralize)
Folder = FS.NeutralizePath(Folder);
bool exists = Directory.Exists(Folder);
@@ -775,7 +755,6 @@ public virtual string[] GetFilesystemEntries(string Path, bool IsFile = false, b
try
{
Path = FS.NeutralizePath(Path);
- FS.ThrowOnInvalidPath(Path);
// Check to see if we're calling from the root path
string Pattern = IsFile ? "" : "*";
@@ -834,9 +813,7 @@ public virtual string[] GetFilesystemEntries(string? Parent, string Pattern, boo
var Entries = Array.Empty();
try
{
- FS.ThrowOnInvalidPath(Parent);
- FS.ThrowOnInvalidPath(Pattern);
- Parent = FS.NeutralizePath(Parent);
+ Parent = FS.NeutralizePath(Parent);
// Get the entries
if (Directory.Exists(Parent))
@@ -912,7 +889,6 @@ public virtual char[] GetInvalidFileChars()
///
public virtual FilesystemNewlineStyle GetLineEndingFromFile(string TextFile)
{
- FS.ThrowOnInvalidPath(TextFile);
TextFile = FS.NeutralizePath(TextFile);
if (!Checking.FileExists(TextFile))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("File {0} not found."), TextFile);
@@ -964,8 +940,6 @@ public virtual FilesystemNewlineStyle GetLineEndingFromFile(string TextFile)
///
public virtual string GetNumberedFileName(string? path, string fileName)
{
- FS.ThrowOnInvalidPath(path);
- FS.ThrowOnInvalidPath(fileName);
path = FS.NeutralizePath(path);
string fileNameWithoutExtension = IOPath.GetFileNameWithoutExtension(fileName);
string fileNameExtension = IOPath.GetExtension(fileName);
@@ -1000,7 +974,6 @@ public string GetRandomFolderName() =>
public virtual bool IsBinaryFile(string Path)
{
// Neutralize path
- FS.ThrowOnInvalidPath(Path);
Path = FS.NeutralizePath(Path);
// Check to see if the file contains these control characters
@@ -1024,8 +997,7 @@ public virtual bool IsJson(string Path)
try
{
// Neutralize path
- FS.ThrowOnInvalidPath(Path);
- Path = FS.NeutralizePath(Path);
+ Path = FS.NeutralizePath(Path);
// Try to parse the content as JSON object
try
@@ -1065,7 +1037,6 @@ public virtual bool IsSql(string Path)
///
public virtual void MakeDirectory(string NewDirectory, bool ThrowIfDirectoryExists = true)
{
- FS.ThrowOnInvalidPath(NewDirectory);
NewDirectory = FS.NeutralizePath(NewDirectory);
DebugWriter.WriteDebug(DebugLevel.I, "New directory: {0} ({1})", NewDirectory, Checking.FolderExists(NewDirectory));
if (!Checking.FolderExists(NewDirectory))
@@ -1084,7 +1055,6 @@ public virtual void MakeDirectory(string NewDirectory, bool ThrowIfDirectoryExis
///
public virtual void MakeFile(string NewFile, bool ThrowIfFileExists = true)
{
- FS.ThrowOnInvalidPath(NewFile);
NewFile = FS.NeutralizePath(NewFile);
DebugWriter.WriteDebug(DebugLevel.I, "File path is {0} and .Exists is {1}", NewFile, Checking.FileExists(NewFile));
if (!Checking.FileExists(NewFile))
@@ -1114,7 +1084,6 @@ public virtual void MakeFile(string NewFile, bool ThrowIfFileExists = true)
///
public virtual void MakeJsonFile(string NewFile, bool ThrowIfFileExists = true, bool useArray = false)
{
- FS.ThrowOnInvalidPath(NewFile);
NewFile = FS.NeutralizePath(NewFile);
DebugWriter.WriteDebug(DebugLevel.I, "File path is {0} and .Exists is {1}", NewFile, Checking.FileExists(NewFile));
if (!Checking.FileExists(NewFile))
@@ -1148,9 +1117,6 @@ public virtual void MakeJsonFile(string NewFile, bool ThrowIfFileExists = true,
///
public virtual void MakeSymlink(string linkName, string target)
{
- FS.ThrowOnInvalidPath(linkName);
- FS.ThrowOnInvalidPath(target);
-
// Neutralize the paths
linkName = FS.NeutralizePath(linkName);
target = FS.NeutralizePath(target);
@@ -1172,8 +1138,6 @@ public virtual void MoveDirectory(string Source, string Destination) =>
///
public virtual void MoveDirectory(string Source, string Destination, bool ShowProgress)
{
- FS.ThrowOnInvalidPath(Source);
- FS.ThrowOnInvalidPath(Destination);
if (!Checking.FolderExists(Source))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("Directory {0} not found."), Source);
@@ -1222,8 +1186,6 @@ public virtual void MoveDirectory(string Source, string Destination, bool ShowPr
///
public virtual void MoveFile(string Source, string Destination)
{
- FS.ThrowOnInvalidPath(Source);
- FS.ThrowOnInvalidPath(Destination);
Source = FS.NeutralizePath(Source);
DebugWriter.WriteDebug(DebugLevel.I, "Source directory: {0}", Source);
Destination = FS.NeutralizePath(Destination);
@@ -1256,8 +1218,6 @@ public virtual void MoveFile(string Source, string Destination)
///
public virtual void MoveFileOrDir(string Source, string Destination)
{
- FS.ThrowOnInvalidPath(Source);
- FS.ThrowOnInvalidPath(Destination);
Source = FS.NeutralizePath(Source);
DebugWriter.WriteDebug(DebugLevel.I, "Source directory: {0}", Source);
Destination = FS.NeutralizePath(Destination);
@@ -1306,7 +1266,6 @@ public virtual string RenderContents(string filename, bool PrintLineNumbers, boo
var builder = new StringBuilder();
// Check the path
- FS.ThrowOnInvalidPath(filename);
filename = FS.NeutralizePath(filename);
// If interacting with the binary file, display it in hex. Otherwise, display it as if it is text except if forced to view binaries as texts.
@@ -1364,7 +1323,6 @@ public virtual void PrintContents(string filename) =>
public virtual void PrintContents(string filename, bool PrintLineNumbers, bool ForcePlain = false)
{
// Check the path
- FS.ThrowOnInvalidPath(filename);
filename = FS.NeutralizePath(filename);
// Now, render the contents
@@ -1448,7 +1406,6 @@ public virtual void PrintFileInfo(FileSystemEntry FileInfo, bool ShowFileDetails
public virtual byte[] ReadAllBytes(string path)
{
// Read the bytes
- FS.ThrowOnInvalidPath(path);
path = FS.NeutralizePath(path);
return File.ReadAllBytes(path);
}
@@ -1456,8 +1413,6 @@ public virtual byte[] ReadAllBytes(string path)
///
public virtual byte[] ReadAllBytesNoBlock(string path)
{
- FS.ThrowOnInvalidPath(path);
-
// Read all the bytes, bypassing the restrictions.
path = FS.NeutralizePath(path);
long size = new FileSystemEntry(path).FileSize;
@@ -1471,8 +1426,6 @@ public virtual byte[] ReadAllBytesNoBlock(string path)
///
public virtual string[] ReadAllLinesNoBlock(string path)
{
- FS.ThrowOnInvalidPath(path);
-
// Read all the lines, bypassing the restrictions.
path = FS.NeutralizePath(path);
var AllLnList = new List();
@@ -1487,7 +1440,6 @@ public virtual string[] ReadAllLinesNoBlock(string path)
public virtual string[] ReadContents(string filename)
{
// Read the contents
- FS.ThrowOnInvalidPath(filename);
filename = FS.NeutralizePath(filename);
return File.ReadAllLines(filename);
}
@@ -1495,8 +1447,6 @@ public virtual string[] ReadContents(string filename)
///
public virtual string ReadAllTextNoBlock(string path)
{
- FS.ThrowOnInvalidPath(path);
-
// Read all the lines, bypassing the restrictions.
path = FS.NeutralizePath(path);
var fileContentBuilder = new StringBuilder();
@@ -1511,7 +1461,6 @@ public virtual string ReadAllTextNoBlock(string path)
public virtual string ReadContentsText(string filename)
{
// Read the contents
- FS.ThrowOnInvalidPath(filename);
filename = FS.NeutralizePath(filename);
return File.ReadAllText(filename);
}
@@ -1520,7 +1469,6 @@ public virtual string ReadContentsText(string filename)
public virtual void WriteAllBytes(string path, byte[] contents)
{
// Write the bytes
- FS.ThrowOnInvalidPath(path);
path = FS.NeutralizePath(path);
File.WriteAllBytes(path, contents);
}
@@ -1528,8 +1476,6 @@ public virtual void WriteAllBytes(string path, byte[] contents)
///
public virtual void WriteAllLinesNoBlock(string path, string[] contents)
{
- FS.ThrowOnInvalidPath(path);
-
// Write all the lines, bypassing the restrictions.
path = FS.NeutralizePath(path);
var FOpen = new StreamWriter(File.Open(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite));
@@ -1542,7 +1488,6 @@ public virtual void WriteAllLinesNoBlock(string path, string[] contents)
public virtual void WriteContents(string filename, string[] contents)
{
// Write the contents
- FS.ThrowOnInvalidPath(filename);
filename = FS.NeutralizePath(filename);
File.WriteAllLines(filename, contents);
}
@@ -1550,8 +1495,6 @@ public virtual void WriteContents(string filename, string[] contents)
///
public virtual void WriteAllTextNoBlock(string path, string contents)
{
- FS.ThrowOnInvalidPath(path);
-
// Write all the lines, bypassing the restrictions.
path = FS.NeutralizePath(path);
var FOpen = new StreamWriter(File.Open(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite));
@@ -1563,7 +1506,6 @@ public virtual void WriteAllTextNoBlock(string path, string contents)
public virtual void WriteContentsText(string filename, string contents)
{
// Write the contents
- FS.ThrowOnInvalidPath(filename);
filename = FS.NeutralizePath(filename);
File.WriteAllText(filename, contents);
}
@@ -1571,8 +1513,6 @@ public virtual void WriteContentsText(string filename, string contents)
///
public virtual void WriteAllBytesNoBlock(string path, byte[] contents)
{
- FS.ThrowOnInvalidPath(path);
-
// Write all the bytes, bypassing the restrictions.
path = FS.NeutralizePath(path);
var FOpen = File.Open(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
@@ -1583,7 +1523,6 @@ public virtual void WriteAllBytesNoBlock(string path, byte[] contents)
///
public virtual void RemoveAttributeFromFile(string FilePath, FileAttributes Attributes)
{
- FS.ThrowOnInvalidPath(FilePath);
FilePath = FS.NeutralizePath(FilePath);
var Attrib = File.GetAttributes(FilePath);
DebugWriter.WriteDebug(DebugLevel.I, "File attributes: {0}", Attrib);
@@ -1602,7 +1541,6 @@ public virtual void RemoveDirectory(string Target) =>
///
public virtual void RemoveDirectory(string Target, bool ShowProgress, bool secureRemove = false)
{
- FS.ThrowOnInvalidPath(Target);
if (!Checking.FolderExists(Target))
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("Directory {0} not found."), Target);
@@ -1645,7 +1583,6 @@ public virtual void RemoveDirectory(string Target, bool ShowProgress, bool secur
///
public virtual void RemoveFile(string Target, bool secureRemove = false)
{
- FS.ThrowOnInvalidPath(Target);
string Dir = FS.NeutralizePath(Target);
if (secureRemove)
{
@@ -1687,7 +1624,6 @@ public virtual void RemoveFileOrDir(string Target, bool secureRemove = false)
///
public virtual void RemoveFromPathLookup(string Path)
{
- FS.ThrowOnInvalidPath(Path);
var LookupPaths = GetPathList();
Path = FS.NeutralizePath(Path);
LookupPaths.Remove(Path);
@@ -1697,8 +1633,6 @@ public virtual void RemoveFromPathLookup(string Path)
///
public virtual void RemoveFromPathLookup(string Path, string RootPath)
{
- FS.ThrowOnInvalidPath(Path);
- FS.ThrowOnInvalidPath(RootPath);
var LookupPaths = GetPathList();
Path = FS.NeutralizePath(Path, RootPath);
LookupPaths.Remove(Path);
@@ -1710,8 +1644,7 @@ public virtual List SearchFileForString(string FilePath, string StringLo
{
try
{
- FS.ThrowOnInvalidPath(FilePath);
- FilePath = FS.NeutralizePath(FilePath);
+ FilePath = FS.NeutralizePath(FilePath);
var Matches = new List();
var Filebyte = Reading.ReadContents(FilePath);
int MatchNum = 1;
@@ -1742,8 +1675,7 @@ public virtual List SearchFileForStringRegexp(string FilePath, Regex Str
{
try
{
- FS.ThrowOnInvalidPath(FilePath);
- FilePath = FS.NeutralizePath(FilePath);
+ FilePath = FS.NeutralizePath(FilePath);
var Matches = new List();
var Filebyte = Reading.ReadContents(FilePath);
int MatchNum = 1;
@@ -1774,8 +1706,7 @@ public virtual List SearchFileForStringRegexp(string FilePath, Regex Str
{
try
{
- FS.ThrowOnInvalidPath(FilePath);
- FilePath = FS.NeutralizePath(FilePath);
+ FilePath = FS.NeutralizePath(FilePath);
var Matches = new List<(string, MatchCollection)>();
var Filebyte = Reading.ReadContents(FilePath);
for (int i = 0; i < Filebyte.Length; i++)
@@ -1818,8 +1749,7 @@ public virtual bool TryParseFileName(string Name)
{
try
{
- FS.ThrowOnInvalidPath(Name);
- return !(Name.IndexOfAny(IOPath.GetInvalidFileNameChars()) >= 0);
+ return !(Name.IndexOfAny(IOPath.GetInvalidFileNameChars()) >= 0);
}
catch (Exception ex)
{
@@ -1834,8 +1764,7 @@ public virtual bool TryParsePath(string Path)
{
try
{
- FS.ThrowOnInvalidPath(Path);
- return !(Path.IndexOfAny(GetInvalidPathChars()) >= 0);
+ return !(Path.IndexOfAny(GetInvalidPathChars()) >= 0);
}
catch (Exception ex)
{
diff --git a/public/Nitrocid/Files/FilesystemTools.cs b/public/Nitrocid/Files/FilesystemTools.cs
index 0bd9b733f7..9e64c7a192 100644
--- a/public/Nitrocid/Files/FilesystemTools.cs
+++ b/public/Nitrocid/Files/FilesystemTools.cs
@@ -96,8 +96,6 @@ public static string NeutralizePath(string? Path, string? Source, bool Strict =
// Warning: There should be no debug statements until the strict check point.
Path ??= "";
Source ??= "";
- ThrowOnInvalidPath(Path);
- ThrowOnInvalidPath(Source);
// Unescape the characters
Path = RegexpTools.Unescape(Path.Replace(@"\", "/"));
@@ -128,26 +126,6 @@ public static string NeutralizePath(string? Path, string? Source, bool Strict =
return Path;
}
- ///
- /// Mitigates Windows 10/11 NTFS corruption/Blue Screen of Death (BSOD) bug
- ///
- /// Target path
- ///
- /// - When we try to access the secret NTFS bitmap path, which contains $i30, from the partition root path, we'll trigger the "Your disk is corrupt" message.
- /// - When we try to access the kernelconnect secret device from the system partition root path, we'll trigger the BSOD.
- /// This sub will try to prevent access to these paths on unpatched systems and patched systems by throwing
- ///
- public static void ThrowOnInvalidPath(string? Path)
- {
- if (string.IsNullOrEmpty(Path))
- return;
- if (KernelPlatform.IsOnWindows() && (Path.Contains("$i30") || Path.Contains(@"\\.\globalroot\device\condrv\kernelconnect")))
- {
- DebugWriter.WriteDebug(DebugLevel.F, "Trying to access invalid path. Path was {0}", Path);
- throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("Trying to access invalid path. This check was done to prevent older Windows 10 systems that didn't update to the April 2021 patch or higher from accessing these paths known to cause either the NTFS filesystem corruption or the Blue Screen of Death (BSOD) issue. This implies that the caller is attempting to cause a Denial of Service (DoS) and should be fixed, or that the user input is malicious."));
- }
- }
-
///
/// Checks to see if the file is locked
///
diff --git a/public/Nitrocid/Files/Folders/Listing.cs b/public/Nitrocid/Files/Folders/Listing.cs
index 2c96e1df24..f94dec3be8 100644
--- a/public/Nitrocid/Files/Folders/Listing.cs
+++ b/public/Nitrocid/Files/Folders/Listing.cs
@@ -112,7 +112,6 @@ public static void List(string folder, bool ShowFileDetails, bool SuppressUnauth
/// Whether the list is recursive or not
public static void List(string folder, bool ShowFileDetails, bool SuppressUnauthorizedMessage, bool Sort, bool Recursive = false)
{
- FilesystemTools.ThrowOnInvalidPath(folder);
DebugWriter.WriteDebug(DebugLevel.I, "Folder {0} will be listed...", folder);
// List files and folders
@@ -230,7 +229,6 @@ public static void ListTree(string folder, bool SuppressUnauthorizedMessage, boo
/// Indentation level
internal static void ListTree(string folder, bool SuppressUnauthorizedMessage, bool Sort, int level = 0)
{
- FilesystemTools.ThrowOnInvalidPath(folder);
DebugWriter.WriteDebug(DebugLevel.I, "Folder {0} will be listed...", folder);
// List files and folders
diff --git a/public/Nitrocid/Kernel/Configuration/Config.cs b/public/Nitrocid/Kernel/Configuration/Config.cs
index e65415143d..767fcc1156 100644
--- a/public/Nitrocid/Kernel/Configuration/Config.cs
+++ b/public/Nitrocid/Kernel/Configuration/Config.cs
@@ -109,7 +109,6 @@ public static void CreateConfig(string ConfigFolder)
if (KernelEntry.SafeMode)
return;
- FilesystemTools.ThrowOnInvalidPath(ConfigFolder);
if (!Checking.FolderExists(ConfigFolder))
throw new KernelException(KernelExceptionType.Config, Translate.DoTranslation("Specify an existent folder to store the three configuration files on."));
DebugWriter.WriteDebug(DebugLevel.I, "Config folder {0} exists, so saving...", ConfigFolder);
@@ -135,7 +134,6 @@ public static void CreateConfig(BaseKernelConfig type, string ConfigPath)
return;
// Serialize the config object
- FilesystemTools.ThrowOnInvalidPath(ConfigPath);
string serialized = GetSerializedConfig(type);
DebugWriter.WriteDebug(DebugLevel.I, "Got serialized config object of length {0}...", serialized.Length);
@@ -246,7 +244,6 @@ public static void ReadConfig(BaseKernelConfig type) =>
public static void ReadConfig(TConfig type, string ConfigPath)
{
// Open the config JSON file
- FilesystemTools.ThrowOnInvalidPath(ConfigPath);
if (!Checking.FileExists(ConfigPath))
throw new KernelException(KernelExceptionType.Config, Translate.DoTranslation("Specify an existent path to a configuration file"));
diff --git a/public/Nitrocid/Kernel/Configuration/Instances/KernelMainConfig.cs b/public/Nitrocid/Kernel/Configuration/Instances/KernelMainConfig.cs
index 69fca3553c..e5ac501bc4 100644
--- a/public/Nitrocid/Kernel/Configuration/Instances/KernelMainConfig.cs
+++ b/public/Nitrocid/Kernel/Configuration/Instances/KernelMainConfig.cs
@@ -830,16 +830,11 @@ public string CurrentDir
}
set
{
- FilesystemTools.ThrowOnInvalidPath(value);
value = FilesystemTools.NeutralizePath(value);
if (Checking.FolderExists(value))
- {
CurrentDirectory._CurrentDirectory = value;
- }
else
- {
throw new KernelException(KernelExceptionType.Filesystem, Translate.DoTranslation("Directory {0} not found"), value);
- }
}
}
///