summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2007-10-19 15:27:45 -0400
committerRay Strode <rstrode@redhat.com>2007-10-19 15:27:45 -0400
commit3e93636726afbc69699c84d53169d3493e37299f (patch)
tree1c211bfd89a16e11642540d436c446875266a712 /src
parentac1e206825516e386c38224f98c97ea0468842e9 (diff)
Make ply_create_directory more robust about trailing slashes
Diffstat (limited to 'src')
-rw-r--r--src/libply/ply-utils.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c
index ed8b19a..bf94ba3 100644
--- a/src/libply/ply-utils.c
+++ b/src/libply/ply-utils.c
@@ -653,12 +653,13 @@ ply_create_directory (const char *directory)
ply_trace ("parent directory '%s' doesn't exist, creating it first", parent_directory);
if (ply_create_directory (parent_directory)
- && (mkdir (directory, 0755) == 0))
+ && ((mkdir (directory, 0755) == 0) || errno == EEXIST))
is_created = true;
ply_save_errno ();
free (parent_directory);
ply_restore_errno ();
+
}
return is_created;
@@ -757,14 +758,18 @@ ply_copy_file (const char *source,
file_copied = false;
source_fd = -1;
destination_fd = -1;
+
+ ply_trace ("opening source '%s'", source);
source_fd = open (source, O_RDONLY | O_NOFOLLOW);
if (source_fd < 0)
goto out;
+ ply_trace ("stating fd %d", source_fd);
if (fstat (source_fd, &file_info) < 0)
goto out;
+ ply_trace ("opening dest '%s'", destination);
destination_fd = open (destination, O_WRONLY | O_NOFOLLOW | O_CREAT,
file_info.st_mode);
@@ -792,8 +797,10 @@ ply_copy_file (const char *source,
file_copied = true;
out:
+ ply_save_errno ();
close (source_fd);
close (destination_fd);
+ ply_restore_errno ();
return file_copied;
}
@@ -805,6 +812,7 @@ ply_copy_file_in_direcetory (const char *filename,
{
char *source, *target;
+ ply_trace ("copying '%s' in '%s' to '%s'", filename, parent, destination);
source = NULL;
asprintf (&source, "%s/%s", parent, filename);