Closed oprypin closed 6 years ago
@oprypin Will try, but somehow I was not able to achieve it even after discussion on Crystal irc.
@oprypin You are right. It works. But it has impact on other part of library.
This works fine now: BakedFileSystem.load("./something")
But it change behavior of absolute paths!
Now when you call BakedFileSystem.load("/home/name")
it loads /home/name
because of default source = ""
.
With this upgrade it will because of source = __DIR__
do File.join(__DIR__, "/home/name")
which is /dir/path/home/name
- invalid
What would make sense is to check if first argument is absolute path and ignore the other one. What do you think?
Whoa. There is no method to check if path is absolute or relative in Crystal!
@oprypin There is branch with update, can you test it?
Hi. I'm not going to run the code, but I can comment on it.
You don't need to check if the path is absolute, just apply this function, which you seem to already have found.
File.expand_path("foo.html", "/home") #=> "/home/foo.html"
File.expand_path("/foo.html", "/home") #=> "/foo.html"
But you can specify
__DIR__
as the default macro argument. Like so: