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

Function overwrite_ok

src/copy.c:1412–1438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1410}
1411
1412static bool
1413overwrite_ok (struct cp_options const *x, char const *dst_name,
1414 int dst_dirfd, char const *dst_relname,
1415 struct stat const *dst_sb)
1416{
1417 if (! writable_destination (dst_dirfd, dst_relname, dst_sb->st_mode))
1418 {
1419 char perms[12]; /* "-rwxrwxrwx " ls-style modes. */
1420 strmode (dst_sb->st_mode, perms);
1421 perms[10] = '\0';
1422 fprintf (stderr,
1423 (x->move_mode || x->unlink_dest_before_opening
1424 || x->unlink_dest_after_failed_open)
1425 ? _("%s: replace %s, overriding mode %04lo (%s)? ")
1426 : _("%s: unwritable %s (mode %04lo, %s); try anyway? "),
1427 program_name, quoteaf (dst_name),
1428 (unsigned long int) (dst_sb->st_mode & CHMOD_MODE_BITS),
1429 &perms[1]);
1430 }
1431 else
1432 {
1433 fprintf (stderr, _("%s: overwrite %s? "),
1434 program_name, quoteaf (dst_name));
1435 }
1436
1437 return yesno ();
1438}
1439
1440/* Initialize the hash table implementing a set of F_triple entries
1441 corresponding to destination files. */

Callers 2

abandon_moveFunction · 0.85
copy_internalFunction · 0.85

Calls 1

writable_destinationFunction · 0.85

Tested by

no test coverage detected