Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
f5b532b1
Commit
f5b532b1
authored
Sep 23, 2007
by
Wayne Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an option to copy_file() that tells it to try to make a
backup directory if the open of the dest file fails.
parent
c0dba635
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
util.c
util.c
+6
-6
No files found.
util.c
View file @
f5b532b1
...
...
@@ -265,15 +265,14 @@ static int safe_read(int desc, char *ptr, size_t len)
*
* This is used in conjunction with the --temp-dir, --backup, and
* --copy-dest options. */
int
copy_file
(
const
char
*
source
,
const
char
*
dest
,
mode_t
mode
)
int
copy_file
(
const
char
*
source
,
const
char
*
dest
,
mode_t
mode
,
int
create_bak_dir
)
{
int
ifd
;
int
ofd
;
char
buf
[
1024
*
8
];
int
len
;
/* Number of bytes read into `buf'. */
ifd
=
do_open
(
source
,
O_RDONLY
,
0
);
if
(
ifd
==
-
1
)
{
if
((
ifd
=
do_open
(
source
,
O_RDONLY
,
0
))
<
0
)
{
rsyserr
(
FERROR
,
errno
,
"open %s"
,
full_fname
(
source
));
return
-
1
;
}
...
...
@@ -283,8 +282,9 @@ int copy_file(const char *source, const char *dest, mode_t mode)
return
-
1
;
}
ofd
=
do_open
(
dest
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_EXCL
,
mode
);
if
(
ofd
==
-
1
)
{
if
((
ofd
=
do_open
(
dest
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_EXCL
,
mode
))
<
0
&&
(
!
create_bak_dir
||
errno
!=
ENOENT
||
make_bak_dir
(
dest
)
<
0
||
(
ofd
=
do_open
(
dest
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_EXCL
,
mode
))
<
0
))
{
rsyserr
(
FERROR
,
errno
,
"open %s"
,
full_fname
(
dest
));
close
(
ifd
);
return
-
1
;
...
...
@@ -407,7 +407,7 @@ int robust_rename(const char *from, const char *to, const char *partialptr,
return
-
1
;
to
=
partialptr
;
}
if
(
copy_file
(
from
,
to
,
mode
)
!=
0
)
if
(
copy_file
(
from
,
to
,
mode
,
0
)
!=
0
)
return
-
2
;
do_unlink
(
from
);
return
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment