MCPcopy Create free account
hub / github.com/MariaDB/server / MakeEmptyFile

Method MakeEmptyFile

storage/connect/filamvct.cpp:373–406  ·  view source on GitHub ↗

/ VCT Create an empty file for Vector formatted tables. */ /

Source from the content-addressed store, hash-verified

371/* VCT Create an empty file for Vector formatted tables. */
372/***********************************************************************/
373bool VCTFAM::MakeEmptyFile(PGLOBAL g, PCSZ fn)
374 {
375 // Vector formatted file: this will create an empty file of the
376 // required length if it does not exists yet.
377 char filename[_MAX_PATH], c = 0;
378 int h, n;
379
380 PlugSetPath(filename, fn, Tdbp->GetPath());
381#if defined(_WIN32)
382 h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, _O_CREAT | _O_WRONLY, S_IREAD | S_IWRITE);
383#else // !_WIN32
384 h= global_open(g, MSGID_OPEN_EMPTY_FILE, filename, O_CREAT | O_WRONLY, S_IREAD | S_IWRITE);
385#endif // !_WIN32
386
387 if (h == -1)
388 return true;
389
390 n = (Header == 1 || Header == 3) ? sizeof(VECHEADER) : 0;
391
392 if (lseek(h, n + MaxBlk * Nrec * Lrecl - 1, SEEK_SET) < 0)
393 goto err;
394
395 // This actually fills the empty file
396 if (write(h, &c, 1) < 0)
397 goto err;
398
399 close(h);
400 return false;
401
402 err:
403 snprintf(g->Message, sizeof(g->Message), MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
404 close(h);
405 return true;
406 } // end of MakeEmptyFile
407
408/***********************************************************************/
409/* VCT Access Method opening routine. */

Callers

nothing calls this directly

Calls 7

global_openFunction · 0.85
writeEnum · 0.85
GetLastErrorFunction · 0.85
safe_strcatFunction · 0.85
PlugSetPathFunction · 0.70
htrcFunction · 0.70
GetPathMethod · 0.45

Tested by

no test coverage detected