Wed 08 Apr 2009 08:24:55 AM UTC, comment #8:
This has now been fixed. Thanks to Ben Pfaff for getting the necessary patch into gnulib.
|
Fri 20 Mar 2009 03:27:09 AM UTC, comment #7:
It works. I can save a file just clicking on the "SAVE" button.
What I did was change the "rename" to:
ok = MoveFileEx(rf->tmp_name, rf->file_name, MOVEFILE_REPLACE_EXISTING) != 0;
and insert an "#include <windows.h>" on the top of the file.
I need to use "!= 0" because it only returns zero if a error happens, the opposite of rename.
|
Fri 20 Mar 2009 03:13:31 AM UTC, comment #6:
On Windows theres is a function called MoveFileEx:http://msdn.microsoft.com/en-us/library/aa365240(VS.85).aspx
It has two interesting options:
MOVEFILE_REPLACE_EXISTING: If a file named lpNewFileName exists, the function replaces its contents with the contents of the lpExistingFileName file...
We could use:
ok = MoveFileEx(rf->tmp_name, rf->file_name, MOVEFILE_REPLACE_EXISTING) != 0;
I will try it.
|
Fri 20 Mar 2009 02:59:36 AM UTC, comment #5:
Unfortunately this isn't a correct solution to the problem. It'll break a number of other things, because we need the destination to remain intact if renaming the file fails for any reason.
Currently we have:
rename (rf->tmp_name, rf->file_name);
one solution would be to change this to:
rename (rf->file_name, tmp2_name);
if ( ! rename (rf->tmp_name, rf->file_name))
rename (tmp2_name, rf->file_name);
but that brings some issues of its own.
Alternatively if there is a safe equivalent to "rename" in Mingw which can safely and atomically move files from one filesystem entry to another, then we could use that.
So we still have to come up with a solution to this problem, but at least we understand it better.
|
Fri 20 Mar 2009 02:44:39 AM UTC, comment #4:
GREAT! It works. I did what you told and it fixes this issue.Thank you!
|
Fri 20 Mar 2009 02:18:00 AM UTC, comment #3:
Looking through the code, it would appear that the file has been closed. The error message doesn't complain that the file is open, simply that it exists.
What happens if you add unlink (rf->file_name);
above the call to rename in make-file.c ?
|
Fri 20 Mar 2009 12:09:48 AM UTC, comment #2:
Seems like its a problem with rename() function. On Linux it allows to rename an open file, but on windows it doesn't.
Looking at Posix theres nothing about rename an open file, so I don't know who is "right".
I've send an message to mingw list to see if theres an alternative to that.
|
Mon 09 Mar 2009 04:12:09 AM UTC, comment #1:
>If I open a file on psppire(in this case teste2.sav file) and
>change anything on it and then click on "Save" button, I get:
>"PSPP error: Replacing teste2.sav.tmpcLzJvi by teste2.sav: File
>exists."
I don't have a solution, yet, but I can speculate on what is going on. I suspect that PSPPIRE has teste2.sav still open at the time that it tries to replace it by a new version. Under Unix, this works just fine. But Windows forbids deleting or replacing an open file, so it fails (with the given error message).
>After that, if I close this error message, and close psppire, it
>doesn't ask me to save my file before close it.
That sounds like a separate bug, for what it's worth. PSPPIRE should consider the file not to be saved if the save failed (as it did).
|
Sun 08 Mar 2009 10:06:17 PM UTC, original submission:
If I open a file on psppire(in this case teste2.sav file) and change anything on it and then click on "Save" button, I get:
"PSPP error: Replacing teste2.sav.tmpcLzJvi by teste2.sav: File exists."
After that, if I close this error message, and close psppire, it doesn't ask me to save my file before close it.
If I open the file again, the changes aren't there.
|