Problem with Windows path?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problem with Windows path?

asotobu
Today I was trying to resolve one problem that affects how Windows path are used by Windows system, at first I though we could do something in java part (in fact we can) but look this case:

Asciidoctor asciidoctor = Asciidoctor.Factory.create();
Map<String, Object> options = OptionsBuilder.options().inPlace(false).safe(SafeMode.UNSAFE).asMap();
options.put("to_file", "target/b.html");

String render = asciidoctor.render("This is", options);
System.out.println(render);


In theory a file should be rendered on currentDirectory/target/b.html but an exception is thrown:

Exception in thread "main" org.jruby.exceptions.RaiseException: (IOError) target directory does not exist: C:/Documents and Settings/alex/sandbox-workspace/demo/C:/Documents and Settings/alex/sandbox-workspace/demo/target

see that in this case I am not using an absolute path, it is an String which is passed directly to Ruby code. Any ideas?

This is the related issue (https://github.com/asciidoctor/asciidoctor-java-integration/issues/36)



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Windows path?

mojavelinux
Administrator
As a matter of fact, I just fixed it :)

My unit test for path resolving were passing, but it was the integration tests that were failing. I had a wrong assumption about what value Ruby assigns to File::SEPARATOR. I thought on Windows it would be a backslash. It turns out, the File::SEPARATOR is always forward slash. It's File::ALT_SEPARATOR that is conditionally set to backslash on Windows.

Now the path resolution logic resolves all Windows paths to the posix variant (which Ruby actually prefers). (That also solved another bug). That means after cleaning the following path:

C:\Users\writer\docs

It will be:

C:/Users/writer/docs

Of course, all the base path stuff is now working correctly. All 906 tests pass on Windows :)

-Dan


On Thu, May 16, 2013 at 12:27 AM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Today I was trying to resolve one problem that affects how Windows path are used by Windows system, at first I though we could do something in java part (in fact we can) but look this case:

Asciidoctor asciidoctor = Asciidoctor.Factory.create();
Map<String, Object> options = OptionsBuilder.options().inPlace(false).safe(SafeMode.UNSAFE).asMap();
options.put("to_file", "target/b.html");

String render = asciidoctor.render("This is", options);
System.out.println(render);


In theory a file should be rendered on currentDirectory/target/b.html but an exception is thrown:

Exception in thread "main" org.jruby.exceptions.RaiseException: (IOError) target directory does not exist: C:/Documents and Settings/alex/sandbox-workspace/demo/C:/Documents and Settings/alex/sandbox-workspace/demo/target

see that in this case I am not using an absolute path, it is an String which is passed directly to Ruby code. Any ideas?

This is the related issue (https://github.com/asciidoctor/asciidoctor-java-integration/issues/36)






If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Problem-with-Windows-path-tp205.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Windows path?

mojavelinux
Administrator
In reply to this post by asotobu
By "just fixed it", I mean its in origin/master :)


On Thu, May 16, 2013 at 2:18 AM, Dan Allen <[hidden email]> wrote:
As a matter of fact, I just fixed it :)

My unit test for path resolving were passing, but it was the integration tests that were failing. I had a wrong assumption about what value Ruby assigns to File::SEPARATOR. I thought on Windows it would be a backslash. It turns out, the File::SEPARATOR is always forward slash. It's File::ALT_SEPARATOR that is conditionally set to backslash on Windows.

Now the path resolution logic resolves all Windows paths to the posix variant (which Ruby actually prefers). (That also solved another bug). That means after cleaning the following path:

C:\Users\writer\docs

It will be:

C:/Users/writer/docs

Of course, all the base path stuff is now working correctly. All 906 tests pass on Windows :)

-Dan


On Thu, May 16, 2013 at 12:27 AM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Today I was trying to resolve one problem that affects how Windows path are used by Windows system, at first I though we could do something in java part (in fact we can) but look this case:

Asciidoctor asciidoctor = Asciidoctor.Factory.create();
Map<String, Object> options = OptionsBuilder.options().inPlace(false).safe(SafeMode.UNSAFE).asMap();
options.put("to_file", "target/b.html");

String render = asciidoctor.render("This is", options);
System.out.println(render);


In theory a file should be rendered on currentDirectory/target/b.html but an exception is thrown:

Exception in thread "main" org.jruby.exceptions.RaiseException: (IOError) target directory does not exist: C:/Documents and Settings/alex/sandbox-workspace/demo/C:/Documents and Settings/alex/sandbox-workspace/demo/target

see that in this case I am not using an absolute path, it is an String which is passed directly to Ruby code. Any ideas?

This is the related issue (https://github.com/asciidoctor/asciidoctor-java-integration/issues/36)






If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Problem-with-Windows-path-tp205.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--



--
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Windows path?

asotobu
cool, then it would work with relative and absolute paths, so I close the issue in asciidoctor-java-project, and next version of asciidoctor will fix this problem.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Windows path?

mojavelinux
Administrator
You got it!

-Dan


On Thu, May 16, 2013 at 2:24 AM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
cool, then it would work with relative and absolute paths, so I close the issue in asciidoctor-java-project, and next version of asciidoctor will fix this problem.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Problem-with-Windows-path-tp205p209.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Loading...