@@ -2,7 +2,7 @@ package vmt
2
2
3
3
import (
4
4
keyvalues "github.com/galaco/KeyValues"
5
- "github.com/golang-source-engine/filesystem "
5
+ "io "
6
6
"strings"
7
7
)
8
8
@@ -11,10 +11,14 @@ const (
11
11
vmtExtension = ".vmt"
12
12
)
13
13
14
+ type virtualFilesystem interface {
15
+ GetFile (string ) (io.Reader , error )
16
+ }
17
+
14
18
// FromFilesystem loads a material from filesystem
15
19
// Its important to note this is the ONLY way to automatically
16
20
// resolve `import` properties present in a vmt
17
- func FromFilesystem (filePath string , fs * filesystem. FileSystem , definition Material ) (Material , error ) {
21
+ func FromFilesystem (filePath string , fs virtualFilesystem , definition Material ) (Material , error ) {
18
22
// ensure proper file path
19
23
validatedPath := sanitizeFilePath (filePath )
20
24
@@ -38,7 +42,7 @@ func sanitizeFilePath(filePath string) string {
38
42
return filePath
39
43
}
40
44
41
- func readVmtFromFilesystem (path string , fs * filesystem. FileSystem ) (* keyvalues.KeyValue , error ) {
45
+ func readVmtFromFilesystem (path string , fs virtualFilesystem ) (* keyvalues.KeyValue , error ) {
42
46
root , err := readKeyValuesFromFilesystem (path , fs )
43
47
if err != nil {
44
48
return nil , err
@@ -56,7 +60,7 @@ func readVmtFromFilesystem(path string, fs *filesystem.FileSystem) (*keyvalues.K
56
60
return root , nil
57
61
}
58
62
59
- func mergeIncludedVmtRecursive (base * keyvalues.KeyValue , includePath string , fs * filesystem. FileSystem ) (* keyvalues.KeyValue , error ) {
63
+ func mergeIncludedVmtRecursive (base * keyvalues.KeyValue , includePath string , fs virtualFilesystem ) (* keyvalues.KeyValue , error ) {
60
64
parent , err := readKeyValuesFromFilesystem (includePath , fs )
61
65
if err != nil {
62
66
return base , err
@@ -80,7 +84,7 @@ func mergeIncludedVmtRecursive(base *keyvalues.KeyValue, includePath string, fs
80
84
// ReadKeyValues loads a keyvalues file.
81
85
// Its just a simple wrapper that combines the KeyValues library and
82
86
// the filesystem module.
83
- func readKeyValuesFromFilesystem (filePath string , fs * filesystem. FileSystem ) (* keyvalues.KeyValue , error ) {
87
+ func readKeyValuesFromFilesystem (filePath string , fs virtualFilesystem ) (* keyvalues.KeyValue , error ) {
84
88
stream , err := fs .GetFile (filePath )
85
89
if err != nil {
86
90
return nil , err
0 commit comments