/*
 * Monitor a file.
 *
 * Returns a Fam::Request object, which is used to identify the monitor
 * associated with events.
 *
 * Raises a Fam::Error exception if the file could not be monitored.
 *
 * Aliases:
 *   Fam::Connection#file
 *
 * Examples:
 *   req = fam.monitor_file '/var/log/messages'
 *
 */
static VALUE fam_conn_file(VALUE self, VALUE file)
{
  FAMConnection *conn;
  FAMRequest *req = NULL;
  int err;

  Data_Get_Struct(self, FAMConnection, conn);
  req = ALLOC(FAMRequest);
  FAMREQUEST_GETREQNUM(req) = (int) req;
  err = FAMMonitorFile(conn, RSTRING(file)->ptr, req, NULL);

  if (err == -1) {
    xfree(req);
    rb_raise(eError, "Couldn't monitor file \"%s\": %s",
             RSTRING(file)->ptr ? RSTRING(file)->ptr : "NULL", fam_error());
  }

  return wrap_req(req);
}