1 19 20 package org.openide.loaders; 21 22 import java.io.File ; 23 import java.io.FileOutputStream ; 24 import java.io.IOException ; 25 import java.io.PrintWriter ; 26 import java.net.URL ; 27 import java.text.DecimalFormat ; 28 import java.text.NumberFormat ; 29 import java.util.Arrays ; 30 import java.util.Enumeration ; 31 import java.util.HashMap ; 32 import java.util.Iterator ; 33 import java.util.Map ; 34 import java.util.StringTokenizer ; 35 36 import org.openide.filesystems.*; 37 38 41 public class TestUtilHid { 42 public static FileSystem createLocalFileSystem(String name, String [] resources) throws IOException { 43 File f = File.createTempFile (name, ".tmp"); 44 f.delete (); 45 f = new File (f.getParent (), name); 46 f.mkdirs (); 47 return createLocalFileSystem (f, resources); 48 } 49 50 public static FileSystem createLocalFileSystem(File mountPoint, String [] resources) throws IOException { 51 mountPoint.mkdir(); 52 53 for (int i = 0; i < resources.length; i++) { 54 File f = new File (mountPoint,resources[i]); 55 if (f.isDirectory() || resources[i].endsWith("/")) { 56 f.mkdirs(); 57 } 58 else { 59 f.getParentFile().mkdirs(); 60 try { 61 f.createNewFile(); 62 } catch (IOException iex) { 63 throw new IOException ("While creating " + resources[i] + " in " + mountPoint.getAbsolutePath() + ": " + iex.toString() + ": " + f.getAbsolutePath() + " with resource list: " + Arrays.asList(resources)); 64 } 65 } 66 } 67 68 LocalFileSystem lfs = new StatusFileSystem(); 69 try { 70 lfs.setRootDirectory(mountPoint); 71 } catch (Exception ex) {} 72 73 return lfs; 74 } 75 76 public final static void destroyLocalFileSystem (String testName) throws IOException { 77 } 78 79 static class StatusFileSystem extends LocalFileSystem { 80 Status status = new Status () { 81 public String annotateName (String name, java.util.Set files) { 82 return name; 83 } 84 85 public java.awt.Image annotateIcon (java.awt.Image icon, int iconType, java.util.Set files) { 86 return icon; 87 } 88 }; 89 90 public org.openide.filesystems.FileSystem.Status getStatus() { 91 return status; 92 } 93 94 } 95 } 96 | Popular Tags |