-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
397 additions
and
220 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Lingua.Api.IO; | ||
|
||
internal abstract class PathValidation | ||
{ | ||
public static void CheckInputFilePath(string inputFilePath) { | ||
if (!Path.IsPathRooted(inputFilePath)) | ||
throw new ArgumentException($"Input file path '{inputFilePath}' is not absolute"); | ||
|
||
if (!File.Exists(inputFilePath)) | ||
throw new DirectoryNotFoundException($"Input file '{inputFilePath}' does not exist"); | ||
|
||
var attributes = File.GetAttributes(inputFilePath); | ||
if (!attributes.HasFlag(FileAttributes.Normal)) | ||
throw new ArgumentException($"Input file path '{inputFilePath}' does not represent a regular file"); | ||
} | ||
|
||
public static void CheckOutputDirectoryPath(string outputDirectoryPath) | ||
{ | ||
if (!Path.IsPathRooted(outputDirectoryPath)) | ||
throw new ArgumentException($"Output directory path '{outputDirectoryPath}' is not absolute"); | ||
|
||
if (!Directory.Exists(outputDirectoryPath)) | ||
throw new DirectoryNotFoundException($"Output directory '{outputDirectoryPath}' does not exist"); | ||
} | ||
} |
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
Oops, something went wrong.