author | bpb |
Thu, 22 Mar 2018 12:30:47 -0700 | |
changeset 49285 | 4d2e3f5abb48 |
parent 47216 | 71c04702a3d5 |
child 50817 | fa1e04811ff6 |
permissions | -rw-r--r-- |
13360
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
1 |
/* |
49285
4d2e3f5abb48
8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
13360
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
4 |
* |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
10 |
* |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
15 |
* accompanied this code). |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
16 |
* |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
20 |
* |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
23 |
* questions. |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
24 |
*/ |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
25 |
|
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
26 |
package sun.nio.fs; |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
27 |
|
14702
111342b28e67
7142921: (fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04
dxu
parents:
14342
diff
changeset
|
28 |
import java.nio.file.Path; |
111342b28e67
7142921: (fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04
dxu
parents:
14342
diff
changeset
|
29 |
import java.nio.file.spi.FileTypeDetector; |
111342b28e67
7142921: (fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04
dxu
parents:
14342
diff
changeset
|
30 |
import sun.security.action.GetPropertyAction; |
13360
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
31 |
|
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
32 |
/** |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
33 |
* MacOSX implementation of FileSystemProvider |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
34 |
*/ |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
35 |
|
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
36 |
public class MacOSXFileSystemProvider extends BsdFileSystemProvider { |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
37 |
public MacOSXFileSystemProvider() { |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
38 |
super(); |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
39 |
} |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
40 |
|
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
41 |
@Override |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
42 |
MacOSXFileSystem newFileSystem(String dir) { |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
43 |
return new MacOSXFileSystem(this, dir); |
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
44 |
} |
14702
111342b28e67
7142921: (fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04
dxu
parents:
14342
diff
changeset
|
45 |
|
111342b28e67
7142921: (fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04
dxu
parents:
14342
diff
changeset
|
46 |
@Override |
111342b28e67
7142921: (fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04
dxu
parents:
14342
diff
changeset
|
47 |
FileTypeDetector getFileTypeDetector() { |
49285
4d2e3f5abb48
8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents:
47216
diff
changeset
|
48 |
Path userMimeTypes = Path.of(GetPropertyAction |
37781
71ed5645f17c
8155775: Re-examine naming of privileged methods to access System properties
redestad
parents:
37593
diff
changeset
|
49 |
.privilegedGetProperty("user.home"), ".mime.types"); |
31450
35fe554da3fb
8129632: (fs) Files.probeContentType returns null on Mac OS X
bpb
parents:
25859
diff
changeset
|
50 |
|
35fe554da3fb
8129632: (fs) Files.probeContentType returns null on Mac OS X
bpb
parents:
25859
diff
changeset
|
51 |
return chain(new MimeTypesFileTypeDetector(userMimeTypes), |
35fe554da3fb
8129632: (fs) Files.probeContentType returns null on Mac OS X
bpb
parents:
25859
diff
changeset
|
52 |
new UTIFileTypeDetector()); |
14702
111342b28e67
7142921: (fs) Files.probeContentType reports a MIME type of "text/plain" on Ubuntu 11.04
dxu
parents:
14342
diff
changeset
|
53 |
} |
13360
b62b5e86f92a
7130915: File.equals does not give expected results when path contains Non-English characters on Mac OS X
sherman
parents:
diff
changeset
|
54 |
} |