Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
fix get files. directory name with dot
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvalsol committed Apr 4, 2023
1 parent 92f682c commit 7ceee81
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions SubtitlesCleaner.Command/SubtitlesHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,26 +337,22 @@ private string[] GetFilePaths(string path, out bool isPathExists)

private string[] GetFiles(string path, bool isRecursive, out bool isPathExists)
{
isPathExists = File.Exists(path) || Directory.Exists(path);

bool isSRTFile = string.Compare(Path.GetExtension(path), ".srt", true) == 0;
if (isSRTFile)
if (Directory.Exists(path))
{
if (File.Exists(path))
return new string[] { path };
isPathExists = true;

return Directory.GetFiles(path, "*.srt", (isRecursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly));
}
else if (Directory.Exists(path))
else if (File.Exists(path))
{
List<string> files = new List<string>(Directory.GetFiles(path, "*.srt", (isRecursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)));
var bakFiles = files.Where(x => x.EndsWith(".bak.srt")).ToArray();
foreach (var bakFile in bakFiles)
{
files.Remove(bakFile);
files.Remove(bakFile.Replace(".bak.srt", ".srt"));
}
return files.ToArray();
isPathExists = true;

bool isSRTFile = string.Compare(Path.GetExtension(path), ".srt", true) == 0;
if (isSRTFile)
return new string[] { path };
}

isPathExists = false;
return null;
}

Expand Down

0 comments on commit 7ceee81

Please sign in to comment.