- int fds[2];
- _assert(pipe(fds) != -1);
-
- pid_t pid(ExecFork());
- if (pid == 0) {
- _assert(dup2(fds[1], 1) != -1);
- _assert(close(fds[0]) != -1);
- _assert(close(fds[1]) != -1);
- /* XXX: this should probably not use du */
- _root(execl("/usr/libexec/cydia/du", "du", "-s", [path UTF8String], NULL));
- exit(1);
- } else {
- _assert(close(fds[1]) != -1);
-
- if (FILE *du = fdopen(fds[0], "r")) {
- char line[1024];
- while (fgets(line, sizeof(line), du) != NULL) {
- size_t length(strlen(line));
- while (length != 0 && line[length - 1] == '\n')
- line[--length] = '\0';
- if (char *tab = strchr(line, '\t')) {
- *tab = '\0';
- value = [NSNumber numberWithUnsignedLong:strtoul(line, NULL, 0)];
- }
+ FILE *du(popen([[NSString stringWithFormat:@"/usr/libexec/cydia/cydo /usr/libexec/cydia/du -ks %@", ShellEscape(path)] UTF8String], "r"));
+ if (du != NULL) {
+ char line[1024];
+ while (fgets(line, sizeof(line), du) != NULL) {
+ size_t length(strlen(line));
+ while (length != 0 && line[length - 1] == '\n')
+ line[--length] = '\0';
+ if (char *tab = strchr(line, '\t')) {
+ *tab = '\0';
+ value = [NSNumber numberWithUnsignedLong:strtoul(line, NULL, 0)];