| | |
| | | } |
| | | } else { |
| | | if(operation == OP_MOVE) { |
| | | FileUtils.moveFileToDirectory(srcFile, targetDir, false); |
| | | String fname = srcFile.getName().toLowerCase(); |
| | | if(fname.endsWith(TNServlet.JPEG) || fname.endsWith(TNServlet.JPG) || fname.endsWith(TNServlet.PNG)) { |
| | | moveImgFilesToDirectory(srcFile, srcDir, targetDir, false); |
| | | } else { |
| | | FileUtils.moveFileToDirectory(srcFile, targetDir, false); |
| | | } |
| | | } else { |
| | | FileUtils.copyFileToDirectory(srcFile, targetDir); |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | private void moveImgFilesToDirectory(File srcFile, File srcDir, File targetDir, boolean createDestDir) throws IOException { |
| | | String fnameext = srcFile.getName(); |
| | | int dotpos = fnameext.lastIndexOf(DOT); |
| | | String fname = fnameext.substring(0, dotpos); |
| | | String ext = fnameext.substring(dotpos); |
| | | logger.fine("fname: " + fname + ", ext: " + ext); |
| | | FileFilter fileFilter = new WildcardFileFilter(fname + "*" + ext); |
| | | File[] files = srcDir.listFiles(fileFilter); |
| | | for (int i = 0; i < files.length; i++) { |
| | | logger.fine(files[i].getName()); |
| | | FileUtils.moveFileToDirectory(files[i], targetDir, createDestDir); |
| | | } |
| | | } |
| | | |
| | | public FileRef saveTextFileAs(String relPath, String fileName, String contents) { |
| | | FileRef savedFile = null; |
| | | logger.fine(relPath + " " + fileName); |