/* * @(#)SecFile.java * * This file is part of webCDwriter - Network CD Writing. * * Copyright (C) 1999-2002 Jörg P. M. Haeger * * webCDwriter is free software. See CDcreator.java for details. */ import java.io.*; import netscape.security.PrivilegeManager; /** * Run the methods of File in a Netscape privilege environment. * * @version 20021111 * @author Jörg P. M. Haeger */ class SecFile extends File2 { public SecFile(File parent, String child) { super(parent, child); } public SecFile(String pathname) { super(pathname); } public boolean canRead() { if (CDcreator.isNetscapeVM()) try { PrivilegeManager.enablePrivilege( "UniversalFileRead"); } catch (Exception e) { } return super.canRead(); } public boolean isDirectory() { if (CDcreator.isNetscapeVM()) try { PrivilegeManager.enablePrivilege( "UniversalFileRead"); } catch (Exception e) { } return super.isDirectory(); } public long length() { if (CDcreator.isNetscapeVM()) try { PrivilegeManager.enablePrivilege( "UniversalFileRead"); } catch (Exception e) { } return super.length(); } public File[] listFiles() { if (CDcreator.isNetscapeVM()) try { PrivilegeManager.enablePrivilege( "UniversalFileRead"); } catch (Exception e) { } String names[] = list(); if (names == null) return null; File[] files = new File[names.length]; for (int i = 0; i < files.length; i++) files[i] = new SecFile(this, names[i]); return files; } }