osseps.nim 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # Include file that implements 'DirSep' and friends. Do not import this when
  2. # you also import `os.nim`!
  3. # Improved based on info in 'compiler/platform.nim'
  4. ## .. importdoc:: ospaths2.nim
  5. const
  6. doslikeFileSystem* = defined(windows) or defined(OS2) or defined(DOS)
  7. const
  8. CurDir* =
  9. when defined(macos): ':'
  10. elif defined(genode): '/'
  11. else: '.'
  12. ## The constant character used by the operating system to refer to the
  13. ## current directory.
  14. ##
  15. ## For example: `'.'` for POSIX or `':'` for the classic Macintosh.
  16. ParDir* =
  17. when defined(macos): "::"
  18. else: ".."
  19. ## The constant string used by the operating system to refer to the
  20. ## parent directory.
  21. ##
  22. ## For example: `".."` for POSIX or `"::"` for the classic Macintosh.
  23. DirSep* =
  24. when defined(macos): ':'
  25. elif doslikeFileSystem or defined(vxworks): '\\'
  26. elif defined(RISCOS): '.'
  27. else: '/'
  28. ## The character used by the operating system to separate pathname
  29. ## components, for example: `'/'` for POSIX, `':'` for the classic
  30. ## Macintosh, and `'\\'` on Windows.
  31. AltSep* =
  32. when doslikeFileSystem: '/'
  33. else: DirSep
  34. ## An alternative character used by the operating system to separate
  35. ## pathname components, or the same as DirSep_ if only one separator
  36. ## character exists. This is set to `'/'` on Windows systems
  37. ## where DirSep_ is a backslash (`'\\'`).
  38. PathSep* =
  39. when defined(macos) or defined(RISCOS): ','
  40. elif doslikeFileSystem or defined(vxworks): ';'
  41. elif defined(PalmOS) or defined(MorphOS): ':' # platform has ':' but osseps has ';'
  42. else: ':'
  43. ## The character conventionally used by the operating system to separate
  44. ## search path components (as in PATH), such as `':'` for POSIX
  45. ## or `';'` for Windows.
  46. FileSystemCaseSensitive* =
  47. when defined(macos) or defined(macosx) or doslikeFileSystem or defined(vxworks) or
  48. defined(PalmOS) or defined(MorphOS): false
  49. else: true
  50. ## True if the file system is case sensitive, false otherwise. Used by
  51. ## `cmpPaths proc`_ to compare filenames properly.
  52. ExeExt* =
  53. when doslikeFileSystem: "exe"
  54. elif defined(atari): "tpp"
  55. elif defined(netware): "nlm"
  56. elif defined(vxworks): "vxe"
  57. elif defined(nintendoswitch): "elf"
  58. else: ""
  59. ## The file extension of native executables. For example:
  60. ## `""` for POSIX, `"exe"` on Windows (without a dot).
  61. ScriptExt* =
  62. when doslikeFileSystem: "bat"
  63. else: ""
  64. ## The file extension of a script file. For example: `""` for POSIX,
  65. ## `"bat"` on Windows.
  66. DynlibFormat* =
  67. when defined(macos): "$1.dylib" # platform has $1Lib
  68. elif defined(macosx): "lib$1.dylib"
  69. elif doslikeFileSystem or defined(atari): "$1.dll"
  70. elif defined(MorphOS): "$1.prc"
  71. elif defined(PalmOS): "$1.prc" # platform has lib$1.so
  72. elif defined(genode): "$1.lib.so"
  73. elif defined(netware): "$1.nlm"
  74. elif defined(amiga): "$1.Library"
  75. else: "lib$1.so"
  76. ## The format string to turn a filename into a `DLL`:idx: file (also
  77. ## called `shared object`:idx: on some operating systems).
  78. ExtSep* = '.'
  79. ## The character which separates the base filename from the extension;
  80. ## for example, the `'.'` in `os.nim`.
  81. # MacOS paths
  82. # ===========
  83. # MacOS directory separator is a colon ":" which is the only character not
  84. # allowed in filenames.
  85. #
  86. # A path containing no colon or which begins with a colon is a partial
  87. # path.
  88. # E.g. ":kalle:petter" ":kalle" "kalle"
  89. #
  90. # All other paths are full (absolute) paths. E.g. "HD:kalle:" "HD:"
  91. # When generating paths, one is safe if one ensures that all partial paths
  92. # begin with a colon, and all full paths end with a colon.
  93. # In full paths the first name (e g HD above) is the name of a mounted
  94. # volume.
  95. # These names are not unique, because, for instance, two diskettes with the
  96. # same names could be inserted. This means that paths on MacOS are not
  97. # waterproof. In case of equal names the first volume found will do.
  98. # Two colons "::" are the relative path to the parent. Three is to the
  99. # grandparent etc.