Beispiel #1
0
static void
edit (const char *filename, const char *root)
{
  CLEANUP_FREE char *filename_to_free = NULL;
  int r;

  /* Windows?  Special handling is required. */
  if (root != NULL && is_windows (g, root)) {
    filename = filename_to_free = windows_path (g, root, filename,
                                                0 /* not read only */);
    if (filename == NULL)
      exit (EXIT_FAILURE);
  }

  if (perl_expr != NULL) {
    r = edit_file_perl (g, filename, perl_expr, backup_extension, verbose);
  } else
    r = edit_file_editor (g, filename, NULL /* use $EDITOR */,
                          backup_extension, verbose);

  switch (r) {
  case -1:
    exit (EXIT_FAILURE);
  case 1:
    printf ("File not changed.\n");
    break;
  default:
    /* Success. */
    break;
  }
}
Beispiel #2
0
value
virt_customize_edit_file_perl (value verbosev, value gv, value filev,
                               value exprv)
{
  CAMLparam4 (verbosev, gv, filev, exprv);
  int r;
  guestfs_h *g = Guestfs_val (gv);

  r = edit_file_perl (g, String_val (filev), String_val (exprv), NULL,
                      Bool_val (verbosev));
  if (r == -1)
    ocaml_guestfs_raise_error (g, "edit_file_perl");

  CAMLreturn (Val_unit);
}