MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / create_backup

Method create_backup

src/utilities/nbackup/nbackup.cpp:767–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

765}
766
767void NBackup::create_backup()
768{
769#ifdef WIN_NT
770 if (bakname == "stdout") {
771 backup = GetStdHandle(STD_OUTPUT_HANDLE);
772 }
773 else
774 {
775 // See CORE-4913 and "Create File" article on MSDN:
776 // When an application creates a file across a network, it is better to use
777 // GENERIC_READ | GENERIC_WRITE for dwDesiredAccess than to use GENERIC_WRITE
778 // alone. The resulting code is faster, because the redirector can use the
779 // cache manager and send fewer SMBs with more data. This combination also
780 // avoids an issue where writing to a file across a network can occasionally
781 // return ERROR_ACCESS_DENIED.
782
783 backup = CreateFile(bakname.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE,
784 NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
785 }
786 if (backup != INVALID_HANDLE_VALUE)
787 return;
788#else
789 if (bakname == "stdout")
790 {
791 backup = 1; // Posix file handle for stdout
792 return;
793 }
794 backup = os_utils::open(bakname.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, 0660);
795 if (backup >= 0)
796 return;
797#endif
798
799 status_exception::raise(Arg::Gds(isc_nbackup_err_createbk) << bakname.c_str() << Arg::OsError());
800}
801
802void NBackup::close_backup()
803{

Callers

nothing calls this directly

Calls 5

raiseFunction · 0.85
GdsClass · 0.85
OsErrorClass · 0.85
openFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected