celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject celix git commit: CELIX-288: Change readdir to readdir_r for deployment admin
Date Tue, 17 Nov 2015 13:31:20 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 367608211 -> 048b79994


CELIX-288: Change readdir to readdir_r for deployment admin


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/048b7999
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/048b7999
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/048b7999

Branch: refs/heads/develop
Commit: 048b79994fe53afc16d7d666f4abdb51ea35ecd2
Parents: 3676082
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Tue Nov 17 14:19:20 2015 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Tue Nov 17 14:19:20 2015 +0100

----------------------------------------------------------------------
 deployment_admin/private/src/deployment_admin.c | 38 ++++++++++++--------
 1 file changed, 23 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/048b7999/deployment_admin/private/src/deployment_admin.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/deployment_admin.c b/deployment_admin/private/src/deployment_admin.c
index 1e70a02..200def4 100644
--- a/deployment_admin/private/src/deployment_admin.c
+++ b/deployment_admin/private/src/deployment_admin.c
@@ -475,21 +475,29 @@ static celix_status_t deploymentAdmin_deleteTree(char * directory) {
 	if (dir == NULL) {
 	    status = CELIX_FILE_IO_EXCEPTION;
 	} else {
-		struct dirent *dp;
-		while ((dp = readdir(dir)) != NULL) {
-		    if ((strcmp((dp->d_name), ".") != 0) && (strcmp((dp->d_name), "..") !=
0)) {
-                char subdir[512];
-                snprintf(subdir, sizeof(subdir), "%s/%s", directory, dp->d_name);
-
-                if (dp->d_type == DT_DIR) {
-                    status = deploymentAdmin_deleteTree(subdir);
-                } else {
-                    if (remove(subdir) != 0) {
-                        status = CELIX_FILE_IO_EXCEPTION;
-                        break;
-                    }
-                }
-		    }
+
+		struct dirent dp;
+		struct dirent *result = NULL;
+		int rc = readdir_r(dir, &dp, &result);
+		while (rc == 0 && result != NULL) {
+			if ((strcmp((dp.d_name), ".") != 0) && (strcmp((dp.d_name), "..") != 0)) {
+				char subdir[512];
+				snprintf(subdir, sizeof(subdir), "%s/%s", directory, dp.d_name);
+
+				if (dp.d_type == DT_DIR) {
+					status = deploymentAdmin_deleteTree(subdir);
+				} else {
+					if (remove(subdir) != 0) {
+						status = CELIX_FILE_IO_EXCEPTION;
+						break;
+					}
+				}
+			}
+			rc = readdir_r(dir, &dp, &result);
+		}
+
+		if (rc != 0) {
+			status = CELIX_FILE_IO_EXCEPTION;
 		}
 
 		if (closedir(dir) != 0) {


Mime
View raw message