diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2014-09-04 20:36:45 +0200 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2014-09-04 20:36:45 +0200 |
commit | 82ce28122dfaabd2d8d910a7f75edf648d08bd6b (patch) | |
tree | b330105e2ac50467f63dbb7270fc8410f0072f9b /twrpDU.cpp | |
parent | MTP: Better handling of stat (diff) | |
download | android_bootable_recovery-82ce28122dfaabd2d8d910a7f75edf648d08bd6b.tar android_bootable_recovery-82ce28122dfaabd2d8d910a7f75edf648d08bd6b.tar.gz android_bootable_recovery-82ce28122dfaabd2d8d910a7f75edf648d08bd6b.tar.bz2 android_bootable_recovery-82ce28122dfaabd2d8d910a7f75edf648d08bd6b.tar.lz android_bootable_recovery-82ce28122dfaabd2d8d910a7f75edf648d08bd6b.tar.xz android_bootable_recovery-82ce28122dfaabd2d8d910a7f75edf648d08bd6b.tar.zst android_bootable_recovery-82ce28122dfaabd2d8d910a7f75edf648d08bd6b.zip |
Diffstat (limited to 'twrpDU.cpp')
-rw-r--r-- | twrpDU.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/twrpDU.cpp b/twrpDU.cpp index 28c3dfa15..0a4e44a34 100644 --- a/twrpDU.cpp +++ b/twrpDU.cpp @@ -70,6 +70,7 @@ uint64_t twrpDU::Get_Folder_Size(const string& Path) { struct dirent* de; struct stat st; uint64_t dusize = 0; + string FullPath; d = opendir(Path.c_str()); if (d == NULL) { @@ -79,10 +80,15 @@ uint64_t twrpDU::Get_Folder_Size(const string& Path) { } while ((de = readdir(d)) != NULL) { - if (de->d_type == DT_DIR && !check_skip_dirs(Path + "/" + de->d_name)) { - dusize += Get_Folder_Size(Path + "/" + de->d_name); - } else if (de->d_type == DT_REG) { - stat((Path + "/" + de->d_name).c_str(), &st); + FullPath = Path + "/"; + FullPath += de->d_name; + if (lstat(FullPath.c_str(), &st)) { + LOGERR("Unable to stat '%s'\n", FullPath.c_str()); + continue; + } + if ((st.st_mode & S_IFDIR) && !check_skip_dirs(FullPath) && de->d_type != DT_SOCK) { + dusize += Get_Folder_Size(FullPath); + } else if (st.st_mode & S_IFREG) { dusize += (uint64_t)(st.st_size); } } |