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

static int init_files ( const char *  filename  )  [static]

Initialize the files

Parameters:
filename base name for the output file
Returns:
0 on success;
1 on out of memory;
2 if the input file could not be opened

Definition at line 84 of file disk2zip.c.

References fname, infile, inname, outname, and PATH_SEPARATOR.

Referenced by main().

{
  int i = strlen (filename);

  /* allocate memory for the output filenames */

  if (!(outname = (char*) malloc (i + 3)))
    return 1;

  /* copy the base filename */

  memcpy (outname, filename, i + 1);

  /* modify the filename */

  for (fname = outname + i;
       fname > outname && *fname != PATH_SEPARATOR; fname--);
  if (fname > outname)
    fname++;
  fname[1] = '!';
  memcpy (fname + 2, filename + (fname - outname), i);

  /* try to open the input file */

  return (!infile && !(infile = fopen (inname, "rb"))) ? 2 : 0;
}


Generated by  Doxygen 1.6.0   Back to index