Kaydet (Commit) 6edbcc1b authored tarafından Stephan Bergmann's avatar Stephan Bergmann

cid#1242936 handle rename failure

Change-Id: I92ce690a6f8183ce77c8ed53bd2fcb45d39d756e
üst f13678d8
......@@ -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()
*/
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment