jochenw commented on issue #31: DirectoryUtils - isEqual to compare directories
URL: https://github.com/apache/commons-io/pull/31#issuecomment-539364025
 
 
   Besides, rather than simply returning a boolean value, I'd hope for an event 
API, like
   
           public interface DirCompareListener {
               /**
                * Called, if a file has been detected in the first directory, 
which is missing in the second.
                * In other words, the difference can be remedied by copying the 
file from the first
                * directory to the second.
                * @param pFirstDir First directory being compared (root 
directory); the directory, where
                *                               a file has been found, which is 
not present in the second directory.
                * @param pSecondDir Second directory being compared (root 
directory); the directory, 
                *                               where a file is missing.
                * @param pFile Path pf the additional file, relative to the 
root directory.
                */
                public void fileAdded(Path pFirstDir, Path pSecondDir, String 
pFileName);
           }
           /** Method, which compares two directories by iterating over the 
files in the first directory,
             * checking, whether they are present (and identical) in the second 
directory, and vice versa.
             * Upon detection of differences, a suitable method of the listener 
is being invoked.
             */
           public void compareDirectories(Path pFirstDir, Path pSecondDir, 
DirCompareListener pListener);
           /** Method, which compares two directories by iterating over the 
files in the first directory,
             * checking, whether they are present (and identical) in the second 
directory, and vice versa.
             * Upon detection of differences, the value false is being 
returned, otherwise returns true.
             */
           public boolean compareDirectories(Path pFirstDir, Path pSecondDir) {
               final DirCompareListener listener = new DirCompareListener(){
                    public void fileAdded(Path pFirstDir, Path pSecondDir, 
pFileName) {
                        throw new IllegalPathStateException();
                    }
               };
               try {
                     compare(pFirstDir, pSecondDir, listener);
                     return true;
               } catch (IllegalPathStateException e) {
                     return false;
               }
          }
          

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to