rendered paste bodyIndex: client/File.cpp===================================================================--- client/File.cpp (.../svn+ssh://david@null/home/repos/ldcpp/tags/cvs-2007-10-28) (revision 19)+++ client/File.cpp (arbetskopia)@@ -223,8 +223,9 @@ } h = open(filename.c_str(), m, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);- if(h == -1)- throw FileException("Could not open file");+ if(h == -1) {+ throw FileException(Util::translateError(errno));+ } } uint32_t File::getLastModified() throw() {@@ -271,20 +272,31 @@ } size_t File::read(void* buf, size_t& len) throw(FileException) {- ssize_t x = ::read(h, buf, len);- if(x == -1)- throw FileException("Read error");- len = x;- return (size_t)x;+ ssize_t result = ::read(h, buf, len);+ if (result == -1) {+ throw FileException(Util::translateError(errno));+ }+ len = result;+ return (size_t)result; } size_t File::write(const void* buf, size_t len) throw(FileException) {- ssize_t x = ::write(h, buf, len);- if(x == -1)- throw FileException("Write error");- if(x < (ssize_t)len)- throw FileException("Disk full(?)");- return x;+ ssize_t result;+ char* pointer = (char*)buf;+ int left = len;++ while (left > 0) {+ result = ::write(h,pointer,left);+ if (result == -1) {+ if (errno != EINTR) {+ throw FileException(Util::translateError(errno));+ }+ } else {+ pointer+=result;+ left-=result;+ }+ }+ return len; } // some ftruncate implementations can't extend files like SetEndOfFile,@@ -338,10 +350,10 @@ void File::renameFile(const string& source, const string& target) throw(FileException) { int ret = ::rename(Text::fromUtf8(source).c_str(), Text::fromUtf8(target).c_str()); if(ret != 0 && errno == EXDEV) {- copyFile(source.c_str(), target.c_str());- deleteFile(source.c_str());+ copyFile(source, target);+ deleteFile(source); } else if(ret != 0)- throw FileException(source.c_str() + Util::translateError(errno));+ throw FileException(source + Util::translateError(errno)); } // This doesn't assume all bytes are written in one write call, it is a bit saferIndex: client/Util.h===================================================================--- client/Util.h (.../svn+ssh://david@null/home/repos/ldcpp/tags/cvs-2007-10-28) (revision 19)+++ client/Util.h (arbetskopia)@@ -192,7 +192,13 @@ } return tmp; #else // _WIN32- return Text::toUtf8(strerror(aError));+// strerror is not thread safe. +// return Text::toUtf8(strerror(aError));++ char errorBuffer[100];+ char* errorMsg = strerror_r(aError, errorBuffer, 100);+ return Text::toUtf8(errorMsg);+ #endif // _WIN32 }