Create a TWRP Disk Usage Class to retain state about a directory and whether we should skip it in other classes like twrpTar.
Moved Get_Folder_Size to this new class. Change-Id: If0a0220f900eb109581f2eeaf7b76e3f7d6886f1
This commit is contained in:
committed by
Dees Troy
parent
4d132cabf4
commit
34684ff313
@@ -206,39 +206,6 @@ int TWFunc::Recursive_Mkdir(string Path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned long long TWFunc::Get_Folder_Size(const string& Path, bool Display_Error) {
|
||||
DIR* d;
|
||||
struct dirent* de;
|
||||
struct stat st;
|
||||
unsigned long long dusize = 0;
|
||||
unsigned long long dutemp = 0;
|
||||
|
||||
d = opendir(Path.c_str());
|
||||
if (d == NULL)
|
||||
{
|
||||
LOGERR("error opening '%s'\n", Path.c_str());
|
||||
LOGERR("error: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((de = readdir(d)) != NULL)
|
||||
{
|
||||
if (de->d_type == DT_DIR && strcmp(de->d_name, ".") != 0 && strcmp(de->d_name, "..") != 0 && strcmp(de->d_name, "lost+found") != 0)
|
||||
{
|
||||
dutemp = Get_Folder_Size((Path + "/" + de->d_name), Display_Error);
|
||||
dusize += dutemp;
|
||||
dutemp = 0;
|
||||
}
|
||||
else if (de->d_type == DT_REG)
|
||||
{
|
||||
stat((Path + "/" + de->d_name).c_str(), &st);
|
||||
dusize += (unsigned long long)(st.st_size);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
return dusize;
|
||||
}
|
||||
|
||||
bool TWFunc::Path_Exists(string Path) {
|
||||
// Check to see if the Path exists
|
||||
struct stat st;
|
||||
|
||||
Reference in New Issue
Block a user