static void r_core_file_info(RCore *core, int mode) {
	const char *fn = NULL;
	int dbg = r_config_get_i (core->config, "cfg.debug");
	bool io_cache = r_config_get_i (core->config, "io.cache");
	RBinInfo *info = r_bin_get_info (core->bin);
	RBinFile *binfile = r_core_bin_cur (core);
	RCoreFile *cf = core->file;
	RBinPlugin *plugin = r_bin_file_cur_plugin (binfile);
	if (mode == R_CORE_BIN_JSON) {
		r_cons_printf ("{");
	}
	if (mode == R_CORE_BIN_RADARE) {
		return;
	}
	if (mode == R_CORE_BIN_SIMPLE) {
		return;
	}
	if (info) {
		fn = info->file;
		if (mode == R_CORE_BIN_JSON) {
			r_cons_printf ("\"type\":\"%s\"", STR (info->type));
		}
	} else {
		fn = (cf && cf->desc)? cf->desc->name: NULL;
	}
	if (cf && mode == R_CORE_BIN_JSON) {
		const char *uri = fn;
		if (!uri) {
			if (cf->desc && cf->desc->uri && *cf->desc->uri) {
				uri = cf->desc->uri;
			} else {
				uri = "";
			}
		}
		{
			char *escapedFile = r_str_utf16_encode (uri, -1);
			r_cons_printf (",\"file\":\"%s\"", escapedFile);
			free (escapedFile);
		}
		if (dbg) {
			dbg = R_IO_WRITE | R_IO_EXEC;
		}
		if (cf->desc) {
			ut64 fsz = r_io_desc_size (core->io, cf->desc);
			r_cons_printf (",\"fd\":%d", cf->desc->fd);
			if (fsz != UT64_MAX) {
				r_cons_printf (",\"size\":%"PFMT64d, fsz);
				char *humansz = r_num_units (NULL, fsz);
				if (humansz) {
					r_cons_printf (",\"humansz\":\"%s\"", humansz);
					free (humansz);
				}
			}
			r_cons_printf (",\"iorw\":%s", r_str_bool ( io_cache ||\
					cf->desc->flags & R_IO_WRITE ));
			r_cons_printf (",\"mode\":\"%s\"", r_str_rwx_i (
					cf->desc->flags & 7 ));
			r_cons_printf (",\"obsz\":%"PFMT64d, (ut64) core->io->desc->obsz);
			if (cf->desc->referer && *cf->desc->referer) {
				r_cons_printf (",\"referer\":\"%s\"", cf->desc->referer);
			}
		}
		r_cons_printf (",\"block\":%d", core->blocksize);
		if (binfile) {
			if (binfile->curxtr) {
				r_cons_printf (",\"packet\":\"%s\"",
					binfile->curxtr->name);
			}
			if (plugin) {
				r_cons_printf (",\"format\":\"%s\"",
					plugin->name);
			}
		}
		r_cons_printf ("}");
	} else if (cf && mode != R_CORE_BIN_SIMPLE) {
		//r_cons_printf ("# Core file info\n");
		if (dbg) {
			dbg = R_IO_WRITE | R_IO_EXEC;
		}
		if (cf->desc) {
			pair ("blksz", sdb_fmt (0, "0x%"PFMT64x, (ut64) core->io->desc->obsz));
		}
		pair ("block", sdb_fmt (0, "0x%x", core->blocksize));
		if (cf->desc) {
			pair ("fd", sdb_fmt (0, "%d", cf->desc->fd));
		}
		if (fn || (cf->desc && cf->desc->uri)) {
			pair ("file", fn? fn: cf->desc->uri);
		}
		if (plugin) {
			pair ("format", plugin->name);
		}
		if (cf->desc) {
			pair ("iorw", r_str_bool (io_cache || cf->desc->flags & R_IO_WRITE ));
			pair ("mode", r_str_rwx_i (cf->desc->flags & 7));
		}
		if (binfile && binfile->curxtr) {
			pair ("packet", binfile->curxtr->name);
		}
		if (cf->desc && cf->desc->referer && *cf->desc->referer) {
			pair ("referer", cf->desc->referer);
		}
		if (cf->desc) {
			ut64 fsz = r_io_desc_size (core->io, cf->desc);
			if (fsz != UT64_MAX) {
				pair ("size", sdb_fmt (0,"0x%"PFMT64x, fsz));
				char *humansz = r_num_units (NULL, fsz);
				if (humansz) {
					pair ("humansz", humansz);
					free (humansz);
				}
			}
		}
		if (info) {
			pair ("type", info->type);
		}
	}
}