MCPcopy Create free account
hub / github.com/coreutils/coreutils / swallow_file_in_memory

Function swallow_file_in_memory

src/ptx.c:493–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491`------------------------------------------------------------------------*/
492
493static void
494swallow_file_in_memory (char const *file_name, BLOCK *block)
495{
496 size_t used_length; /* used length in memory buffer */
497
498 /* As special cases, a file name which is null or "-" indicates standard
499 input, which is already opened. In all other cases, open the file from
500 its name. */
501 bool using_stdin = !file_name || !*file_name || streq (file_name, "-");
502 if (using_stdin)
503 block->start = fread_file (stdin, 0, &used_length);
504 else
505 block->start = read_file (file_name, 0, &used_length);
506
507 if (!block->start)
508 error (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name));
509
510 if (using_stdin)
511 clearerr (stdin);
512
513 block->end = block->start + used_length;
514}
515
516/* Sort and search routines. */
517

Callers 3

digest_break_fileFunction · 0.85
digest_word_fileFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected