/// <summary>Checks whether parent directories are equal for the passed file paths.</summary> /// <param name="firstPath">path to the first file</param> /// <param name="secondPath">path to the second file</param> /// <returns>true if parent directories are equal, otherwise - false</returns> private bool AreEqualParentDirectories(String firstPath, String secondPath) { String firstParentDir = TesseractOcrUtil.GetParentDirectory(firstPath); String secondParentDir = TesseractOcrUtil.GetParentDirectory(secondPath); return(firstParentDir != null && firstParentDir.Equals(secondParentDir)); }
/// <summary> /// Create list of parameters for command moving to the image parent /// directory. /// </summary> /// <param name="imagePath">path to input image</param> /// <returns>command list</returns> private IList <String> MoveToImageDirectory(String imagePath) { // go the image parent directory IList <String> @params = new List <String>(); String parent = TesseractOcrUtil.GetParentDirectory(imagePath); String replacement = IsWindows() ? "" : "/"; parent = parent.Replace("file:///", replacement).Replace("file:/", replacement); // Use "/d" parameter to handle cases when the current directory on Windows // is located on a different drive compared to the directory we move to if (IsWindows()) { @params.Add("cd /d"); } else { @params.Add("cd"); } @params.Add(AddQuotes(parent)); return(@params); }