Hi,
Wolfgang Lux wrote:
Riccardo Mottola wrote:
Hi,
I am chasing a strange error in ProjectCenter that drives me crazy.
Depending on how a project was opened, PC misbehaved. I tracked it down to
certain paths depending on the project path being absolute vs. relative.
Especially creations!
What's the best way (= portable also to windows) to get the absolute path of a
file or directory? I looked for methods in NSFileManager but found no easy
route.
In order to determine the absolute path you would need to know the base
directory for the relative path. In case this is the directory of your project,
you should query the NSDocument class or remember the path that was used to
open the project. This is always an absolute path. You then can append the
relative path to that directory using -stringByAppendingPathComponent:.
ProjectCenter triess to remember the path that was used to open the project.
However from a bit of debugging, I found that if "ProjectCenter file.x"
is invoked on the command line,
- (BOOL)application:(NSApplication *)application openFile:(NSString
*)fileName
fileName results in just the file name, not the absolute path.
When using "NSDocument" methods, that is open file, open recent and so
on, I correctly always get a full path.
[[NSURL fileURLWithPath:fileName] path];
Fixes my troubles, but I wonder then if I need to do that or not. If it
is correct that application openFile doesn't get a "normalized" file
path there.
Riccardo
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep