/[classpath]/classpath/java/io/File.java
ViewVC logotype

Diff of /classpath/java/io/File.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by mkoch, Wed Oct 2 12:58:39 2002 UTC revision 1.20 by mark, Fri Oct 25 12:43:24 2002 UTC
# Line 224  createTempFile(String prefix, String suf Line 224  createTempFile(String prefix, String suf
224    // Verify that we are allowed to create this file    // Verify that we are allowed to create this file
225    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
226    if (sm != null)    if (sm != null)
227      {      sm.checkWrite(f.getAbsolutePath());
 //      try  
 //        {  
           sm.checkWrite(f.getAbsolutePath());  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
228    
229    // Now create the file and return our file object    // Now create the file and return our file object
230    createInternal(f.getAbsolutePath());    createInternal(f.getAbsolutePath());
# Line 572  private synchronized native boolean canR Line 563  private synchronized native boolean canR
563  public boolean  public boolean
564  canWrite() throws SecurityException  canWrite() throws SecurityException
565  {  {
   // Test for existence.  This is required by the spec  
   if (!exists())  
     return(false);  
   
566    // We still need to do a SecurityCheck since exists() only checks    // We still need to do a SecurityCheck since exists() only checks
567    // for read access    // for read access
568    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
569    if (sm != null)    if (sm != null)
570      {      sm.checkWrite(path);
 //      try  
 //        {  
             sm.checkWrite(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
571        
572      // Test for existence.  This is required by the spec
573      if (!exists())
574        return(false);
575    
576    return(canWriteInternal(path));    return(canWriteInternal(path));
577  }  }
578    
# Line 626  setReadOnly() throws SecurityException Line 608  setReadOnly() throws SecurityException
608    // for read access    // for read access
609    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
610    if (sm != null)    if (sm != null)
611      {      sm.checkWrite(path);
 //      try  
 //        {  
             sm.checkWrite(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
612        
613    return(setReadOnlyInternal(path));    return(setReadOnlyInternal(path));
614  }  }
# Line 663  exists() throws SecurityException Line 636  exists() throws SecurityException
636    // Check the SecurityManager    // Check the SecurityManager
637    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
638    if (sm != null)    if (sm != null)
639      {      sm.checkRead(path);
 //      try  
 //        {  
             sm.checkRead(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
640        
641    return(existsInternal(path));    return(existsInternal(path));
642  }  }
# Line 700  public boolean isFile() throws SecurityE Line 664  public boolean isFile() throws SecurityE
664    // Check the SecurityManager    // Check the SecurityManager
665    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
666    if (sm != null)    if (sm != null)
667      {      sm.checkRead(path);
 //      try  
 //        {  
             sm.checkRead(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
668    
669    return(isFileInternal(path));    return(isFileInternal(path));
670  }  }
# Line 739  public boolean isDirectory() throws Secu Line 694  public boolean isDirectory() throws Secu
694    // Check the SecurityManager    // Check the SecurityManager
695    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
696    if (sm != null)    if (sm != null)
697      {      sm.checkRead(path);
 //      try  
 //        {  
             sm.checkRead(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
698    
699    return(isDirectoryInternal(path));    return(isDirectoryInternal(path));
700  }  }
# Line 798  length() throws SecurityException Line 744  length() throws SecurityException
744    // Check the SecurityManager    // Check the SecurityManager
745    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
746    if (sm != null)    if (sm != null)
747      {      sm.checkRead(path);
 //      try  
 //        {  
             sm.checkRead(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
748    
749    return(lengthInternal(path));    return(lengthInternal(path));
750  }  }
# Line 841  lastModified() throws SecurityException Line 778  lastModified() throws SecurityException
778    // Check the SecurityManager    // Check the SecurityManager
779    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
780    if (sm != null)    if (sm != null)
781      {      sm.checkRead(path);
 //      try  
 //        {  
             sm.checkRead(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
782    
783    return(lastModifiedInternal(path));    return(lastModifiedInternal(path));
784  }  }
# Line 889  setLastModified(long time) throws Illega Line 817  setLastModified(long time) throws Illega
817    // Check the SecurityManager    // Check the SecurityManager
818    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
819    if (sm != null)    if (sm != null)
820      {      sm.checkWrite(path);
 //      try  
 //        {  
             sm.checkWrite(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
821        
822    return(setLastModifiedInternal(path, time));    return(setLastModifiedInternal(path, time));
823  }  }
# Line 932  createNewFile() throws IOException, Secu Line 851  createNewFile() throws IOException, Secu
851  {  {
852    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
853    if (sm != null)    if (sm != null)
854      {      sm.checkWrite(path);
 //      try  
 //        {  
             sm.checkWrite(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
855        
856    return(createInternal(getPath()));    return(createInternal(getPath()));
857  }  }
# Line 962  delete() throws SecurityException Line 872  delete() throws SecurityException
872    // Check the SecurityManager    // Check the SecurityManager
873    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
874    if (sm != null)    if (sm != null)
875      {      sm.checkDelete(path);
 //      try  
 //        {  
             sm.checkDelete(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
876    
877    return(deleteInternal(path));    return(deleteInternal(path));
878  }  }
# Line 999  deleteOnExit() throws SecurityException Line 900  deleteOnExit() throws SecurityException
900    // Check the SecurityManager    // Check the SecurityManager
901    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
902    if (sm != null)    if (sm != null)
903      {      sm.checkDelete(path);
 //      try  
 //        {  
             sm.checkDelete(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
904    
905    // Sounds like we need to do some VM specific stuff here. We could delete    // Sounds like we need to do some VM specific stuff here. We could delete
906    // the file in finalize() and set FinalizeOnExit to true, but delete on    // the file in finalize() and set FinalizeOnExit to true, but delete on
# Line 1033  mkdir() throws SecurityException Line 925  mkdir() throws SecurityException
925    // Check the SecurityManager    // Check the SecurityManager
926    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
927    if (sm != null)    if (sm != null)
928      {      sm.checkWrite(path);
 //      try  
 //        {  
             sm.checkWrite(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
929    
930    String mk_path;    String mk_path;
931    mk_path = PlatformHelper.removeTailSeparator(path);    mk_path = PlatformHelper.removeTailSeparator(path);
# Line 1105  renameTo(File dest) throws SecurityExcep Line 988  renameTo(File dest) throws SecurityExcep
988    // Check the SecurityManager    // Check the SecurityManager
989    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
990    if (sm != null)    if (sm != null)
991      {      sm.checkWrite(path);
 //      try  
 //        {  
             sm.checkWrite(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
992    
993    // Call our native rename method    // Call our native rename method
994    boolean rc = renameToInternal(path, dest.getPath());    boolean rc = renameToInternal(path, dest.getPath());
# Line 1186  list(FilenameFilter filter) Line 1060  list(FilenameFilter filter)
1060    // Check the SecurityManager    // Check the SecurityManager
1061    SecurityManager sm = System.getSecurityManager();    SecurityManager sm = System.getSecurityManager();
1062    if (sm != null)    if (sm != null)
1063      {      sm.checkRead(path);
 //      try  
 //        {  
             sm.checkRead(path);  
 //        }  
 //      catch(AccessControlException e)  
 //        {  
 //          throw new SecurityException(e.getMessage())  
 //        }  
     }  
1064    
1065    // Get the list of files    // Get the list of files
1066    String list_path = PlatformHelper.removeTailSeparator(path);    String list_path = PlatformHelper.removeTailSeparator(path);
1067    
     
1068    String files[] = listInternal(list_path);    String files[] = listInternal(list_path);
1069    if (files == null)    if (files == null)
1070      return(null);      return(null);
# Line 1286  public File[] Line 1150  public File[]
1150  listFiles(FilenameFilter filter)  listFiles(FilenameFilter filter)
1151  {  {
1152    String[] filelist = list(filter);    String[] filelist = list(filter);
1153      if (filelist == null)
1154        return(null);
1155    
1156    File[] fobjlist = new File[filelist.length];    File[] fobjlist = new File[filelist.length];
1157    
1158    for (int i = 0; i < filelist.length; i++)    for (int i = 0; i < filelist.length; i++)
# Line 1323  listFiles(FileFilter filter) Line 1190  listFiles(FileFilter filter)
1190  {  {
1191    File[] fobjlist = listFiles((FilenameFilter)null);    File[] fobjlist = listFiles((FilenameFilter)null);
1192    
1193      if (fobjlist == null)
1194        return(null);
1195    
1196      if (filter == null)
1197        return(fobjlist);
1198    
1199    int count = 0;    int count = 0;
1200    for (int i = 0; i < fobjlist.length; i++)    for (int i = 0; i < fobjlist.length; i++)
1201      if (filter.accept(fobjlist[i]) == true)      if (filter.accept(fobjlist[i]) == true)

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26