osseps.nim 4.1 KB

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