From e8f9a47f07ac8b581507e8d848260df04eb08e29 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Thu, 14 Nov 2024 10:00:51 +0000
Subject: [PATCH] Dokumentation in Arbeit: Renamer fertig dokumentiert, kleinere Anpassungen

---
 src/de/uhilger/fm/Eraser.java |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/de/uhilger/fm/Eraser.java b/src/de/uhilger/fm/Eraser.java
index 0ecea3d..3df2242 100644
--- a/src/de/uhilger/fm/Eraser.java
+++ b/src/de/uhilger/fm/Eraser.java
@@ -1,5 +1,5 @@
 /*
-  neon-fm - File management extensions to Neon
+  fm - File management class library
   Copyright (C) 2024  Ulrich Hilger
 
   This program is free software: you can redistribute it and/or modify
@@ -30,19 +30,24 @@
  * @author Ulrich Hilger, 15. Januar 2024
  */
 public class Eraser {
+  
+  public static final int OP_DELETE = 3;  
+  
+  private final String STR_DOT = ".";
+  
   public String deleteFiles(String relPath, List<String> fileNames, String base) {
     String result = null;
     try {
       //logger.fine(fileNames.toString());
-      if (!relPath.startsWith(Const.STR_DOT)) {
+      if (!relPath.startsWith(STR_DOT)) {
         File targetDir = new File(base, relPath); // getTargetDir(relPath);
         //logger.fine("targetDir: " + targetDir);
         for (String fileName : fileNames) {
           File targetFile = new File(targetDir, fileName);
           //logger.fine(targetFile.getAbsolutePath());
           if (targetFile.isDirectory()) {
-            OrdnerBearbeiter bearbeiter = new OrdnerBearbeiter();
-            bearbeiter.setOperation(Const.OP_DELETE);
+            FileOpsVisitor bearbeiter = new FileOpsVisitor();
+            bearbeiter.setOperation(OP_DELETE);
             Files.walkFileTree(targetFile.toPath(), bearbeiter);
           } else {
             /*
@@ -51,9 +56,9 @@
                 die so heissen, also z.B. alle [Dateiname]*.jpg
              */
             String fname = targetFile.getName().toLowerCase();
-            if (fname.endsWith(Const.JPEG)
-                    || fname.endsWith(Const.JPG)
-                    || fname.endsWith(Const.PNG)) {
+            if (fname.endsWith(ImageFileFilter.JPEG)
+                    || fname.endsWith(ImageFileFilter.JPG)
+                    || fname.endsWith(ImageFileFilter.PNG)) {
               deleteImgFiles(targetDir, targetFile);
             } else {
               targetFile.delete();
@@ -70,7 +75,7 @@
 
   private void deleteImgFiles(File targetDir, File targetFile) throws IOException {
     String fnameext = targetFile.getName();
-    int dotpos = fnameext.lastIndexOf(Const.STR_DOT);
+    int dotpos = fnameext.lastIndexOf(STR_DOT);
     String fname = fnameext.substring(0, dotpos);
     String ext = fnameext.substring(dotpos);
     //logger.fine("fname: " + fname + ", ext: " + ext);

--
Gitblit v1.9.3