du
This commit is contained in:
parent
78ffcd1cfc
commit
7918563eae
@ -10,7 +10,6 @@ unsigned int h_flag;
|
||||
unsigned int s_flag;
|
||||
unsigned int b_flag;
|
||||
unsigned int m_flag;
|
||||
unsigned int L_flag;
|
||||
|
||||
void print(long size, const char *filename) {
|
||||
/* Kb */
|
||||
@ -25,7 +24,7 @@ void print(long size, const char *filename) {
|
||||
}
|
||||
|
||||
long du(const char *path, int recurs_flag) {
|
||||
long sum;
|
||||
long sum = 0;
|
||||
|
||||
struct stat sb;
|
||||
if (lstat(path, &sb) != 0) {
|
||||
@ -59,12 +58,13 @@ long du(const char *path, int recurs_flag) {
|
||||
|
||||
closedir(dp);
|
||||
|
||||
if (s_flag)
|
||||
if (!recurs_flag) {
|
||||
if (!s_flag && recurs_flag) {
|
||||
print(sum, path);
|
||||
return sum;
|
||||
}
|
||||
|
||||
else
|
||||
/* Silent mode */
|
||||
else if (!recurs_flag)
|
||||
print(sum, path);
|
||||
}
|
||||
|
||||
@ -98,11 +98,8 @@ int main(const int argc, const char **argv) {
|
||||
m_flag = 1;
|
||||
}
|
||||
|
||||
else if (!strcmp(argv[i], "-L"))
|
||||
L_flag = 1;
|
||||
|
||||
else if (!strcmp(argv[i], "--help")) {
|
||||
printf("du [-h (Sizes in human readable format (e.g., 1K 243M 2G))] [-s (Display only a total for each argument)] [-b (Apparent size)] [-L (Follow all symlinks)] [-m (Size in megabyte)] [file file2...]\n");
|
||||
printf("du [-h (Sizes in human readable format (e.g., 1K 243M 2G))] [-s (Display only a total for each argument)] [-b (Apparent size)] [-m (Size in megabyte)] [file file2...]\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user