[erlang-questions] Best way to check if a given directory is empty (or not)?

Adrian Roe roe.adrian@REDACTED
Tue Mar 13 18:33:38 CET 2012


You need to be careful with things like /atime/ - systems using solid 
state disks tend to routinely set the /noatime /flag to minimise the 
number of write-cycles the disk undergoes, which on SSDs limit the 
lifetime of the disk.

I strongly suspect that the link count from file:read_file_info() (as in 
Taavi's post) is the way forward.

Adrian

On 13/03/12 15:57, Wes James wrote:
> There is also filelib:file_size
>
> Another thing to look at.  Can you keep track of when the folder is
> first created:
>
>   #file_info.atime (keep somwhere like ets table)
>
> then later read #file_info.atime and compare?
>
> The problem here is that when a file file is written or the folder is
> just plane read (I did ls of folder and the atime changed) the atime
> changes.
>
> Will the folder ever be accessed other than to have a file be written
> to it, if so, this may work.
>
> -wes
>
> On Tue, Mar 13, 2012 at 9:34 AM, Zabrane Mickael<zabrane3@REDACTED>  wrote:
>> On Mar 13, 2012, at 4:33 PM, Wes James wrote:
>>
>>> Per Bengt's experience.  What happens if you add a file?  Does the size change?
>> Nothing change when I added a file.
>>
>> Regards,
>> Zabrane
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120313/b4e9603e/attachment.htm>


More information about the erlang-questions mailing list