summaryrefslogtreecommitdiffstats
path: root/lib/utils/dirsize.cpp
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-08-24 13:07:44 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-08-24 13:07:44 +0200
commit5cc439c2c24859accf8a94d8a91879ad6d967ea4 (patch)
tree1915379ff53eeb579ed92d889b7e6d873df1144a /lib/utils/dirsize.cpp
parentbe100446ebd3b1c8f6bb3ed450867c9dcbc625e8 (diff)
downloadabrt-5cc439c2c24859accf8a94d8a91879ad6d967ea4.tar.gz
abrt-5cc439c2c24859accf8a94d8a91879ad6d967ea4.tar.xz
abrt-5cc439c2c24859accf8a94d8a91879ad6d967ea4.zip
concat_path_file: make it a C function, not C++
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'lib/utils/dirsize.cpp')
-rw-r--r--lib/utils/dirsize.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/utils/dirsize.cpp b/lib/utils/dirsize.cpp
index 739b6b73..79f429e3 100644
--- a/lib/utils/dirsize.cpp
+++ b/lib/utils/dirsize.cpp
@@ -33,17 +33,21 @@ double get_dirsize(const char *pPath)
{
if (dot_or_dotdot(ep->d_name))
continue;
- string dname = concat_path_file(pPath, ep->d_name);
- if (lstat(dname.c_str(), &statbuf) != 0)
+ char *dname = concat_path_file(pPath, ep->d_name);
+ if (lstat(dname, &statbuf) != 0)
+ {
+ free(dname);
continue;
+ }
if (S_ISDIR(statbuf.st_mode))
{
- size += get_dirsize(dname.c_str());
+ size += get_dirsize(dname);
}
else if (S_ISREG(statbuf.st_mode))
{
size += statbuf.st_size;
}
+ free(dname);
}
closedir(dp);
return size;
@@ -66,12 +70,15 @@ double get_dirsize_find_largest_dir(
{
if (dot_or_dotdot(ep->d_name))
continue;
- string dname = concat_path_file(pPath, ep->d_name);
- if (lstat(dname.c_str(), &statbuf) != 0)
+ char *dname = concat_path_file(pPath, ep->d_name);
+ if (lstat(dname, &statbuf) != 0)
+ {
+ free(dname);
continue;
+ }
if (S_ISDIR(statbuf.st_mode))
{
- double sz = get_dirsize(dname.c_str());
+ double sz = get_dirsize(dname);
size += sz;
if (worst_dir && (!excluded || strcmp(excluded, ep->d_name) != 0))
@@ -94,6 +101,7 @@ double get_dirsize_find_largest_dir(
{
size += statbuf.st_size;
}
+ free(dname);
}
closedir(dp);
return size;