goldenXcode / grafx2

Automatically exported from code.google.com/p/grafx2
0 stars 0 forks source link

Path problem with sub-scripts on AROS #501

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the script "Spritesheet" on AROS

What is the expected output? What do you see instead?
It prints the error "cannot open ../libs/memory.lua:
object name invalid".

Please use labels and text to provide additional information.
Some scripts are loading another script like this:
dofile("../libs/memory.lua")

That ".." doesn't exist on AROS operating systems. A platform independent 
solution has to be found.

Additionally, GrafX2 uses a subdirectory of the current directory for 
libraries. I think a global directory would be better.

Original issue reported on code.google.com by mazzearos on 6 Aug 2012 at 12:23

GoogleCodeExporter commented 9 years ago
Global directory was the original design, and is still supported: factory.c 
sets the environment variable LUA_PATH to <program's data 
directory>/scripts/libs/?.lua
so any script anywhere that does 'require("memory")' will call 
scripts/libs/memory.lua
But this strategy doesn't work with user-provided libraries, whose version can 
change over time : so DawnBringer's scripts should always refer to the specific 
dawnbringer_lib.lua they're shipped with.

Generally, Lua seems to have a very bad support for subdirectories, we also 
have the problem that dofile() is relative to the directory of the first 
calling script, not the called one. I think we should implement a specific 
run() that:
1) changes the current directory
2) runs the called script
3) changes back the current directory

As a step 1b, it could also perform any string modification so that a script 
written for a Linux/Windows filesystem can be translated to AROS filesystem 
terms.
As I understand from the link below, "../../libs/memory.lua" for example would 
be translated to "//libs/memory.lua"
http://aros.sourceforge.net/documentation/users/shell/introduction.php#id1

Original comment by yrizoud on 11 Aug 2012 at 5:42

GoogleCodeExporter commented 9 years ago
> As I understand from the link below, "../../libs/memory.lua" for example
> would be translated to "//libs/memory.lua"

Yes, that's right.

Original comment by mazzearos on 12 Aug 2012 at 8:26

GoogleCodeExporter commented 9 years ago
Path conversion is implemented in r1991.
The recommendation for writers of Lua scripts is to use / path separators, and 
../ for previous directory. And be careful of case sensitivity. And use 
relative paths, not system-specific ones like "DF0:foo" or "C:\foo" or 
"/local/users/foo"
This way, the same scripts will work equally well on all platforms.

Please test and let me know how it goes.

Original comment by yrizoud on 15 Aug 2012 at 5:22

GoogleCodeExporter commented 9 years ago
From looking how PARENT_DIR is defined in const.h, it seems the specific 
conversion should by applied in cases __MORPHOS__ __amigaos4__ __amigaos__ too.

Original comment by yrizoud on 15 Aug 2012 at 5:59

GoogleCodeExporter commented 9 years ago
> Please test and let me know how it goes.

Very good. Thanks :-)

> From looking how PARENT_DIR is defined in const.h, it seems the
> specific conversion should by applied in cases __MORPHOS__
> __amigaos4__ __amigaos__ too.

That's probably true for a lot of my recent fixes for AROS. I'd prefer is 
someone who can test does the changes.

Original comment by mazzearos on 16 Aug 2012 at 9:38

GoogleCodeExporter commented 9 years ago

Original comment by yrizoud on 23 Sep 2012 at 11:55