Ticket #9824: is_empty.symlink.diff

File is_empty.symlink.diff, 1.1 KB (added by michael.burr@…, 9 years ago)

Possible fix for is_empty() symlink support

  • src/operations.cpp

    diff --git a/src/operations.cpp b/src/operations.cpp
    index 8809f5c..40a68e8 100644
    a b using std::wstring;  
    116116#   else
    117117#     include <sys/utime.h>
    118118#   endif
     119#   include <sys/stat.h>
    119120
    120121//  REPARSE_DATA_BUFFER related definitions are found in ntifs.h, which is part of the
    121122//  Windows Device Driver Kit. Since that's inconvenient, the definitions are provided
    namespace detail  
    12841285      : path_stat.st_size == 0;
    12851286#   else
    12861287
    1287     WIN32_FILE_ATTRIBUTE_DATA fad;
    1288     if (error(::GetFileAttributesExW(p.c_str(), ::GetFileExInfoStandard, &fad)== 0,
    1289       p, ec, "boost::filesystem::is_empty"))
    1290         return false;
    1291 
    1292     if (ec != 0) ec->clear();
    1293     return
    1294       (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
    1295         ? is_empty_directory(p)
    1296         : (!fad.nFileSizeHigh && !fad.nFileSizeLow);
     1288    struct _stat path_stat;
     1289    if (error(::_wstat(p.c_str(), &path_stat) != 0,
     1290        p, ec, "boost::filesystem::is_empty"))
     1291      return false;
     1292    return ((path_stat.st_mode & _S_IFDIR) != 0)
     1293      ? is_empty_directory(p)
     1294      : path_stat.st_size == 0;
    12971295#   endif
    12981296  }
    12991297