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

Function mkancesdirs_safe_wd

src/install.c:747–782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745 Return true if successful. */
746
747static bool
748mkancesdirs_safe_wd (char const *from, char *to, struct cp_options *x,
749 bool save_always)
750{
751 bool save_working_directory =
752 save_always
753 || ! (IS_ABSOLUTE_FILE_NAME (from) && IS_ABSOLUTE_FILE_NAME (to));
754
755 struct savewd wd;
756 savewd_init (&wd);
757 if (! save_working_directory)
758 savewd_finish (&wd);
759
760 int status = EXIT_SUCCESS;
761 if (mkancesdirs (to, &wd, make_ancestor, x) == -1)
762 {
763 error (0, errno, _("cannot create directory %s"), quoteaf (to));
764 status = EXIT_FAILURE;
765 }
766
767 if (save_working_directory)
768 {
769 int restore_result = savewd_restore (&wd, status);
770 int restore_errno = errno;
771 savewd_finish (&wd);
772 if (EXIT_SUCCESS < restore_result)
773 return false;
774 if (restore_result < 0 && status == EXIT_SUCCESS)
775 {
776 error (0, restore_errno, _("cannot create directory %s"),
777 quoteaf (to));
778 return false;
779 }
780 }
781 return status == EXIT_SUCCESS;
782}
783
784/* Copy file FROM onto file TO, creating any missing parent directories of TO.
785 Return true if successful. */

Callers 2

install_file_in_dirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected