rename() cannot replace the file which is opened with writable access
L. A. Walsh
cygwin@tlinx.org
Thu Jan 12 19:06:00 GMT 2017
Masamichi Hosoda wrote:
> Hello,
>
> I've found that rename() cannot replace the file
> which is opened with writable access on Cygwin.
> On Linux, it works.
>
> If I understand correctly, it should work under POSIX.
>
> Here's sample code for reproduce.
---
> #define OLDPATH "oldpath"
> #define NEWPATH "newpath"
>
> int main () {
> int fd;
> struct flock fl;
> char buff[] = "test";
> fd = open (OLDPATH, O_CREAT | O_RDWR | O_TRUNC, 0666);
> close (fd);
> fd = open (NEWPATH, O_CREAT | O_RDWR | O_TRUNC, 0666);
> if (rename (OLDPATH, NEWPATH) < 0) perror ("rename");
>
----
What are you trying to do by renaming the oldfile
over the top of a still-open-for-write, "newfile".
Why rename over the top of another file? What are you trying
to do? Maybe there is a better way to do it? ;-).
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list