protected void delete(String name) throws IOException { File file = getFile(name); if (deleteFile(file) != SUCCESS) { if (file.exists()) { throw new FSException(NbBundle.getMessage(LocalFileSystem.class, "EXC_CannotDelete", name, getDisplayName(), file.getAbsolutePath())); } else { /** When file externaly deleted and fo.delete () is called before periodical refresh */ FileObject thisFo = findResource(name); if (thisFo != null) { if (thisFo.getParent() != null) { thisFo.getParent().refresh(); } thisFo.refresh(); if (thisFo.isValid()) { throw new FSException(NbBundle.getMessage(LocalFileSystem.class, "EXC_CannotDelete", name, getDisplayName(), file.getAbsolutePath())); } } } } }
public String[] children(String name) { return fs.children(name); }
/** Set the root directory of the filesystem. * @param r file to set root to * @exception PropertyVetoException if the value if vetoed by someone else (usually * by the {@link org.openide.filesystems.Repository Repository}) * @exception IOException if the root does not exists or some other error occured */ public synchronized void setRootDirectory(File r) throws PropertyVetoException, IOException { if (!r.exists() || r.isFile()) { throw new FSException(NbBundle.getMessage(LocalFileSystem.class, "EXC_RootNotExist", r.getAbsolutePath())); } String oldDisplayName = getDisplayName(); _setSystemName(computeSystemName(r)); rootFile = r; firePropertyChange(PROP_ROOT, null, refreshRoot()); firePropertyChange(PROP_DISPLAY_NAME, oldDisplayName, getDisplayName()); }
protected void createFolder(String name) throws java.io.IOException { File f = getFile(name); if (name.equals("")) { // NOI18N throw new FSException(NbBundle.getMessage(LocalFileSystem.class, "EXC_CannotCreateF", f.getName(), getDisplayName(), f.getAbsolutePath())); } if (f.exists()) { throw new FSException(NbBundle.getMessage(LocalFileSystem.class, "EXC_FolderAlreadyExist", f.getName(), getDisplayName(), f.getAbsolutePath())); } boolean b = createRecursiveFolder(f); if (!b) { throw new FSException(NbBundle.getMessage(LocalFileSystem.class, "EXC_CannotCreateF", f.getName(), getDisplayName(), f.getAbsolutePath())); } }
/** Set the root directory of the filesystem. * @param r file to set root to * @exception PropertyVetoException if the value if vetoed by someone else (usually * by the {@link org.openide.filesystems.Repository Repository}) * @exception IOException if the root does not exists or some other error occured */ public synchronized void setRootDirectory (File r) throws PropertyVetoException, IOException { if (!r.exists() || r.isFile ()) { FSException.io ("EXC_RootNotExist", r.getAbsolutePath ()); // NOI18N } String oldDisplayName = getDisplayName (); setSystemName(computeSystemName (r)); rootFile = r; firePropertyChange(PROP_ROOT, null, refreshRoot ()); firePropertyChange (PROP_DISPLAY_NAME, oldDisplayName, getDisplayName ()); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public synchronized FileSystem getFileSystem() throws IOException { if (fileSystem == null) { try { fileSystem = new LocalFileSystem(); fileSystem.setRootDirectory(new File(rootPath)); final FileObject rootFolder = fileSystem.getRoot(); if (rootFolder == null) { throw new FileNotFoundException(rootPath); } } catch (PropertyVetoException e) { throw new FileNotFoundException(e.toString()); } } return fileSystem; } }
private static FileObject getFileObjectFromFile(File file) { File parent = file.getParentFile(); LocalFileSystem lfs = new LocalFileSystem(); try { lfs.setRootDirectory(parent); } catch(java.beans.PropertyVetoException pve) { // ?? ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, pve); return null; } catch(java.io.IOException ioe) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioe); return null; } return lfs.findResource(file.getName()); }
public void createData(String name) throws IOException { fs.createData(name); }
public void delete(String name) throws IOException { fs.delete(name); }
public void createFolder(String name) throws java.io.IOException { fs.createFolder(name); }
/** Creates new folder and all necessary subfolders * @param f folder to create * @return <code>true</code> if the file exists when returning from this method */ private static boolean createRecursiveFolder(File f) { if (f.exists()) { return true; } if (!f.isAbsolute()) { f = f.getAbsoluteFile(); } String par = f.getParent(); if (par == null) { return false; } if (!createRecursiveFolder(new File(par))) { return false; } f.mkdir(); return f.exists(); }
/** Method that recursivelly deletes all files in a folder. * @return true if successful */ private static int deleteFile(File file) { boolean ret = file.delete(); if (ret) { return SUCCESS; } if (!file.exists()) { return NOT_EXISTS; } if (file.isDirectory()) { // first of all delete whole content File[] arr = file.listFiles(); for (int i = 0; i < arr.length; i++) { if (deleteFile(arr[i]) != SUCCESS) { return FAILURE; } } } // delete the file itself return (file.delete() ? SUCCESS : FAILURE); }
/******************************************************************************************************************* * * Swaps the repositories. * * @throws IOException in case of error * @throws PropertyVetoException in case of error * ******************************************************************************************************************/ private void swapRepositories() throws IOException, PropertyVetoException { exposedRepository = repositories[repositorySelector]; repositorySelector = (repositorySelector + 1) % 2; alternateRepository = repositories[repositorySelector]; fileSystemDelegate.setRootDirectory(exposedRepository.getWorkArea().toFile()); swapCounter++; log.info("New exposed repository: {}", exposedRepository.getWorkArea()); log.info("New alternate repository: {}", alternateRepository.getWorkArea()); }
/** Set the root directory of the filesystem. * @param r file to set root to * @exception PropertyVetoException if the value if vetoed by someone else (usually * by the {@link org.openide.filesystems.Repository Repository}) * @exception IOException if the root does not exists or some other error occured */ public synchronized void setRootDirectory (File r) throws PropertyVetoException, IOException { if (!r.exists() || r.isFile ()) { FSException.io ("EXC_RootNotExist", r.getAbsolutePath ()); // NOI18N } String oldDisplayName = getDisplayName (); setSystemName(computeSystemName (r)); rootFile = r; firePropertyChange(PROP_ROOT, null, refreshRoot ()); firePropertyChange (PROP_DISPLAY_NAME, oldDisplayName, getDisplayName ()); }
protected void createFolder (String name) throws java.io.IOException { File f = getFile (name); if (name.equals ("")) { // NOI18N FSException.io ("EXC_CannotCreateF", new Object[] { f.getName (), getDisplayName (), f.getAbsolutePath ()}); // NOI18N } if (f.exists()) { FSException.io ("EXC_FolderAlreadyExist", new Object[] { f.getName (), getDisplayName (), f.getAbsolutePath ()}); // NOI18N } boolean b = createRecursiveFolder(f); if (!b) { FSException.io ("EXC_CannotCreateF", new Object[] { f.getName (), getDisplayName (), f.getAbsolutePath ()}); // NOI18N } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public synchronized ResourceFileSystem getFileSystem() throws IOException { if (fileSystem == null) { try { fileSystemDelegate = new LocalFileSystem(); fileSystemDelegate.setRootDirectory(new File(rootPath)); final FileObject rootFolder = fileSystemDelegate.getRoot(); if (rootFolder == null) { throw new FileNotFoundException(rootPath); } fileSystem = new ResourceFileSystemNetBeansPlatform(fileSystemDelegate); } catch (PropertyVetoException e) { throw new FileNotFoundException(e.toString()); } } return fileSystem; } }
public void createData (String name) throws IOException { fs.createData (name); }
public void delete (String name) throws IOException { fs.delete (name); }
public void createFolder (String name) throws java.io.IOException { fs.createFolder (name); }
/** Creates new folder and all necessary subfolders * @param f folder to create * @return <code>true</code> if the file exists when returning from this method */ private static boolean createRecursiveFolder(File f) { if (f.exists()) return true; if (!f.isAbsolute()) f = f.getAbsoluteFile(); String par = f.getParent(); if (par == null) return false; if (!createRecursiveFolder(new File(par))) return false; f.mkdir(); return f.exists(); }