Closed MiranDMC closed 2 months ago
Can we update ResolvePath in such a way that it:
1) Resolves the absolute path:
absolutePath
to prefix path + input pathabsolutePath
to input pathabsolutePath
to customworkdir path + input pathabsolutePath
to workDir path + input pathabsolutePath
to game root path + input pathabsolutePath
relativePath
) andrelativePath
is not calculated:relativePath
root = C:\root
user = C:\userfiles
cwd = C:\root
same results as above
same results as above
This is writing explicit ModLoader support, but embedded into fabric of whole internal CLEO logic. There is difference between preparing file path before using it somewhere in hope ML picks it up with hooked APIs and resolving file paths for other purposes.
As proposed before whole path processing inside CLEO should be done without complicating it with ML peculiarities, then just translate resulting path to the ML standard just before using it. However that solution is also weak as apparently ML is not consistent in it's working; some APIs work with absolute paths, other require relatives, returned results also vary. Which mean every single place where path is send to some API it need to take in consideration how ML is handling it and how the path should be preprocessed.
CLEO5 was already rewritten to use absolute paths internally to avoid any ambiguities. Once resolved path is absolute and finite. Any further resolving causes no change. Proper Mod Loader was implemented in branch: https://github.com/cleolibrary/CLEO5/pull/143 Which was made by adding ML support to already existing void CLEO_ResolvePath and CLEO_ListDirectory exports.
There is no new logic in the examples, it's just structured + tests cases are given. Which of them you think are wrong?
There is no new logic in the examples, it's just structured + tests cases are given. Which of them you think are wrong?
Resolving cleo:
into cleo
is not resolving anything at all.
0A99 argument is not something that is stored anywhere and can be used for test cases in examples. Only persisting result is actual work dir. So before processing any path it should be resolved to absolute.
0A99 "root:" // or actual non virtual
open_file "cleo\test.ini"
and
0A99 "cleo:" // or actual non virtual
open_file "test.ini"
should produce same result, so there is no point for checking what initial ingredients were.
So if preparing path for ML it would make sense to check if the resulting path starts with game directory, then cut game directory prefix from it. Then also it should be checked if global work dir is actually set to game dir as ML depends on it.
Then it all gets entangled again when taking into account situation where find_first_file is used along with 0A99
All those problems are already solved with generic approach and ML plugin providing exports: give me file, list me files. Just do what you need to do instead of playing around and pretending fake paths.
What test case I provided is incorrect?
0A99 argument is not something that is stored anywhere and can be used for test cases in examples.
it is stored as script's workdir and it is used in the logic I described as workdir
else if workdir has been set with 0A99:
resolve script workdir and
set absolutePath to workDir path + input path
They seems to be logically ok, in matter of what you want to send to ML. As mentioned CLEO5 is intentionally not working on relative paths internally, so that logic can not be embedded in generic util function for resolving paths.
But... "logically" is not what ML is doing, as absolute/relative paths inconsistency was already observed.
What functionality you expect to break if ResolvePath implementation changes to the proposed one?
What functionality you expect to break if ResolvePath implementation changes to the proposed one?
resolve_filepath opcode returning not resolved paths/mixed styles, cleo.log reporting ambiguous paths and potentially any operation in core or plugins that depended on fact resolved path is absolute.
resolve_filepath opcode returning not resolved paths/mixed styles, cleo.log reporting ambiguous paths
currently they return/report wrong paths assuming one location (CLEO) where in fact the physical location of the file is different (modloader). I think it is equally bad.
resolve_filepath opcode returning not resolved paths/mixed styles, cleo.log reporting ambiguous paths
currently they return/report wrong paths assuming one location (CLEO) where in fact the physical location of the file is different (modloader). I think it is equally bad.
I think it is already solved in ML branch. Resolving CLEO path is not so trivial, as each autostarted custom script believe it is located inside CLEO. To complicate things ML loads every cs file it find in any subdirectory of mod.
@MiranDMC
https://github.com/cleolibrary/CLEO5/blob/9670d556b8a59f73432348746588ad8bcbb041c1/source/CScriptEngine.cpp#L719C28-L719C44
weakly_canonical returns an absolute path, so
ResolvePath("cleo") / fsPath
makes the path absolute.