I agree move the
if (jclSeparator == '/') return
earlier is the easiest way to fix this. And I have tested the fix with
the tests referenced in this thread luni unit tests, all passed. So I
will attach the patch to the JIRA soon.
Best Regards,
Regis.
Mark Hindess wrote:
In message <[EMAIL PROTECTED]>, Regis writes:
Thanks Mark. After the fix, "\\" doesn't transform to "/" in constructor
now, but new File("d1\\d2").mkdir(); return false and create nothing on
file system. The implementation of File.mkdir() delegate to native
code by return mkdirImpl(properPath(true)); maybe properPath do the
wrong thing. But I notice new File("d1\\d2").exists() will return false
when there is file "d1/d2" in file system. So I suspect native code
couldn't deal with "\\" correctly neither.
On Linux, with the RI if I get the following in an empty directory:
(new File("d1\d2")).exists(): false
(new File("d1\d2").mkdir(): true
(new File("d1\d2")).exists(): true
(new File("d1\d2").mkdir(): false
and a directory called "d1\d2" is created.
On Linux, with Harmony I get:
(new File("d1\d2")).exists(): false
(new File("d1\d2").mkdir(): false
and no directory is created. So I concur, something is still wrong.
It looks like it is probably a problem with ioh_convertToPlatform
which I think should possibly do *nothing* on unix. That is move the
if (jclSeparator == '/') return
to the earlier in the function.
-Mark.
I will try to dig more...
Best Regards,
Regis.
Mark Hindess wrote:
In message <[EMAIL PROTECTED]>, Tim Ellison writes:
Regis wrote:
It seems intended to be, but I'm not sure. I think it's a great feature
when porting the windows depended code("\\" in path name) to linux, but
there is potential problem, how to reference a file which name contians
"\\" on linux? And this different may cause surprise when some
applications depends on the behavior of RI.
Any comments/suggestions?
I think we need to change to allow \ to be passed through as part of the
file name on Linux.
I agree with Tim. In fact, I noticed this issue a little while ago and
fixed it (plus some invalid tests) in commit r698140.
-Mark.
Regis Xu (JIRA) wrote:
[classlib][luni] - different behavior with RI when file path contains
"\\" in Linux
------------------------------------------------------------------------
--
---------
Key: HARMONY-5987
URL: https://issues.apache.org/jira/browse/HARMONY-5987
Project: Harmony
Issue Type: Bug
Components: Classlib
Affects Versions: 5.0M7
Reporter: Regis Xu
Fix For: 5.0M8
Consider the test:
File file = new File("d1\\d2");
file.mkdirs();
RI create a directory named "d1\d2", while Harmony create two
directories "d1" and "d1/d2", seems RI doesn't covert windows file
separator char "\\" to system separator char on Linux, and
spec says nothing about it. I quickly navigate the source, found we
have a method fixSlashes in java.io.File, which convert "\\" or "/" to
system separator char, so it may be intended or a feature of harmony?