private boolean isValidEntry(String n) { return isValidEntry(n, null); }
public void createData(String name) throws IOException { if (isValidEntry(name, Boolean.FALSE)) { StringBuffer message = new StringBuffer(); message.append("File already exists: ").append(name); throw new IOException(message.toString());//NOI18N } getOrCreateEntry(name).data = new byte[0]; }
public void createFolder(String name) throws java.io.IOException { if (isValidEntry(name, Boolean.FALSE)) { StringBuffer message = new StringBuffer(); message.append("Folder already exists: ").append(name); throw new IOException(message.toString());//NOI18N } getOrCreateEntry(name).data = null; }
@Override public void rename(String oldName, String newName) throws IOException { if (!isValidEntry(oldName)) { throw new IOException("The file to rename does not exist."); } if (isValidEntry(newName)) { throw new IOException("Cannot rename to existing file"); } if ((newName.length() > 0) && (newName.charAt(0) == '/')) { newName = newName.substring(1); } ArrayList<Map.Entry<String, Entry>> clone = new ArrayList<Map.Entry<String, Entry>>(entries.entrySet()); for (Map.Entry<String, Entry> each : clone) { if (each.getKey().startsWith(oldName)) { entries.remove(each.getKey()); String n = newName + each.getKey().substring(oldName.length()); entries.put(n, each.getValue()); } } }
public Object readAttribute(String name, String attrName) { return isValidEntry(name) ? getOrCreateEntry(name).attrs.get(attrName) : null; }
/** finds entry for given name */ private Entry getOrCreateEntry(String n) { if ((n.length() > 0) && (n.charAt(0) == '/')) { n = n.substring(1); } boolean isValidEntry = isValidEntry(n); synchronized(entries) { Entry x = entries.get(n); if (x == null || !isValidEntry) { x = new Entry(n); entries.put(n, x); } return x; } }
public Enumeration<String> attributes(String name) { if (!isValidEntry(name)) { return org.openide.util.Enumerations.empty(); } return Collections.enumeration(getOrCreateEntry(name).attrs.keySet()); }