public void delete(FileLock lock) throws IOException { fileObj.delete(lock); }
/** Delete this file. If the file is a folder and it is not empty then * all of its contents are also recursively deleted. FileObject is locked * before delete and finally is this lock released. * * @exception IOException if the file could not be deleted or * FileAlreadyLockedException if the file is already locked {@link #lock} * @since 1.15 */ public final void delete() throws IOException { FileLock lock = lock(); try { delete(lock); } finally { lock.releaseLock(); } }
/** * Return the revived file from the MFS * @return the revived file, if the operation succeeds. * @throws IOException from the deletion of the masking file. */ @Override public FileObject call() throws IOException { if (maskFile.isValid()) { maskFile.delete(); } return MultiFileObject.this.getFileObject(maskFile.getNameExt()); }
/** Deletes a file object that will mask the given file. * @param fs filesystem to work on * @param res resource name of the file * @exception IOException if it fails */ void unmaskFile(FileSystem fs, String res) throws IOException { FileObject fo = findResourceOn(fs, res + MASK); if (fo != null) { FileLock lock = fo.lock(); try { fo.delete(lock); } finally { lock.releaseLock(); } } }
/** Moves this file. This allows the filesystem to perform any additional * operation associated with the move. But the default implementation is encapsulated * as copy and delete. * * @param lock File must be locked before renaming. * @param target target folder to move this file to * @param name new basename of file * @param ext new extension of file (ignored for folders) * @return the newly created file object representing the moved file */ public FileObject move(FileLock lock, FileObject target, String name, String ext) throws IOException { if (getParent().equals(target)) { // it is possible to do only rename rename(lock, name, ext); return this; } else { // have to do copy FileObject dest = copy(target, name, ext); delete(lock); FileObjectLkp.reassign(this, dest); return dest; } }
/** * auxiliary method that returns true if mask is needed and deletes all delegates * on writable layers if deleteDelegates is true. * @param lock * @param deleteDelegates if true all delegates on writable layers will be deleted * @throws IOException is thrown if lock is not valid. * @return true if mask is necessary*/ private boolean needsMask(FileLock lock, boolean deleteDelegates) throws IOException { MfLock lck = testLock(lock); Enumeration<FileObject> e = getMultiFileSystem().delegates(getPath()); boolean needsMask = false; while (e.hasMoreElements()) { FileObject fo = e.nextElement(); FileLock lockForFo = lck.findLock(fo); if (lockForFo == null) { // we will need to create mask needsMask = true; } else { if (deleteDelegates) { fo.delete(lockForFo); } } } return needsMask; }
try { userDefinedResolverFO.delete(); } catch (IOException e) { ERR.log(Level.SEVERE, "Cannot delete resolver " + FileUtil.toFile(userDefinedResolverFO), e); //NOI18N
final public void delete(FileLock lock) throws IOException { if (isFolder()) { FileObject[] fos = this.getChildren(); for (int i = 0; i < fos.length; i++) { FileObject fo = fos[i]; FileLock foLock = fo.lock(); try { fo.delete(foLock); } catch (IOException iex) { String message = NbBundle.getMessage(AbstractFolder.class, "EXC_CannotDelete", // XXX use FileUtil.getFileDisplayName instead? getPath(), fo.getFileSystem().getDisplayName() ); ExternalUtil.annotate(iex, message); //NOI18N throw iex; } finally { foLock.releaseLock(); } } } handleDelete(lock); }
remoteFile.delete(); System.out.println("File delete successful");
@Override public boolean delete() { try { f.delete(); return true; } catch (IOException ex) { return false; } }
public void run() { try { fo1.delete(); } catch (IOException ex) { throw Debug.error(ex); } } });
/** * Cleanup the given folder. The folder itself is not removed. * @param fileObject folder to be cleaned up * @throws IOException if any error occurs */ public static void cleanupFolder(FileObject fileObject) throws IOException { for (FileObject child : fileObject.getChildren()) { child.delete(); } }
@Override public void restore() throws IOException { FileObject file = URLMapper.findFileObject(url); if (file != null) { file.delete(); } } };
private void safelyDelete(FileObject file) { try { file.delete(); } catch (Throwable t) { LOG.log(Level.FINER, "unable to delete cache file {0}, exception {1}", new Object[]{file.getPath(), t.getMessage()}); } }
@Override public void remove(FieldTask entity) { removeFromCache(entity); try { getTargetFile(entity).delete(); } catch (IOException e) { LOGGER.log(Level.WARNING, "Could not remove FieldTask {0}. {1}", new Object[]{entity, e.getMessage() }); } } }
static void removeTemplate(Project proj) throws IOException { FileObject projDir = proj.getProjectDirectory(); FileObject jnlpBuildFile = projDir.getFileObject("nbproject/extendArchiveGF.xml"); // NOI18N if (jnlpBuildFile != null) { jnlpBuildFile.delete(); } }
private synchronized void clearInstanceStorage(final String url) { FileObject instanceFO = getInstanceFileObject(url); if (instanceFO != null) { try { instanceFO.delete(); } catch (IOException ioe) { LOGGER.log(Level.INFO, null, ioe); } } Keyring.delete(getPasswordKey(url)); }
public synchronized static boolean removeAction(FileObject actionFile) { if (TransientAction.hasAction(actionFile.getPath())) { try { actionFile.delete(); TransientAction.removeAction(actionFile.getPath()); return true; } catch (IOException ex) { Exceptions.printStackTrace(ex); } } return false; }
public void run() throws IOException { FileObject rakeD = project.getProjectDirectory().getFileObject(RAKE_D_OUTPUT); // clean old content if (rakeD != null && rakeD.isValid() && rakeD.isData()) { rakeD.delete(); } } });
private FileObject copy(FileObject source) throws IOException { FileObject fo = p.getProjectDirectory(); //target/nb-private/tesng-suite.xml FileObject folder = FileUtil.createFolder(fo, "target/nb-private"); //NOI18N FileObject cfg = folder.getFileObject("testng-suite", "xml"); //NOI18N if (cfg != null) { cfg.delete(); } return FileUtil.copyFile(source, folder, "testng-suite"); //NOI18N }