1 15 package org.eclipse.core.internal.filesystem.local; 16 17 import java.io.File ; 18 import java.net.URI ; 19 import org.eclipse.core.filesystem.*; 20 import org.eclipse.core.filesystem.provider.FileSystem; 21 import org.eclipse.core.runtime.IPath; 22 import org.eclipse.osgi.service.environment.Constants; 23 24 28 public class LocalFileSystem extends FileSystem { 29 32 static final boolean MACOSX = LocalFileSystem.getOS().equals(Constants.OS_MACOSX); 33 34 37 private static final boolean caseSensitive = MACOSX ? false : new java.io.File ("a").compareTo(new java.io.File ("A")) != 0; 39 43 private int attributes = -1; 44 47 private static IFileSystem instance; 48 49 54 public static IFileSystem getInstance() { 55 return instance; 56 } 57 58 62 static String getOS() { 63 return System.getProperty("osgi.os", ""); } 65 66 69 public LocalFileSystem() { 70 super(); 71 instance = this; 72 } 73 74 78 public int attributes() { 79 if (attributes != -1) 80 return attributes; 81 attributes = 0; 82 if (!LocalFileNatives.usingNatives()) 83 return attributes; 84 85 int nativeAttributes = LocalFileNatives.attributes(); 87 if (nativeAttributes >= 0) { 88 attributes = nativeAttributes; 89 return attributes; 90 } 91 92 attributes |= EFS.ATTRIBUTE_READ_ONLY; 95 96 String os = getOS(); 98 String arch = System.getProperty("osgi.arch", ""); if (os.equals(Constants.OS_WIN32)) 100 attributes |= EFS.ATTRIBUTE_ARCHIVE | EFS.ATTRIBUTE_HIDDEN; 101 else if (os.equals(Constants.OS_LINUX) || (os.equals(Constants.OS_SOLARIS) && arch.equals(Constants.ARCH_SPARC))) 102 attributes |= EFS.ATTRIBUTE_EXECUTABLE | EFS.ATTRIBUTE_SYMLINK | EFS.ATTRIBUTE_LINK_TARGET; 103 else if (os.equals(Constants.OS_MACOSX) || os.equals(Constants.OS_HPUX) || os.equals(Constants.OS_QNX)) 104 attributes |= EFS.ATTRIBUTE_EXECUTABLE; 105 return attributes; 106 } 107 108 112 public boolean canDelete() { 113 return true; 114 } 115 116 120 public boolean canWrite() { 121 return true; 122 } 123 124 128 public IFileStore fromLocalFile(File file) { 129 return new LocalFile(file); 130 } 131 132 136 public IFileStore getStore(IPath path) { 137 return new LocalFile(path.toFile()); 138 } 139 140 144 public IFileStore getStore(URI uri) { 145 return new LocalFile(new File (uri.getSchemeSpecificPart())); 146 } 147 148 152 public boolean isCaseSensitive() { 153 return caseSensitive; 154 } 155 } 156 | Popular Tags |