Added PathHelper

dev_timestamp
Harald Wolff 2019-08-31 00:38:51 +02:00
parent 94e648406b
commit 9384a87b6d
2 changed files with 54 additions and 0 deletions

53
PathHelper.cs 100644
View File

@ -0,0 +1,53 @@
// /**
// * File: PathHelper.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
namespace ln.types
{
public static class PathHelper
{
public static string FindPath(params string[] search) => FindPath((IEnumerable<string>)search);
public static string FindPath(IEnumerable<string> search)
{
foreach (string p in search)
{
if (Directory.Exists(p) || File.Exists(p))
return Path.GetFullPath(p);
}
return null;
}
public static string FindDirectory(params string[] search) => FindPath((IEnumerable<string>)search);
public static string FindDirectory(IEnumerable<string> search)
{
foreach (string p in search)
{
if (Directory.Exists(p))
return Path.GetFullPath(p);
}
return null;
}
public static string FindFile(string filename, params string[] search) => FindFile(filename, (IEnumerable<string>)search);
public static string FindFile(string filename, IEnumerable<string> search)
{
foreach (string p in search)
{
String path = Path.Combine(p, filename);
if (File.Exists(path))
return path;
}
return null;
}
}
}

View File

@ -95,6 +95,7 @@
<Compile Include="odb\ng\index\SimpleIndex.cs" />
<Compile Include="odb\ng\index\Path.cs" />
<Compile Include="odb\ng\index\IndexPath.cs" />
<Compile Include="PathHelper.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="odb\" />