< prev index next >

src/java.desktop/share/classes/java/awt/color/ICC_Profile.java

Print this page




1857 
1858         if (f != null && !f.isFile()) {
1859             f = null;
1860         }
1861         return f;
1862     }
1863 
1864     /**
1865      * Returns a stream corresponding to a built-in profile
1866      * specified by fileName.
1867      * If there is no built-in profile with such name, then the method
1868      * returns null.
1869      */
1870     private static InputStream getStandardProfileInputStream(String fileName) {
1871         return AccessController.doPrivileged(
1872             new PrivilegedAction<InputStream>() {
1873                 public InputStream run () {
1874                     return
1875                         PCMM.class.getResourceAsStream("profiles/" + fileName);
1876                 }
1877             }, null, new FilePermission("<<ALL FILES>>", "read"));

1878     }
1879 
1880     /**
1881      * Checks whether given file resides inside give directory.
1882      */
1883     private static boolean isChildOf(File f, String dirName) {
1884         try {
1885             File dir = new File(dirName);
1886             String canonicalDirName = dir.getCanonicalPath();
1887             if (!canonicalDirName.endsWith(File.separator)) {
1888                 canonicalDirName += File.separator;
1889             }
1890             String canonicalFileName = f.getCanonicalPath();
1891             return canonicalFileName.startsWith(canonicalDirName);
1892         } catch (IOException e) {
1893             /* we do not expect the IOException here, because invocation
1894              * of this function is always preceded by isFile() call.
1895              */
1896             return false;
1897         }




1857 
1858         if (f != null && !f.isFile()) {
1859             f = null;
1860         }
1861         return f;
1862     }
1863 
1864     /**
1865      * Returns a stream corresponding to a built-in profile
1866      * specified by fileName.
1867      * If there is no built-in profile with such name, then the method
1868      * returns null.
1869      */
1870     private static InputStream getStandardProfileInputStream(String fileName) {
1871         return AccessController.doPrivileged(
1872             new PrivilegedAction<InputStream>() {
1873                 public InputStream run () {
1874                     return
1875                         PCMM.class.getResourceAsStream("profiles/" + fileName);
1876                 }
1877             }, null, new FilePermission("<<ALL FILES>>", "read"),
1878                      new RuntimePermission("accessSystemModules"));
1879     }
1880 
1881     /**
1882      * Checks whether given file resides inside give directory.
1883      */
1884     private static boolean isChildOf(File f, String dirName) {
1885         try {
1886             File dir = new File(dirName);
1887             String canonicalDirName = dir.getCanonicalPath();
1888             if (!canonicalDirName.endsWith(File.separator)) {
1889                 canonicalDirName += File.separator;
1890             }
1891             String canonicalFileName = f.getCanonicalPath();
1892             return canonicalFileName.startsWith(canonicalDirName);
1893         } catch (IOException e) {
1894             /* we do not expect the IOException here, because invocation
1895              * of this function is always preceded by isFile() call.
1896              */
1897             return false;
1898         }


< prev index next >