diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-08-28 11:11:28 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-08-28 11:11:28 +0000 |
commit | f0fabf88acbc7cce1efb9c00b3cfb19c642d9a35 (patch) | |
tree | 67e7149d561a7a702a48441fc4ca98078f2bf678 /pjlib/src/pj/file_io_win32.c | |
parent | 44713297a9609e7834819b986ec5c66998d2b35c (diff) |
Ticket #604: Error opening file in append mode in Win32 (thanks Gang Liu for the report)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2253 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/file_io_win32.c')
-rw-r--r-- | pjlib/src/pj/file_io_win32.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pjlib/src/pj/file_io_win32.c b/pjlib/src/pj/file_io_win32.c index 622ddd82..ee7edef8 100644 --- a/pjlib/src/pj/file_io_win32.c +++ b/pjlib/src/pj/file_io_win32.c @@ -59,6 +59,7 @@ PJ_DEF(pj_status_t) pj_file_open( pj_pool_t *pool, dwDesiredAccess |= GENERIC_WRITE; if ((flags & PJ_O_APPEND) == PJ_O_APPEND) { dwDesiredAccess |= FILE_APPEND_DATA; + dwCreationDisposition |= OPEN_EXISTING; } else { dwDesiredAccess &= ~(FILE_APPEND_DATA); dwCreationDisposition |= CREATE_ALWAYS; @@ -86,6 +87,16 @@ PJ_DEF(pj_status_t) pj_file_open( pj_pool_t *pool, return PJ_RETURN_OS_ERROR(GetLastError()); } + if ((flags & PJ_O_APPEND) == PJ_O_APPEND) { + pj_status_t status; + + status = pj_file_setpos(hFile, 0, PJ_SEEK_END); + if (status != PJ_SUCCESS) { + pj_file_close(hFile); + return status; + } + } + *fd = hFile; return PJ_SUCCESS; } |