-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add staticFileExists and staticDirExists
- Loading branch information
1 parent
9471b5f
commit a16b40d
Showing
4 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## This module implements path handling like os module but works at only compile-time. | ||
## This module works even when cross compiling to OS that is not supported by os module. | ||
|
||
proc staticFileExists*(filename: string): bool {.compileTime.} = | ||
## Returns true if `filename` exists and is a regular file or symlink. | ||
## | ||
## Directories, device files, named pipes and sockets return false. | ||
discard | ||
|
||
proc staticDirExists*(dir: string): bool {.compileTime.} = | ||
## Returns true if the directory `dir` exists. If `dir` is a file, false | ||
## is returned. Follows symlinks. | ||
discard |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import std/[assertions, staticos, os] | ||
|
||
block: | ||
static: | ||
doAssert staticDirExists("MISSINGFILE") == false | ||
doAssert staticFileExists("MISSINGDIR") == false | ||
doAssert staticDirExists(currentSourcePath().parentDir) | ||
doAssert staticFileExists(currentSourcePath()) |
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