Logo Search packages:      
Sourcecode: cbmlink version File versions  Download package

static int drive_image_write ( const char *  cmd,
const char *  filename 
) [static]

copy a file to a disk accessible by the remote host

cmd the -dr command
filename name of the file to be saved, "-" for stdout
zero on success, nonzero on error

output file

drive unit

start and end track

Definition at line 722 of file cbmlink.c.

References buffer, device, disk_install(), disk_params(), disk_remove(), disk_write(), and interleave.

Referenced by main().

  /** output file */
  FILE* f;
  /** drive unit */
  unsigned unit;
  /** start and end track */
  unsigned track, track_end;

  if (disk_params (cmd, &unit, &track, &track_end))
    return -1;

  f = *filename == '-' && !filename[1] ? stdin : fopen (filename, "rb");
  if (!f) {
    fputs (filename, stderr), perror (": fopen(reading)");
    return -2;

  if (disk_install (comm, hostinfo, device)) {
    fputs ("disk: installation failed\n", stderr);
    if (f != stdout) fclose (f);
    return 2;

  if (disk_write (comm, unit, interleave, track, track_end, f, buffer)) {
    fputs ("disk: write failed\n", stderr);
    if (f != stdout)
      fclose (f);
    if (disk_remove (comm)) {
      fputs ("disk: removal failed\n", stderr);
      return 2;
    return 1;

  if (disk_remove (comm))
    goto diskRemove;

  return 0;

Generated by  Doxygen 1.6.0   Back to index