Files
SQLLint/SQLLinter/Infrastructure/Parser/FileSystemWrapper.cs

40 lines
968 B
C#

using SQLLinter.Core.Interfaces;
namespace SQLLinter.Infrastructure.Parser
{
public class FileSystemWrapper : IFileSystemWrapper
{
public bool FileExists(string path)
{
path = RemoveQuotes(path);
return File.Exists(path);
}
public bool PathIsValidForLint(string path)
{
path = RemoveQuotes(path);
if (!File.Exists(path))
{
return Directory.Exists(path) || PathContainsWildCard(path);
}
return true;
}
private static bool PathContainsWildCard(string filePath)
{
return filePath.Contains("*") || filePath.Contains("?");
}
private string RemoveQuotes(string path)
{
return path.Replace("\"", string.Empty);
}
public string CombinePath(params string[] paths)
{
return Path.Combine(paths);
}
}
}