コード例 #1
0
ファイル: lscolors.c プロジェクト: wmene/yafc-1.1.2
void rfile_parse_colors(rfile *f)
{
	char *e, *q;
	int i;

	/* colors should already been initialized by init_colors */

	e = 0;
	if(risdir(f))
		e = diclr;
	else if(rislink(f))
		e = lnclr;
	else if(rischardev(f))
		e = cdclr;
	else if(risblockdev(f))
		e = bdclr;
	else if(rispipe(f))
		e = piclr;
	else if(rissock(f))
		e = soclr;

	/* do this before checking for executable, because
	 * on [v]fat filesystems, all files are 'executable'
	 */
	for(i=0;i<number_of_colors && !e;i++) {
		if(fnmatch(clrs[i].msk, base_name_ptr(f->path), 0) == 0)
			e = clrs[i].clr;
	}

	/* a file is considered executable if there is
	 * an 'x' anywhere in its permission string */
	if(!e && risexec(f))
		e = exclr;

	q = e ? e : ficlr;
	f->color = (char *)xmalloc(strlen(lc) + strlen(q) + strlen(rc) + 1);
	sprintf(f->color, "%s%s%s", lc, q, rc);
}
コード例 #2
0
ファイル: rfile.c プロジェクト: Celelibi/yafc
bool risreg(const rfile *f)
{
    return !(risdir(f) || rispipe(f) || rischardev(f) || risblockdev(f));
}