haxeui / haxeui-core

The core library of the HaxeUI framework
http://haxeui.org
MIT License
340 stars 70 forks source link

Should look also in absolute paths for module resources etc #606

Closed Shallowmallow closed 3 months ago

Shallowmallow commented 3 months ago

So that <resource path='/media/[...]/assets' prefix="assets"/> can work I didn't put an if else because of paths like /haxe/ui/_module/styles that are use by haxe ui core

ianharrigan commented 3 months ago

under what conditions would / could the path be absolute?

Shallowmallow commented 3 months ago

I was trying to add ressources in my module I have some that are on a external drive <resource path='/media/[...]/assets' prefix="assets"/> Now on linux, I can always do a symlink, but for windows...

ianharrigan commented 3 months ago

weird, im actually kinda surprised it didnt "just work" before... :/

ianharrigan commented 3 months ago

huh, yeah:

WARNING: Could not resolve resource path C:\Temp\haxeui-testapps\testbench-universal\assets\absolute_path
Shallowmallow commented 3 months ago

Was surprised too ^^ . But 99% of the time we use relative paths, so it wasn't really noticeable.

ianharrigan commented 3 months ago

yeah, just looked at the code and, as im sure you noticed, it was limited to classpath entries, so your change makes alot of sense

as you say, its probably not going to be used very often since absolute paths feel a little "wrong", but yeah, change make sense... just hope there arent false positives that trigger the "isAbsolute" (will check now what that means in haxe land)

ianharrigan commented 3 months ago
    public static function isAbsolute(path:String):Bool {
        if (StringTools.startsWith(path, '/'))
            return true;
        if (path.charAt(1) == ':')
            return true;
        if (StringTools.startsWith(path, '\\\\'))
            return true;
        return false;
    }

probably should be fine...