diff options
author | Vincent Richard <[email protected]> | 2009-07-11 12:31:18 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2009-07-11 12:31:18 +0000 |
commit | f36ccb2558bfb6c45fc0dcf56c69b2a9e139765b (patch) | |
tree | b4a74b04176d219377f3ef3cdc5c80ccac54c8cf | |
parent | Ensure 'unsigned long' is 4 bytes long (Georg Sauthoff). (diff) | |
download | vmime-f36ccb2558bfb6c45fc0dcf56c69b2a9e139765b.tar.gz vmime-f36ccb2558bfb6c45fc0dcf56c69b2a9e139765b.zip |
fsync() in posixFile::fileCreate(); changed posixFile::rename to exclusive semantics - if dst exists it fails (Georg Sauthoff).
Diffstat (limited to '')
-rw-r--r-- | src/platforms/posix/posixFile.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp index 9b16d035..2a1356ac 100644 --- a/src/platforms/posix/posixFile.cpp +++ b/src/platforms/posix/posixFile.cpp @@ -284,6 +284,9 @@ void posixFile::createFile() if ((fd = ::open(m_nativePath.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660)) == -1) posixFileSystemFactory::reportError(m_path, errno); + if (::fsync(fd) == -1) + posixFileSystemFactory::reportError(m_path, errno); + if (::close(fd) == -1) posixFileSystemFactory::reportError(m_path, errno); } @@ -390,6 +393,9 @@ void posixFile::rename(const path& newName) { const vmime::string newNativePath = posixFileSystemFactory::pathToStringImpl(newName); + posixFile dest(newName); + dest.createFile(); + if (::rename(m_nativePath.c_str(), newNativePath.c_str()) == -1) posixFileSystemFactory::reportError(m_path, errno); |