/** 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); }
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())); } } } } }
/** 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); }
/** 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); }
protected void delete(String name) throws IOException { File file = getFile(name); if (deleteFile(file) != SUCCESS) { if (file.exists()) FSException.io("EXC_CannotDelete", name, getDisplayName(), file.getAbsolutePath()); // NOI18N 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()) FSException.io("EXC_CannotDelete", name, getDisplayName(), file.getAbsolutePath()); // NOI18N } } } }
protected void delete(String name) throws IOException { File file = getFile(name); if (deleteFile(file) != SUCCESS) { if (file.exists()) FSException.io("EXC_CannotDelete", name, getDisplayName(), file.getAbsolutePath()); // NOI18N 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()) FSException.io("EXC_CannotDelete", name, getDisplayName(), file.getAbsolutePath()); // NOI18N } } } }