scoop:scoop.core:0.1.0
src/compiler/directory.scoop
Selected production source · src/compiler/directory.scoop
1
package scoop.compiler3
import Array4
import Byte5
import Option.*6
import String8
/**9
* Embeds selected files from a directory inside the defining Cone.10
* The constant path is relative to this call's source directory. Every entry11
* and resolved symlink target must stay inside the Cone, even when excluded.12
* Include and exclude are array literals of constant String patterns. Include13
* patterns form a union; exclude patterns remove matches. Matching uses full,14
* case-sensitive relative paths with '/' separators. '*' stays in a component;15
* '**' spans zero or more directory levels, including the root directory.16
* Defaults include all files, including hidden files; no gitignore is applied.17
* Files are ordered by relative path in UTF-8 byte order. Empty directories18
* are omitted. This compile-time intrinsic cannot be used as a function reference.19
*/20
@Intrinsic("include_dir")21
public fun includeDir(22
path: String,23
include: Array<String> = ["**"],24
exclude: Array<String> = []25
): EmbeddedDir27
/** One immutable file with its logical path relative to the included directory. */28
public struct EmbeddedFile(val path: String, val bytes: Array<Byte>)30
/**31
* An immutable file table. Lookup returns the first exact path match, or None.32
* Lookup does not expand globs, normalize paths, or access the file system.33
*/34
public struct EmbeddedDir(val files: Array<EmbeddedFile>) {35
public operator fun get(path: String): Array<Byte>? {36
for (file in files) {37
if (file.path == path)38
return Some(file.bytes)39
}40
return None41
}42
}