577 |
577 |
#else
|
578 |
578 |
nlink_t nlink = buf.st_nlink;
|
579 |
579 |
#endif
|
|
580 |
#ifdef EXV_UNICODE_PATH
|
|
581 |
std::wstring wtmpname;
|
|
582 |
#endif
|
|
583 |
std::string tmpname;
|
580 |
584 |
|
581 |
585 |
// If file is > 1MB and doesn't have hard links then use a file, otherwise
|
582 |
586 |
// use a memory buffer. I.e., files with hard links always use a memory
|
... | ... | |
586 |
590 |
std::auto_ptr<FileIo> fileIo;
|
587 |
591 |
#ifdef EXV_UNICODE_PATH
|
588 |
592 |
if (p_->wpMode_ == Impl::wpUnicode) {
|
589 |
|
std::wstring tmpname = wpath() + s2ws(toString(pid));
|
590 |
|
fileIo = std::auto_ptr<FileIo>(new FileIo(tmpname));
|
|
593 |
wtmpname = wpath() + s2ws(toString(pid));
|
|
594 |
fileIo = std::auto_ptr<FileIo>(new FileIo(wtmpname));
|
591 |
595 |
}
|
592 |
596 |
else
|
593 |
597 |
#endif
|
594 |
598 |
{
|
595 |
|
std::string tmpname = path() + toString(pid);
|
|
599 |
tmpname = temporaryPath() + toString(pid);
|
596 |
600 |
fileIo = std::auto_ptr<FileIo>(new FileIo(tmpname));
|
597 |
601 |
}
|
598 |
602 |
if (fileIo->open("w+b") != 0) {
|
599 |
603 |
#ifdef EXV_UNICODE_PATH
|
600 |
604 |
if (p_->wpMode_ == Impl::wpUnicode) {
|
|
605 |
#if defined(_MSC_VER) || defined(__MINGW__)
|
|
606 |
if( !DeleteFileW( wtmpname.c_str() ) )
|
|
607 |
#else
|
|
608 |
if( remove( wtmpname.c_str() ) != 0 )
|
|
609 |
#endif
|
|
610 |
{
|
|
611 |
perror("Error deleting file");
|
|
612 |
}
|
601 |
613 |
throw WError(10, wpath(), "w+b", strError().c_str());
|
602 |
614 |
}
|
603 |
615 |
else
|
604 |
616 |
#endif
|
605 |
617 |
{
|
|
618 |
#if defined(_MSC_VER) || defined(__MINGW__)
|
|
619 |
if( !DeleteFile( tmpname.c_str() ) )
|
|
620 |
#else
|
|
621 |
if( remove( tmpname.c_str() ) != 0 )
|
|
622 |
#endif
|
|
623 |
{
|
|
624 |
perror("Error deleting file");
|
|
625 |
}
|
606 |
626 |
throw Error(10, path(), "w+b", strError());
|
607 |
627 |
}
|
608 |
628 |
}
|