1 /*
2 * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
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
784 @Override
785 public String toString() {
786 // OK if two or more threads create a String
787 if (stringValue == null) {
788 stringValue = fs.normalizeJavaPath(Util.toString(path)); // platform encoding
789 }
790 return stringValue;
791 }
792
793 // -- file operations --
794
795 // package-private
796 int openForAttributeAccess(boolean followLinks) throws UnixException {
797 int flags = O_RDONLY;
798 if (!followLinks) {
799 if (O_NOFOLLOW == 0)
800 throw new UnixException
801 ("NOFOLLOW_LINKS is not supported on this platform");
802 flags |= O_NOFOLLOW;
803 }
804 try {
805 return open(this, flags, 0);
806 } catch (UnixException x) {
807 // HACK: EINVAL instead of ELOOP on Solaris 10 prior to u4 (see 6460380)
808 if (getFileSystem().isSolaris() && x.errno() == EINVAL)
809 x.setError(ELOOP);
810
811 throw x;
812 }
813 }
814
815 void checkRead() {
816 SecurityManager sm = System.getSecurityManager();
817 if (sm != null)
818 sm.checkRead(getPathForPermissionCheck());
819 }
820
821 void checkWrite() {
822 SecurityManager sm = System.getSecurityManager();
823 if (sm != null)
824 sm.checkWrite(getPathForPermissionCheck());
825 }
826
827 void checkDelete() {
828 SecurityManager sm = System.getSecurityManager();
829 if (sm != null)
830 sm.checkDelete(getPathForPermissionCheck());
831 }
832
|
1 /*
2 * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
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
784 @Override
785 public String toString() {
786 // OK if two or more threads create a String
787 if (stringValue == null) {
788 stringValue = fs.normalizeJavaPath(Util.toString(path)); // platform encoding
789 }
790 return stringValue;
791 }
792
793 // -- file operations --
794
795 // package-private
796 int openForAttributeAccess(boolean followLinks) throws UnixException {
797 int flags = O_RDONLY;
798 if (!followLinks) {
799 if (O_NOFOLLOW == 0)
800 throw new UnixException
801 ("NOFOLLOW_LINKS is not supported on this platform");
802 flags |= O_NOFOLLOW;
803 }
804 return open(this, flags, 0);
805 }
806
807 void checkRead() {
808 SecurityManager sm = System.getSecurityManager();
809 if (sm != null)
810 sm.checkRead(getPathForPermissionCheck());
811 }
812
813 void checkWrite() {
814 SecurityManager sm = System.getSecurityManager();
815 if (sm != null)
816 sm.checkWrite(getPathForPermissionCheck());
817 }
818
819 void checkDelete() {
820 SecurityManager sm = System.getSecurityManager();
821 if (sm != null)
822 sm.checkDelete(getPathForPermissionCheck());
823 }
824
|