cross-platform pathnames

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

cross-platform pathnames

Dave Liebreich
I need some help with cross-platform pathnames in makefiles.

I'm trying to pass the name of a directory containing test data to a
script run by xpcshell.

On windows, I get an error.

The makefile target is:

check::
   $(CYGWIN_WRAPPER) $(RUN_TEST_PROGRAM)
$(DIST)/bin/xpcshell$(BIN_SUFFIX) $(srcdir)/test/shell.js $(srcdir)/test

in shell.js, I have:

   var topDir = Components.classes["@mozilla.org/file/local;1"]
     .createInstance(Components.interfaces.nsILocalFile);

   topDir.initWithPath(arguments[0]);

(arguments is xpcshell's argv)

On mac and linux, this works fine.

On win, I get NS_ERROR_FILE_UNRECOGNIZED_PATH

I tried omitting the CYGWIN_WRAPPER, but that did not work.  Neither did
inserting "-nowrap" before the last arg.

Do I need to check the platform in shell.js, then replace "/" with "\"
if running on windows?  Or is there another method/component I can use
that won't barf on the cygwin path?

Thanks

--
Dave Liebreich
Test Architect, Mozilla Corporation
_______________________________________________
dev-builds mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-builds
Reply | Threaded
Open this post in threaded view
|

Re: cross-platform pathnames

Mike Shaver
I suspect you'll need to regex-magic it to change /cygdrive/x to x:,
in that string.  Could theoretically break someone who uses /cygdrive
on Mac or Unix, but I can live that dangerously.

Mike

On 5/23/06, Dave Liebreich <[hidden email]> wrote:

> I need some help with cross-platform pathnames in makefiles.
>
> I'm trying to pass the name of a directory containing test data to a
> script run by xpcshell.
>
> On windows, I get an error.
>
> The makefile target is:
>
> check::
>    $(CYGWIN_WRAPPER) $(RUN_TEST_PROGRAM)
> $(DIST)/bin/xpcshell$(BIN_SUFFIX) $(srcdir)/test/shell.js $(srcdir)/test
>
> in shell.js, I have:
>
>    var topDir = Components.classes["@mozilla.org/file/local;1"]
>      .createInstance(Components.interfaces.nsILocalFile);
>
>    topDir.initWithPath(arguments[0]);
>
> (arguments is xpcshell's argv)
>
> On mac and linux, this works fine.
>
> On win, I get NS_ERROR_FILE_UNRECOGNIZED_PATH
>
> I tried omitting the CYGWIN_WRAPPER, but that did not work.  Neither did
> inserting "-nowrap" before the last arg.
>
> Do I need to check the platform in shell.js, then replace "/" with "\"
> if running on windows?  Or is there another method/component I can use
> that won't barf on the cygwin path?
>
> Thanks
>
> --
> Dave Liebreich
> Test Architect, Mozilla Corporation
> _______________________________________________
> dev-builds mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-builds
>
_______________________________________________
dev-builds mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-builds