Closed Bug 21979 Opened 25 years ago Closed 25 years ago

[PP]PR_APPEND on a nsOutputFileStream on windows does not work right

Categories

(NSPR :: NSPR, defect, P3)

x86
Windows NT
defect

Tracking

(Not tracked)

VERIFIED DUPLICATE of bug 4090

People

(Reporter: sspitzer, Assigned: srinivas)

Details

I've fixed the bug (by using nsIOFileStreams) but on windows nsOutputFileStream doesn't open the file for append in the following case: nsOutputFileStream newsrcStream(newsrcFile, (PR_WRONLY | PR_CREATE_FILE | PR_APPEND)); it ends up opening the file to the start. (on linux, it does the right thing) I fixed my code to do be this: nsIOFileStream newsrcStream(newsrcFile /*, PR_CREATE_FILE */ ); newsrcStream.seek(newsrcFile.GetFileSize()); assigning bug to wtc, because bienvenu thinks its an underlying NSPR bug.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → DUPLICATE
This is a known bug (Bugzilla #4090). PR_APPEND is not yet implemented for non-Unix platforms. PR_APPEND needs to seek to the end of file prior to *every* write, as opposed to when the file is opened. Since Win32 does not have native support of PR_APPEND, I will need to emulate it by calling SetFilePointer() before every WriteFile() call. This is inefficient. You can usually achieve what you want by seeking to the end of file immediately after the file is opened and then never seeking again. Then your writes will all occur at the end of file. You pay the cost of one extra lseek() call on Unix, but win on other platforms where PR_APPEND needs to be emulated. *** This bug has been marked as a duplicate of 4090 ***
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.