aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'samsung-ipc/utils.c')
-rw-r--r--samsung-ipc/utils.c134
1 files changed, 0 insertions, 134 deletions
diff --git a/samsung-ipc/utils.c b/samsung-ipc/utils.c
index e606cad..726f65c 100644
--- a/samsung-ipc/utils.c
+++ b/samsung-ipc/utils.c
@@ -594,137 +594,3 @@ void *string2data(const char *string)
return data;
}
-
-#define DIR_EEXIST 0
-#define DIR_CREATED 1
-
-int rmdir_p(struct ipc_client *client, const char * const path,
- uint64_t dirs_depth, uint64_t created_dirs)
-{
-#if 0
- char *_path;
- char *startp;
- char *endp;
- uint64_t created_dirs = 0;
- uint64_t dirs_depth = 0;
- int rc;
-
- /* We want to be able to modify the path string to replace '/'
- * with '\0' to avoid having to copy again and again string
- * parts */
- _path = malloc(strlen(path) + 1);
- if (_path == NULL) {
- rc = errno;
- ipc_client_log(client,
- "%s: malloc _path failed with error %d: %s",
- __func__, rc, strerror(rc));
- errno = rc;
- return -1;
- }
-
- memcpy(_path, path, strlen(path) + 1);
-
- startp = _path;
- while (true) {
- endp = strchr(startp + 1, '/');
- if (endp != NULL)
- *endp = '\0';
-
- //rc = mkdir(_path, mode);
- if (rc == -1) {
- rc = errno;
- if (rc == EEXIST) {
- dirs_depth++;
- } else {
- ipc_client_log(client,
- "%s: mkdir %s failed with error %d: %s",
- __func__, _path, rc, strerror(rc));
- rc = rmdir_p(client, _path, dirs_depth, created_dirs);
- if (rc == -1) {
- ipc_client_log(client,
- "%s: rmdir_p %s failed",
- __func__, _path);
- }
- return -1;
- }
- } else {
- created_dirs |= (DIR_CREATED << dirs_depth);
- dirs_depth++;
- }
-
- if (endp == NULL)
- break;
-
- startp = endp;
- *endp = '/';
- }
-#endif
- return 0;
-}
-
-int mkdir_p(struct ipc_client *client, const char * const path, mode_t mode)
-{
- char *_path;
- char *startp;
- char *endp;
- /* In case of errors we want to be able to remove (only) the
- * directories we created, so we need to store what was
- * already there and what we created. */
- uint64_t created_dirs = 0;
- uint64_t dirs_depth = 0;
- int rc;
-
- /* We want to be able to modify the path string to replace '/'
- * with '\0' to avoid having to copy again and again string
- * parts */
- _path = malloc(strlen(path) + 1);
- if (_path == NULL) {
- rc = errno;
- ipc_client_log(client,
- "%s: malloc _path failed with error %d: %s",
- __func__, rc, strerror(rc));
- errno = rc;
- return -1;
- }
-
- memcpy(_path, path, strlen(path) + 1);
-
- startp = _path;
- while (true) {
- endp = strchr(startp + 1, '/');
- if (endp != NULL)
- *endp = '\0';
-
- rc = mkdir(_path, mode);
- if (rc == -1) {
- rc = errno;
- if (rc == EEXIST) {
- dirs_depth++;
- } else {
- ipc_client_log(client,
- "%s: mkdir %s failed with error %d: %s",
- __func__, _path, rc, strerror(rc));
- rc = rmdir_p(client, _path, dirs_depth, created_dirs);
- if (rc == -1) {
- ipc_client_log(client,
- "%s: rmdir_p %s failed",
- __func__, _path);
- }
- free(_path);
- return -1;
- }
- } else {
- created_dirs |= (DIR_CREATED << dirs_depth);
- dirs_depth++;
- }
-
- if (endp == NULL)
- break;
-
- startp = endp;
- *endp = '/';
- }
-
- free(_path);
- return 0;
-}