Skip to content

Commit 270e83a

Browse files
committed
Make initial home path configurable.
1 parent 622c972 commit 270e83a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sources/LispKit/Primitives/SystemLibrary.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public final class SystemLibrary: NativeLibrary {
5353
public override func declarations() {
5454
self.currentDirectoryProc =
5555
Procedure(.procedure(Procedure("_validCurrentPath", self.validCurrentPath)),
56-
.makeString(self.context.fileHandler.currentDirectoryPath))
56+
.makeString(self.context.initialHomePath ??
57+
self.context.fileHandler.currentDirectoryPath))
5758
self.compileAndEvalFirstProc =
5859
Procedure("_compileAndEvalFirst", self.compileAndEvalFirst)
5960
self.define("current-directory", as: .procedure(self.currentDirectoryProc))

Sources/LispKit/Runtime/Context.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public final class Context {
3535
/// Command-line arguments
3636
public let commandLineArguments: [String]
3737

38+
/// Initial home path used by the LispKit file system
39+
public let initialHomePath: String?
40+
3841
/// A delegate object which receives updates related to the virtual machine managed by
3942
/// this context. The virtual machine also delegates some functionality to this object.
4043
public var delegate: ContextDelegate?
@@ -100,6 +103,7 @@ public final class Context {
100103
implementationName: String? = nil,
101104
implementationVersion: String? = nil,
102105
commandLineArguments: [String]? = nil,
106+
initialHomePath: String? = nil,
103107
includeInternalResources: Bool = true,
104108
includeDocumentPath: String? = "LispKit",
105109
delegate: ContextDelegate? = nil) {
@@ -108,6 +112,7 @@ public final class Context {
108112
self.implementationName = implementationName ?? Context.implementationName
109113
self.implementationVersion = implementationVersion ?? Context.implementationVersion
110114
self.commandLineArguments = commandLineArguments ?? CommandLine.arguments
115+
self.initialHomePath = initialHomePath
111116
self.console = console
112117
self.heap = Heap()
113118
self.fileHandler = FileHandler(includeInternalResources: includeInternalResources,

0 commit comments

Comments
 (0)