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

Function cat_file

src/pinky.c:317–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315/* If FILE exists in HOME, print it to standard output, preceded by HEADER. */
316
317static void
318cat_file (char const *header, char const *home, char const *file)
319{
320 char *full_name = file_name_concat (home, file, NULL);
321 int fd = open (full_name, O_RDONLY);
322
323 if (0 <= fd)
324 {
325 idx_t header_len = strlen (header);
326 if (write (STDOUT_FILENO, header, header_len) != header_len)
327 write_error ();
328
329 fdadvise (fd, 0, 0, FADVISE_SEQUENTIAL);
330
331 char buf[IO_BUFSIZE];
332 for (ssize_t bytes_read; 0 < (bytes_read = read (fd, buf, sizeof buf));)
333 if (full_write (STDOUT_FILENO, buf, bytes_read) != bytes_read)
334 write_error ();
335
336 close (fd);
337 }
338
339 free (full_name);
340}
341
342/* Display a verbose line of information about UTMP_ENT. */
343

Callers 1

print_long_entryFunction · 0.85

Calls 2

write_errorFunction · 0.85
fdadviseFunction · 0.85

Tested by

no test coverage detected