# include "basic.h"

int file (int argc, char **argv) {
  
  /* usage: file (filename) [var] */

  int status, vstat;
  struct stat fstats;

  if (argc < 2) {
    gprint (GP_ERR, "USAGE: file (filename) [var]\n");
    return (FALSE);
  }

  status = stat (argv[1], &fstats);

  vstat = !status;

  if (argc == 3) {
      
    set_int_variable (argv[2], vstat);

  } else {

    gprint (GP_ERR, "file %s is ", argv[1]);
    if (!vstat) gprint (GP_ERR, "not ");
    gprint (GP_ERR, "found\n");
    
  }
  return (TRUE);
}

