Index: trunk/src_plugins/export_vfs_mc/export_vfs_mc.c =================================================================== --- trunk/src_plugins/export_vfs_mc/export_vfs_mc.c (revision 24000) +++ trunk/src_plugins/export_vfs_mc/export_vfs_mc.c (revision 24001) @@ -71,6 +71,34 @@ gds_uninit(&res); } +static void mc_copyin(const char *path) +{ + gds_t inp; + char buf[256]; + int len; + + gds_init(&inp); + while((len = read(0, buf, 256)) > 0) { + gds_append_len(&inp, buf, len); + if (inp.used > 1024*1024) { + fprintf(stderr, "Data too large\n"); + exit(1); + } + } + + if ((inp.used > 0) && (inp.array[inp.used-1] == '\n')) { + inp.used--; /* remove exactly one trailing newline */ + inp.array[inp.used] = '\0'; + } + + if (pcb_vfs_access(PCB, path, &inp, 1) != 0) { + fprintf(stderr, "Can not access that field for write\n"); + exit(1); + } + gds_uninit(&inp); + return pcb_save_pcb(PCB->Filename, NULL); +} + static void export_vfs_mc_do_export(pcb_hid_attr_val_t * options) { const char *cmd; @@ -86,6 +114,7 @@ cmd = options[HA_export_vfs_mc_cmd].str_value; if (strcmp(cmd, "list") == 0) mc_list(); else if (strcmp(cmd, "copyout") == 0) mc_copyout(options[HA_export_vfs_mc_qpath].str_value); + else if (strcmp(cmd, "copyin") == 0) mc_copyin(options[HA_export_vfs_mc_qpath].str_value); else { fprintf(stderr, "Unknown vfs_mc command: '%s'\n", cmd); exit(1); Index: trunk/src_plugins/export_vfs_mc/upcb =================================================================== --- trunk/src_plugins/export_vfs_mc/upcb (nonexistent) +++ trunk/src_plugins/export_vfs_mc/upcb (revision 24001) @@ -0,0 +1,29 @@ +#!/bin/sh + +# GNU mc VFS glue for printed circuit boards using pcb-rnd +# This file is placed in the public domain by the author, +# Tibor 'Igor2' Palinkas, in 2019. +# +# Install this file in /usr/lib/mc/extfs.d +# +# Then add this in mc.ext (e.g. in /etc/mc/mc.ext): +# +# # PCB files +# shell/.pcb +# Open=%cd %p/upcb:// +# + +PCBRND="pcb-rnd -x vfs_mc" + +cmd=$1 +shift 1 +case "$cmd" in + list) $PCBRND --cmd list "$1" ;; + copyout) $PCBRND --cmd copyout "$1" --qpath "$2" > $3;; + copyin) $PCBRND --cmd copyin "$1" --qpath "$2" < $3;; +# rm) +# rmdir) +# mkdir) + *) exit 1 ;; +esac +exit 0 Property changes on: trunk/src_plugins/export_vfs_mc/upcb ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property