You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "J. Fiala" <mo...@fwd.at> on 2017/02/12 16:21:24 UTC

Compare directories

Hi there,

Currently it seems there is no utility method to compare two directory 
structures:

http://stackoverflow.com/questions/14522239/test-two-directory-trees-for-equality/42189853#42189853

I did a first rough implementation for Java 7 NIO and posted it at SO, 
please advise if it makes sense to include this into FileUtils and if it 
then needs to be backported to Java 6?

Best regards,
Johannes


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Compare directories

Posted by "J. Fiala" <mo...@fwd.at>.
Hi there,

I added a PR with the first implementation of DirectoryUtils.isEqual().

https://github.com/apache/commons-io/pull/31/

I initially added some logging statements and commented them out for now 
as I couldn't find any logger in the existing classes.

Please review and let me know if you need changes.

Best regards,
Johannes


Am 13.02.2017 um 18:54 schrieb Gary Gregory:
> You can provide a diff file and attach it to a JIRA as a feature request.
> Or, you can create a PR on GitHub. Unless you see mocks in the test
> sources, we do not have them ;-) I do not recall seeing such mocks. Feel
> free to come up with a design that is best for the community to understand
> and maintain.
>
> Gary
>
> On Mon, Feb 13, 2017 at 12:05 AM, J. Fiala <mo...@fwd.at> wrote:
>
>> Hello Gary,
>>
>> Thanks, yes DirectoryUtils is probably more descriptive :).
>>
>> I can provide the simple solution, of course this can be tuned & optimized
>> as for the current solution the intersected files will be compared twice.
>> But the current solution offers a low memory footprint as it doesn't have
>> to store any state and is easy to understand.
>>
>> How should the test design look like for this? Do you want to use "real"
>> directories/files or do you already have mocks for the File API?
>>
>> Can I supply this on github as a PR or do I need access to the SVN?
>>
>> Best regards,
>>
>> Johannes
>>
>>
>> Am 12.02.2017 um 18:48 schrieb Gary Gregory:
>>
>>> I would put that in its own class. FU is a bad name to start with, esp in
>>> this case where you are comparing directories.
>>>
>>> Gary
>>>
>>> On Feb 12, 2017 8:21 AM, "J. Fiala" <mo...@fwd.at> wrote:
>>>
>>> Hi there,
>>>
>>> Currently it seems there is no utility method to compare two directory
>>> structures:
>>>
>>> http://stackoverflow.com/questions/14522239/test-two-directo
>>> ry-trees-for-equality/42189853#42189853
>>>
>>> I did a first rough implementation for Java 7 NIO and posted it at SO,
>>> please advise if it makes sense to include this into FileUtils and if it
>>> then needs to be backported to Java 6?
>>>
>>> Best regards,
>>> Johannes
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Compare directories

Posted by Gary Gregory <ga...@gmail.com>.
You can provide a diff file and attach it to a JIRA as a feature request.
Or, you can create a PR on GitHub. Unless you see mocks in the test
sources, we do not have them ;-) I do not recall seeing such mocks. Feel
free to come up with a design that is best for the community to understand
and maintain.

Gary

On Mon, Feb 13, 2017 at 12:05 AM, J. Fiala <mo...@fwd.at> wrote:

> Hello Gary,
>
> Thanks, yes DirectoryUtils is probably more descriptive :).
>
> I can provide the simple solution, of course this can be tuned & optimized
> as for the current solution the intersected files will be compared twice.
> But the current solution offers a low memory footprint as it doesn't have
> to store any state and is easy to understand.
>
> How should the test design look like for this? Do you want to use "real"
> directories/files or do you already have mocks for the File API?
>
> Can I supply this on github as a PR or do I need access to the SVN?
>
> Best regards,
>
> Johannes
>
>
> Am 12.02.2017 um 18:48 schrieb Gary Gregory:
>
>> I would put that in its own class. FU is a bad name to start with, esp in
>> this case where you are comparing directories.
>>
>> Gary
>>
>> On Feb 12, 2017 8:21 AM, "J. Fiala" <mo...@fwd.at> wrote:
>>
>> Hi there,
>>
>> Currently it seems there is no utility method to compare two directory
>> structures:
>>
>> http://stackoverflow.com/questions/14522239/test-two-directo
>> ry-trees-for-equality/42189853#42189853
>>
>> I did a first rough implementation for Java 7 NIO and posted it at SO,
>> please advise if it makes sense to include this into FileUtils and if it
>> then needs to be backported to Java 6?
>>
>> Best regards,
>> Johannes
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Compare directories

Posted by "J. Fiala" <mo...@fwd.at>.
Hello Gary,

Thanks, yes DirectoryUtils is probably more descriptive :).

I can provide the simple solution, of course this can be tuned & 
optimized as for the current solution the intersected files will be 
compared twice. But the current solution offers a low memory footprint 
as it doesn't have to store any state and is easy to understand.

How should the test design look like for this? Do you want to use "real" 
directories/files or do you already have mocks for the File API?

Can I supply this on github as a PR or do I need access to the SVN?

Best regards,

Johannes


Am 12.02.2017 um 18:48 schrieb Gary Gregory:
> I would put that in its own class. FU is a bad name to start with, esp in
> this case where you are comparing directories.
>
> Gary
>
> On Feb 12, 2017 8:21 AM, "J. Fiala" <mo...@fwd.at> wrote:
>
> Hi there,
>
> Currently it seems there is no utility method to compare two directory
> structures:
>
> http://stackoverflow.com/questions/14522239/test-two-directo
> ry-trees-for-equality/42189853#42189853
>
> I did a first rough implementation for Java 7 NIO and posted it at SO,
> please advise if it makes sense to include this into FileUtils and if it
> then needs to be backported to Java 6?
>
> Best regards,
> Johannes
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: Compare directories

Posted by Gary Gregory <ga...@gmail.com>.
I would put that in its own class. FU is a bad name to start with, esp in
this case where you are comparing directories.

Gary

On Feb 12, 2017 8:21 AM, "J. Fiala" <mo...@fwd.at> wrote:

Hi there,

Currently it seems there is no utility method to compare two directory
structures:

http://stackoverflow.com/questions/14522239/test-two-directo
ry-trees-for-equality/42189853#42189853

I did a first rough implementation for Java 7 NIO and posted it at SO,
please advise if it makes sense to include this into FileUtils and if it
then needs to be backported to Java 6?

Best regards,
Johannes


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org