-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1110 from morganwillcock/validate-game-name
Editor: Add some validation tools and validate game filename
- Loading branch information
Showing
6 changed files
with
135 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace AGS.Editor.Utils | ||
{ | ||
public class Validation | ||
{ | ||
public static bool FilenameIsValid(string filename) | ||
{ | ||
return !(filename.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0); | ||
} | ||
|
||
public static bool PathIsAvailable(string path) | ||
{ | ||
if (File.Exists(path)) | ||
return false; | ||
|
||
if (Directory.Exists(path)) | ||
return false; | ||
|
||
return true; | ||
} | ||
|
||
public static bool PathIsAbsoluteDriveLetter(string path) | ||
{ | ||
return Regex.IsMatch(path, @"^[a-zA-Z]:\\"); | ||
} | ||
|
||
public static bool PathIsAbsolute(string path) | ||
{ | ||
bool rooted = false; | ||
|
||
try | ||
{ | ||
rooted = Path.IsPathRooted(path); | ||
} | ||
catch (ArgumentException) | ||
{ | ||
// pass | ||
} | ||
|
||
return rooted; | ||
} | ||
|
||
public static bool PathIsValid(string path) | ||
{ | ||
return !(path.IndexOfAny(Path.GetInvalidPathChars()) >= 0); | ||
} | ||
|
||
public static bool StringIsAsciiCharactersOnly(string fileName) | ||
{ | ||
return !fileName.Any(c => c > 127); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters