< prev index next >

src/java.base/windows/classes/java/io/WinNTFileSystem.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.io;
  27 
  28 import java.security.AccessController;
  29 import java.util.Locale;

  30 import sun.security.action.GetPropertyAction;
  31 
  32 /**
  33  * Unicode-aware FileSystem for Windows NT/2000.
  34  *
  35  * @author Konstantin Kladko
  36  * @since 1.4
  37  */
  38 class WinNTFileSystem extends FileSystem {
  39 
  40     private final char slash;
  41     private final char altSlash;
  42     private final char semicolon;
  43 
  44     public WinNTFileSystem() {
  45         slash = AccessController.doPrivileged(
  46             new GetPropertyAction("file.separator")).charAt(0);
  47         semicolon = AccessController.doPrivileged(
  48             new GetPropertyAction("path.separator")).charAt(0);
  49         altSlash = (this.slash == '\\') ? '/' : '\\';
  50     }
  51 
  52     private boolean isSlash(char c) {
  53         return (c == '\\') || (c == '/');
  54     }
  55 
  56     private boolean isLetter(char c) {
  57         return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
  58     }
  59 
  60     private String slashify(String p) {
  61         if ((p.length() > 0) && (p.charAt(0) != slash)) return slash + p;
  62         else return p;
  63     }
  64 
  65     /* -- Normalization and construction -- */
  66 
  67     @Override
  68     public char getSeparator() {




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.io;
  27 

  28 import java.util.Locale;
  29 import java.util.Properties;
  30 import sun.security.action.GetPropertyAction;
  31 
  32 /**
  33  * Unicode-aware FileSystem for Windows NT/2000.
  34  *
  35  * @author Konstantin Kladko
  36  * @since 1.4
  37  */
  38 class WinNTFileSystem extends FileSystem {
  39 
  40     private final char slash;
  41     private final char altSlash;
  42     private final char semicolon;
  43 
  44     public WinNTFileSystem() {
  45         Properties props = GetPropertyAction.getProperties();
  46         slash = props.getProperty("file.separator").charAt(0);
  47         semicolon = props.getProperty("path.separator").charAt(0);

  48         altSlash = (this.slash == '\\') ? '/' : '\\';
  49     }
  50 
  51     private boolean isSlash(char c) {
  52         return (c == '\\') || (c == '/');
  53     }
  54 
  55     private boolean isLetter(char c) {
  56         return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
  57     }
  58 
  59     private String slashify(String p) {
  60         if ((p.length() > 0) && (p.charAt(0) != slash)) return slash + p;
  61         else return p;
  62     }
  63 
  64     /* -- Normalization and construction -- */
  65 
  66     @Override
  67     public char getSeparator() {


< prev index next >