diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-10-31 12:05:25 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-10-31 12:05:25 +0100 |
commit | 6edbcc1b231feb02f304ff646c323b5df051d9a4 (patch) | |
tree | 2c692063c08db7feb3eb9898ce2a928fbb293d80 /sal | |
parent | f13678d8055d77f891b258f6e2a27aac2c0f07e7 (diff) |
cid#1242936 handle rename failure
Change-Id: I92ce690a6f8183ce77c8ed53bd2fcb45d39d756e
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/file_misc.cxx | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx index eb1e15194fed..5386e4e31077 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -810,6 +810,8 @@ static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* if ( DestFileExists ) { + //TODO: better pick a temp file name instead of adding .osl-tmp: + strncpy(pszTmpDestFile, pszDestFileName, size_tmp_dest_buff - 1); if ((strlen(pszTmpDestFile) + strlen(TMP_DEST_FILE_EXTENSION)) >= size_tmp_dest_buff) @@ -817,9 +819,22 @@ static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* strncat(pszTmpDestFile, TMP_DEST_FILE_EXTENSION, strlen(TMP_DEST_FILE_EXTENSION)); - /* FIXME: what if pszTmpDestFile already exists? */ - /* with getcanonical??? */ - nRet=rename(pszDestFileName,pszTmpDestFile); + if (rename(pszDestFileName,pszTmpDestFile) != 0) + { + if (errno == ENOENT) + { + DestFileExists = 0; + } + else + { + int e = errno; + SAL_INFO( + "sal.osl", + "rename(" << pszDestFileName << ", " << pszTmpDestFile + << ") failed with errno " << e); + return osl_File_E_BUSY; // for want of a better error code + } + } } /* mfe: should be S_ISREG */ |