Last active
December 14, 2015 15:39
-
-
Save mavnn/5109283 to your computer and use it in GitHub Desktop.
Fun with relative directories...
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
let GetHintPath hintPathFromRoot root projFile = | |
let rootDir = DirectoryInfo(root) | |
let projDir = DirectoryInfo(Path.GetDirectoryName(projFile)) | |
let rec dirDiff (rootDir : DirectoryInfo) (currentDir : DirectoryInfo) levels = | |
if rootDir.FullName = currentDir.FullName then | |
levels | |
else | |
dirDiff rootDir (currentDir.Parent) (levels + 1) | |
hintPathFromRoot::[for _ in 1..(dirDiff rootDir projDir 0) -> ".."] | |
|> List.rev | |
|> List.fold (@@) "." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code is completely untested, so don't rely on it to actually work.
@@ is a custom operator for Path.Combine