[PATCH 3/7] server: Fail to set delete disposition on a non-empty directory.

Chip Davis cdavis at codeweavers.com
Wed Nov 7 12:33:18 CST 2018


November 7, 2018 12:30 PM, "Dmitry Timoshkov" <dmitry at baikal.ru> wrote:

> Alexandre Julliard <julliard at winehq.org> wrote:
> 
>> +static int is_directory_empty( struct fd *fd )
>> +{
>> + DIR *dir;
>> + int count = 0;
>> +
>> + if ((dir = fdopendir( fd->unix_fd )))
>> + {
>> + while (readdir( dir ) != NULL && count <= 2)
>> + count++;
>> +
>> + closedir( dir );
>> + }
>> 
>> This won't work, closedir() is going to close the file descriptor.
> 
> What would you suggest to use instead? I'd be glad to consider any other ways
> to detect a non-empty directory.

fstat(2) the directory file and check that st_nlink is greater than 2.

Chip



More information about the wine-devel mailing list