[DONT MERGE] give a spec to input files
This commit is contained in:
parent
5e233b5020
commit
742796c592
12 changed files with 67 additions and 44 deletions
30
Yavsc.Abstract/FileSystem/FileSystemHelpers.cs
Normal file
30
Yavsc.Abstract/FileSystem/FileSystemHelpers.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace Yavsc.Abstract.FileSystem
|
||||
{
|
||||
public static class FileSystemHelpers
|
||||
{
|
||||
public static bool IsValidYavscPath(this string path)
|
||||
{
|
||||
if (path == null) return true;
|
||||
foreach (var name in path.Split('/'))
|
||||
{
|
||||
if (!IsValidDirectoryName(name) || name.Equals("..") || name.Equals("."))
|
||||
return false;
|
||||
}
|
||||
if (path[path.Length]==FileSystemConstants.RemoteDirectorySeparator) return false;
|
||||
return true;
|
||||
}
|
||||
public static bool IsValidDirectoryName(this string name)
|
||||
{
|
||||
return !name.Any(c => !FileSystemConstants.ValidFileNameChars.Contains(c));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class FileSystemConstants
|
||||
{
|
||||
public const char RemoteDirectorySeparator = '/';
|
||||
public static char[] ValidFileNameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. ".ToCharArray();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue