FSharp.Management icon indicating copy to clipboard operation
FSharp.Management copied to clipboard

type Windows = FileSystem<"%SystemRoot%"> // (%SystemRoot% is Environment variable)

Open dzmitry-lahoda opened this issue 9 years ago • 2 comments

Is next possible?

type Windows = FileSystem<"%SystemRoot%"> // (%SystemRoot% is Environment variable usually to "C:/Windows")

Sometimes enterprise admins setups some things which are usually on C:/ to go to other routes via Environment variables.

dzmitry-lahoda avatar Aug 04 '15 13:08 dzmitry-lahoda

It is not possible, but easy to implement.

vasily-kirichenko avatar Aug 04 '15 13:08 vasily-kirichenko

@vasily-kirichenko The easy part is expanding the environment variables once on compile time, i.e. FileSystem<"%SystemRoot%">.Path = @"C:\Windows\". Then, when deploying the compiled program to another machine, the path stays the same, regardless of the actual value of the environment variable. @asd-and-Rizzo is this what you wanted?

I think it would be interesting to also support runtime environment variables: FileSystem<"%Public%">.DynamicPath = @"C:\Users\Public" on standard systems and @"U:\Public" on some other, regardless of the system the program was compiled on. Obviously, DynamicPath can't be [<Literal>]. What do you think?

Things to decide upon

  • [ ] Always expand paths vs. have boolean flag, e.g. FileSystem<"%SystemRoot%", expandEnvVars = true> Note: C:\%TMP%\%WHY%DID%%YOU%DO.that is a valid name, requiring escaping % is a breaking change.
  • [ ] To include DynamicPath / RuntimePath / ... or not? (Having above flag, provide only if switched on.)
  • [ ] Include expansion for relativeTo parameter?
  • [ ] Include expansion for RelativePath<...> provider?

All things settled, I'd volunteer for implementing.

CaringDev avatar Jan 07 '17 08:01 CaringDev