[Libreoffice-commits] core.git: include/osl sal/osl
Stephan Bergmann
sbergman at redhat.com
Fri Oct 31 04:06:06 PDT 2014
include/osl/file.h | 6 +++++-
sal/osl/unx/file_misc.cxx | 21 ++++++++++++++++++---
2 files changed, 23 insertions(+), 4 deletions(-)
New commits:
commit 6edbcc1b231feb02f304ff646c323b5df051d9a4
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Oct 31 12:05:25 2014 +0100
cid#1242936 handle rename failure
Change-Id: I92ce690a6f8183ce77c8ed53bd2fcb45d39d756e
diff --git a/include/osl/file.h b/include/osl/file.h
index e2167db..a9c9462 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 eb1e151..5386e4e 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 */
More information about the Libreoffice-commits
mailing list