summaryrefslogtreecommitdiffstats
path: root/otautil
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--otautil/DirUtil.cpp56
-rw-r--r--otautil/DirUtil.h13
2 files changed, 0 insertions, 69 deletions
diff --git a/otautil/DirUtil.cpp b/otautil/DirUtil.cpp
index e08e360c0..ad344dedf 100644
--- a/otautil/DirUtil.cpp
+++ b/otautil/DirUtil.cpp
@@ -160,59 +160,3 @@ dirCreateHierarchy(const char *path, int mode,
}
return 0;
}
-
-int
-dirUnlinkHierarchy(const char *path)
-{
- struct stat st;
- DIR *dir;
- struct dirent *de;
- int fail = 0;
-
- /* is it a file or directory? */
- if (lstat(path, &st) < 0) {
- return -1;
- }
-
- /* a file, so unlink it */
- if (!S_ISDIR(st.st_mode)) {
- return unlink(path);
- }
-
- /* a directory, so open handle */
- dir = opendir(path);
- if (dir == NULL) {
- return -1;
- }
-
- /* recurse over components */
- errno = 0;
- while ((de = readdir(dir)) != NULL) {
- //TODO: don't blow the stack
- char dn[PATH_MAX];
- if (!strcmp(de->d_name, "..") || !strcmp(de->d_name, ".")) {
- continue;
- }
- snprintf(dn, sizeof(dn), "%s/%s", path, de->d_name);
- if (dirUnlinkHierarchy(dn) < 0) {
- fail = 1;
- break;
- }
- errno = 0;
- }
- /* in case readdir or unlink_recursive failed */
- if (fail || errno < 0) {
- int save = errno;
- closedir(dir);
- errno = save;
- return -1;
- }
-
- /* close directory handle */
- if (closedir(dir) < 0) {
- return -1;
- }
-
- /* delete target directory */
- return rmdir(path);
-}
diff --git a/otautil/DirUtil.h b/otautil/DirUtil.h
index 85b83c387..beecc1081 100644
--- a/otautil/DirUtil.h
+++ b/otautil/DirUtil.h
@@ -17,13 +17,8 @@
#ifndef MINZIP_DIRUTIL_H_
#define MINZIP_DIRUTIL_H_
-#include <stdbool.h>
#include <utime.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
struct selabel_handle;
/* Like "mkdir -p", try to guarantee that all directories
@@ -43,12 +38,4 @@ int dirCreateHierarchy(const char *path, int mode,
const struct utimbuf *timestamp, bool stripFileName,
struct selabel_handle* sehnd);
-/* rm -rf <path>
- */
-int dirUnlinkHierarchy(const char *path);
-
-#ifdef __cplusplus
-}
-#endif
-
#endif // MINZIP_DIRUTIL_H_