Closed yakau closed 1 year ago
You're right, it does behave weirdly.
From memory those options were written as ways to make it more general, rather than more strict, to match the game engine's ability to generally find the right file even if you left off the full path or the extension.
So it's checking all of:
let checkFilepathField (files : Collections.Set<string>) (ids : StringTokens) (prefix : string option) (extension : string option) (leafornode) errors =
let key = getOriginalKey ids
let file = (trimQuote key).Replace("\\","/")
let file2 = file.Replace(".lua",".shader").Replace(".tga",".dds")
let file = if extension.IsSome then file + extension.Value else file
match prefix with
| Some pre ->
if files.Contains file || files.Contains (pre + file) || files.Contains file2 || files.Contains (pre + file2) then errors else inv (ErrorCodes.MissingFile file) leafornode <&&&> errors
| None ->
if files.Contains file || files.Contains file2 then errors else inv (ErrorCodes.MissingFile file) leafornode <&&&> errors
If you wanted to work around this, you could try making a type with the type_per_file
setting. One benefit of this would be that "go to definition" would take users to the file (which filepath probably wouldn't do).
When I browsed through the "type/subtype" section in your guidance doc, my brain melted. :-0
I'll give it another go, now that I've got something specific to solve. :)
Would it be possible for me to grab all of the file names from a directory (eg. some/path/ *.ext) and dump them into a complex enum so that
These 3 would be valid selections: some/path/foo.ext some/path/foo2.ext some/path/foo3.ext
And this would not: other/path/wrong.ini
I'm not sure how I'd go about scraping file names.
type[diplomacy_economy] = {
path = "some/path"
type_per_file = yes
}
path_extension = .ext
might do it?Type is more powerful than complex enum here I think
From memory those options were written as ways to make it more general, rather than more strict, to match the game engine's ability to generally find the right file even if you left off the full path or the extension.
That makes sense. I ran another test:
texture = filepath[common/decisions/,.txt]
texture = common/decisions/000_decisions_help.txt
texture = common/decisions/000_decisions_help
texture = 000_decisions_help.txt
texture = 000_decisions_help
texture = 000_decisions_help.foo
The first four were all passed okay, and the last one failed. I see what it's doing now. Not a bug after all. Thanks, mate.
I've been having trouble with
filepath
, so I read your doc, and then ran a test:Config File:
Game File:
Result:
All of the texture files should fail, because none of them match the permitted file's path or extension.
The cardinality fails correctly ("too many texture") "texture = foo" fails correctly ("foo.ext not found")
However, the first two texture values pass, when they should have failed.
It appears that
filepath
is correctly checking the existence of the file, but is not checking if it matches the criteria[in here]
.I looked through cwtools-vscode and the Vic3/CK3/IR/Stellaris configs to see what
filepath[]
was expecting, but I couldn't find much relevant outside of the doc.Your changelog for v0.8.3 mentions
* Add configu rule support for "filepath[prefix]"
- That doesn't seem to be working for me here. Any ideas?I'm running Vic3 through Steam. This is my first time cloning a repository, using VSCode or CWTools. I'm not a coder. Please forgive me if I've made a dumb error.