mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-09-01 19:51:28 +02:00
Removed special character check, cleanup
This commit is contained in:
@@ -30,40 +30,35 @@ namespace Flowframes.IO
|
||||
public static string[] ReadLines(string path)
|
||||
{
|
||||
List<string> lines = new List<string>();
|
||||
using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 0x1000, FileOptions.SequentialScan))
|
||||
using (var sr = new StreamReader(fs, Encoding.UTF8))
|
||||
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 0x1000, FileOptions.SequentialScan))
|
||||
|
||||
using (var reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
string line;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
lines.Add(line);
|
||||
}
|
||||
|
||||
return lines.ToArray();
|
||||
}
|
||||
|
||||
public static bool IsPathDirectory(string path)
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
path = path.Trim();
|
||||
|
||||
path = path.Trim();
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (File.Exists(path))
|
||||
{
|
||||
|
||||
if (File.Exists(path))
|
||||
return false;
|
||||
}
|
||||
if (new string[2]
|
||||
{
|
||||
"\\",
|
||||
"/"
|
||||
}.Any((string x) => path.EndsWith(x)))
|
||||
{
|
||||
|
||||
if (new string[2] {"\\", "/"}.Any((string x) => path.EndsWith(x)))
|
||||
return true;
|
||||
}
|
||||
return string.IsNullOrWhiteSpace(Path.GetExtension(path));
|
||||
|
||||
return string.IsNullOrWhiteSpace(Path.GetExtension(path));
|
||||
}
|
||||
|
||||
public static bool IsFileValid(string path)
|
||||
@@ -159,16 +154,7 @@ namespace Flowframes.IO
|
||||
File.Move(path, targetPath);
|
||||
}
|
||||
|
||||
public static int GetFilenameCounterLength(string file, string prefixToRemove = "")
|
||||
{
|
||||
string filenameNoExt = Path.GetFileNameWithoutExtension(file);
|
||||
if (!string.IsNullOrEmpty(prefixToRemove))
|
||||
filenameNoExt = filenameNoExt.Replace(prefixToRemove, "");
|
||||
string onlyNumbersFilename = Regex.Replace(filenameNoExt, "[^.0-9]", "");
|
||||
return onlyNumbersFilename.Length;
|
||||
}
|
||||
|
||||
public static int GetAmountOfFiles (string path, bool recursive, string wildcard = "*")
|
||||
public static int GetAmountOfFiles (string path, bool recursive, string wildcard = "*")
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -646,9 +632,7 @@ namespace Flowframes.IO
|
||||
try
|
||||
{
|
||||
Image img = GetImage(path);
|
||||
if (img.Width > 1 && img.Height > 1)
|
||||
return true;
|
||||
return false;
|
||||
return (img.Width > 0 && img.Height > 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -702,6 +686,7 @@ namespace Flowframes.IO
|
||||
// Add file sizes.
|
||||
string[] files;
|
||||
StringComparison ignCase = StringComparison.OrdinalIgnoreCase;
|
||||
|
||||
if (includedExtensions == null)
|
||||
files = Directory.GetFiles(path);
|
||||
else
|
||||
@@ -745,12 +730,7 @@ namespace Flowframes.IO
|
||||
}
|
||||
}
|
||||
|
||||
public static bool HasBadChars(string str)
|
||||
{
|
||||
return str != str.StripBadChars();
|
||||
}
|
||||
|
||||
public static void OverwriteFileWithText (string path, string text = "THIS IS A DUMMY FILE - DO NOT DELETE ME")
|
||||
public static void OverwriteFileWithText (string path, string text = "THIS IS A DUMMY FILE - DO NOT DELETE ME")
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -771,7 +751,7 @@ namespace Flowframes.IO
|
||||
|
||||
foreach (DriveInfo d in allDrives)
|
||||
{
|
||||
if (d.IsReady == true && d.Name.StartsWith(driveLetter))
|
||||
if (d.IsReady && d.Name.StartsWith(driveLetter))
|
||||
{
|
||||
if (mbytes)
|
||||
return (long)(d.AvailableFreeSpace / 1024f / 1000f);
|
||||
@@ -784,6 +764,7 @@ namespace Flowframes.IO
|
||||
{
|
||||
Logger.Log("Error trying to get disk space: " + e.Message, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace Flowframes
|
||||
if (!ResumeUtils.resumeNextRun && !Utils.CheckDeleteOldTempFolder()) return; // Try to delete temp folder if an old one exists
|
||||
if (!Utils.CheckPathValid(current.inPath)) return; // Check if input path/file is valid
|
||||
if (!(await Utils.CheckEncoderValid())) return; // Check NVENC compat
|
||||
Utils.PathAsciiCheck(current.outPath, "output path");
|
||||
currentInputFrameCount = await Utils.GetInputFrameCountAsync(current.inPath);
|
||||
current.stepByStep = false;
|
||||
Program.mainForm.SetStatus("Starting...");
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Flowframes.Main
|
||||
|
||||
current.framesFolder = Path.Combine(current.tempFolder, Paths.framesDir);
|
||||
|
||||
if (!Directory.Exists(current.framesFolder) || IOUtils.GetAmountOfFiles(current.framesFolder, false, "*.png") < 2)
|
||||
if (IOUtils.GetAmountOfFiles(current.framesFolder, false, "*.png") < 2)
|
||||
{
|
||||
InterpolateUtils.ShowMessage("There are no extracted frames that can be interpolated!\nDid you run the extraction step?", "Error");
|
||||
return;
|
||||
@@ -99,7 +99,7 @@ namespace Flowframes.Main
|
||||
|
||||
public static async Task CreateOutputVid()
|
||||
{
|
||||
if (!Directory.Exists(current.interpFolder) || IOUtils.GetAmountOfFiles(current.interpFolder, false) < 2)
|
||||
if (IOUtils.GetAmountOfFiles(current.interpFolder, false) < 2)
|
||||
{
|
||||
Cancel($"There are no interpolated frames to encode!\n\nDid you delete the folder?");
|
||||
return;
|
||||
|
||||
@@ -331,12 +331,6 @@ namespace Flowframes.Main
|
||||
return passes;
|
||||
}
|
||||
|
||||
public static void PathAsciiCheck(string path, string pathTitle)
|
||||
{
|
||||
if (IOUtils.HasBadChars(path) || OSUtils.HasNonAsciiChars(path))
|
||||
ShowMessage($"Warning: Your {pathTitle} includes special characters. This might cause problems. If you get an error, try removing those symbols.");
|
||||
}
|
||||
|
||||
public static bool CheckAiAvailable(AI ai)
|
||||
{
|
||||
if (IOUtils.GetAmountOfFiles(Path.Combine(Paths.GetPkgPath(), ai.pkgDir), true) < 1)
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace Flowframes.UI
|
||||
Program.mainForm.SetTab("interpolate");
|
||||
Program.mainForm.ResetInputInfo();
|
||||
string path = inputTbox.Text.Trim();
|
||||
InterpolateUtils.PathAsciiCheck(path, "input path");
|
||||
|
||||
if (Config.GetBool("clearLogOnInput"))
|
||||
Logger.ClearLogBox();
|
||||
|
||||
Reference in New Issue
Block a user