public static bool TryGetDominantDirectorySeparatorPlatform(string pathSegment, out Platform platform) { var detectedDirectorySeparator = DirectorySeparator.TryDetectDirectorySeparatorOrInvalid(pathSegment, out var directorySeparator); if (!detectedDirectorySeparator) { platform = Platform.Unknown; return(false); } platform = DirectorySeparator.GetPlatformForDirectorySeparator(directorySeparator); return(true); }
/// <summary> /// Between the Windows ('\', back-slash) and the non-Windows ('/', slash) directory separators, given one, return the other. /// Unchecked - If the input directory separator is neither the Windows nor non-Windows separator, the Windows separator is returned. /// </summary> public static string GetAlternateDirectorySeparatorUnchecked(string directorySeparator) { var isWindows = DirectorySeparator.IsWindowsDirectorySeparator(directorySeparator); if (isWindows) { return(DirectorySeparator.NonWindows); } else { return(DirectorySeparator.Windows); } }
public static bool IsValid(string directorySeparator) { var isInvalid = DirectorySeparator.IsInvalid(directorySeparator); if (isInvalid) { return(false); } var isDirectorySeparator = DirectorySeparator.IsDirectorySeparator(directorySeparator); return(isDirectorySeparator); }
public static void ValidateWindows(char windowsDirectorySeparator) { DirectorySeparator.Validate(windowsDirectorySeparator); var isWindows = DirectorySeparator.IsWindowsDirectorySeparator(windowsDirectorySeparator); if (!isWindows) { var @string = DirectorySeparator.CharToStringUnchecked(windowsDirectorySeparator); var exception = DirectorySeparator.GetWindowsDirectorySeparatorExpectedException(@string); throw exception; } }
public static void ValidateNonWindows(char nonWindowsDirectorySeparator, string argumentName) { DirectorySeparator.Validate(nonWindowsDirectorySeparator); var isWindows = DirectorySeparator.IsNonWindowsDirectorySeparator(nonWindowsDirectorySeparator); if (!isWindows) { var @string = DirectorySeparator.CharToStringUnchecked(nonWindowsDirectorySeparator); var exception = DirectorySeparator.GetNonWindowsDirectorySeparatorExpectedArgumentException(@string, argumentName); throw exception; } }
public static Platform GetPlatformForDirectorySeparator(string directorySeparator) { DirectorySeparator.Validate(directorySeparator); switch (directorySeparator) { case DirectorySeparator.NonWindows: return(Platform.NonWindows); case DirectorySeparator.Windows: return(Platform.Windows); default: var exception = DirectorySeparator.GetInvalidDirectorySeparatorArgumentException(directorySeparator, nameof(directorySeparator)); throw exception; } }
/// <summary> /// Determines if the specified value equals the specified directory-separator, and if the specified directory separator is actually a directory separator. /// </summary> public static bool IsDirectorySeparator(string value, string possibleDirectorySeparator) { var areEqual = value == possibleDirectorySeparator; if (!areEqual) { return(false); } var isDirectorySeparator = DirectorySeparator.IsDirectorySeparator(possibleDirectorySeparator); if (!isDirectorySeparator) { return(false); } return(true); }
public static string DetectDirectorySeparatorOrDefault(params string[] pathSegments) { var directorySeparator = DirectorySeparator.Invalid; var nSegments = pathSegments.Length; for (int iSegment = 0; iSegment < nSegments; iSegment++) { var pathSegment = pathSegments[iSegment]; directorySeparator = DirectorySeparator.DetectDirectorySeparatorOrInvalid(pathSegment); if (DirectorySeparator.IsValid(directorySeparator)) { return(directorySeparator); } } // Else, return default. return(DirectorySeparator.Default); }
public char GetDirectorySeparatorStringToChar(string directorySeparator) { var output = DirectorySeparator.StringToChar(directorySeparator); return(output); }
public string GetDirectorySeparatorForPlatform(Platform platform) { var output = DirectorySeparator.GetDirectorySeparatorForPlatform(platform); return(output); }
public Exception GetUnableToDetectDirectorySeparatorException(string pathSegment) { var exception = DirectorySeparator.GetUnableToDetectDirectorySeparatorException(pathSegment); return(exception); }
public ArgumentException GetNonWindowsDirectorySeparatorExpectedArgumentException(string found, string parameterName) { var exception = DirectorySeparator.GetNonWindowsDirectorySeparatorExpectedArgumentException(found, parameterName); return(exception); }
public string GetNonWindowsDirectorySeparatorExpectedExceptionMessage(string notNonWindowsDirectorySeparator) { var message = DirectorySeparator.GetNonWindowsDirectorySeparatorExpectedExceptionMessage(notNonWindowsDirectorySeparator); return(message); }
public ArgumentException GetInvalidDirectorySeparatorArgumentException(string invalidDirectorySeparator, string parameterName) { var exception = DirectorySeparator.GetInvalidDirectorySeparatorArgumentException(invalidDirectorySeparator, parameterName); return(exception); }
public bool IsMixedDirectorySeparatorsDetected(string pathSegment) { var output = DirectorySeparator.IsMixedDirectorySeparatorsDetected(pathSegment); return(output); }
public string GetInvalidDirectorySeparatorExceptionMessage(string invalidDirectorySeparator) { var message = DirectorySeparator.GetInvalidDirectorySeparatorExceptionMessage(invalidDirectorySeparator); return(message); }
public Exception GetInvalidDirectorySeparatorException(string invalidDirectorySeparator) { var exception = DirectorySeparator.GetInvalidDirectorySeparatorException(invalidDirectorySeparator); return(exception); }
public bool ContainsDirectorySeparator(string pathSegment, string directorySeparator) { var output = DirectorySeparator.ContainsDirectorySeparator(pathSegment, directorySeparator); return(output); }
public char GetDirectorySeparatorCharForPlatform(Platform platform) { var output = DirectorySeparator.GetDirectorySeparatorCharForPlatform(platform); return(output); }
public bool ContainsMixedDirectorySeparator(string pathSegment) { var output = DirectorySeparator.ContainsMixedDirectorySeparator(pathSegment); return(output); }
public Exception GetNonWindowsDirectorySeparatorExpectedException(string notNonWindowsDirectorySeparator) { var exception = DirectorySeparator.GetNonWindowsDirectorySeparatorExpectedException(notNonWindowsDirectorySeparator); return(exception); }
public bool TryGetDominantDirectorySeparator(string pathSegment, out string dominantDirectorySeparator) { var output = DirectorySeparator.TryGetDominantDirectorySeparator(pathSegment, out dominantDirectorySeparator); return(output); }
public string GetUnableToDetectDirectorySeparatorExceptionMessage(string pathSegment) { var message = DirectorySeparator.GetUnableToDetectDirectorySeparatorExceptionMessage(pathSegment); return(message); }
public string GetDominantDirectorySeparator(string pathSegment) { var output = DirectorySeparator.GetDominantDirectorySeparator(pathSegment); return(output); }
public ArgumentException GetUnableToDetectDirectorySeparatorArgumentException(string pathSegment, string parameterName) { var exception = DirectorySeparator.GetUnableToDetectDirectorySeparatorArgumentException(pathSegment, parameterName); return(exception); }
public void ResetDefaultDirectorySeparator() { DirectorySeparator.ResetDefault(); }
public Platform GetPlatformForDirectorySeparator(string directorySeparator) { var output = DirectorySeparator.GetPlatformForDirectorySeparator(directorySeparator); return(output); }
public bool TryGetDominantDirectorySeparatorPlatform(string pathSegment, out Platform platform) { var output = DirectorySeparator.TryGetDominantDirectorySeparatorPlatform(pathSegment, out platform); return(output); }
public string GetDirectorySeparatorCharToStringUnchecked(char directorySeparatorChar) { var output = DirectorySeparator.CharToStringUnchecked(directorySeparatorChar); return(output); }
public Platform GetDominantDirectorySeparatorPlatform(string pathSegment) { var output = DirectorySeparator.GetDominantDirectorySeparatorPlatform(pathSegment); return(output); }