From 2248cbff4f9506ea8e0876231f45bfce275a093f Mon Sep 17 00:00:00 2001
From: ulrich@undisclosed
Date: Sun, 01 Mar 2020 15:53:17 +0000
Subject: [PATCH] SuchApi hinzugefuegt

---
 src/java/de/uhilger/filecms/api/FileMgr.java |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java
index 40bd4bb..f2bf1cc 100644
--- a/src/java/de/uhilger/filecms/api/FileMgr.java
+++ b/src/java/de/uhilger/filecms/api/FileMgr.java
@@ -354,7 +354,12 @@
               }
             } 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);              
               }
@@ -368,6 +373,20 @@
     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);

--
Gitblit v1.9.3