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 | |
parent | f13678d8055d77f891b258f6e2a27aac2c0f07e7 (diff) |
cid#1242936 handle rename failure
Change-Id: I92ce690a6f8183ce77c8ed53bd2fcb45d39d756e
-rw-r--r-- | include/osl/file.h | 6 | ||||
-rw-r--r-- | sal/osl/unx/file_misc.cxx | 21 |
2 files changed, 23 insertions, 4 deletions
diff --git a/include/osl/file.h b/include/osl/file.h index e2167dbf72b2..a9c94627e4a2 100644 --- a/include/osl/file.h +++ b/include/osl/file.h @@ -1309,7 +1309,9 @@ SAL_DLLPUBLIC oslFileError SAL_CALL osl_removeFile( osl_File_E_NAMETOOLONG file name too long<br> osl_File_E_NOENT no such file or directory<br> osl_File_E_ISDIR is a directory<br> - osl_File_E_ROFS read-only file system<p> + osl_File_E_ROFS read-only file system<br> + osl_File_E_BUSY if the implementation internally requires resources that are + (temporarily) unavailable (added with LibreOffice 4.4) @see osl_moveFile() @see osl_removeFile() @@ -1339,6 +1341,8 @@ SAL_DLLPUBLIC oslFileError SAL_CALL osl_copyFile( osl_File_E_NAMETOOLONG file name too long<br> osl_File_E_NOENT no such file or directory<br> osl_File_E_ROFS read-only file system<br> + osl_File_E_BUSY if the implementation internally requires resources that are + (temporarily) unavailable (added with LibreOffice 4.4) @see osl_copyFile() */ 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 */ |