コード例 #1
0
ファイル: storage.c プロジェクト: nttputus/blensor
static int bli_compare(struct direntry *entry1, struct direntry *entry2)
{
	/* type is equal to stat.st_mode */

	if (S_ISDIR(entry1->type)) {
		if (S_ISDIR(entry2->type)==0) return (-1);
	}
	else {
		if (S_ISDIR(entry2->type)) return (1);
	}
	if (S_ISREG(entry1->type)) {
		if (S_ISREG(entry2->type)==0) return (-1);
	}
	else {
		if (S_ISREG(entry2->type)) return (1);
	}
	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
	
	/* make sure "." and ".." are always first */
	if ( strcmp(entry1->relname, ".")==0 ) return (-1);
	if ( strcmp(entry2->relname, ".")==0 ) return (1);
	if ( strcmp(entry1->relname, "..")==0 ) return (-1);
	if ( strcmp(entry2->relname, "..")==0 ) return (1);

	return (BLI_natstrcmp(entry1->relname, entry2->relname));
}
コード例 #2
0
static int compare_size(const void *a1, const void *a2)	
{
	const struct direntry *entry1=a1, *entry2=a2;

	/* type is equal to stat.st_mode */

	if (S_ISDIR(entry1->type)) {
		if (S_ISDIR(entry2->type)==0) return (-1);
	}
	else {
		if (S_ISDIR(entry2->type)) return (1);
	}
	if (S_ISREG(entry1->type)) {
		if (S_ISREG(entry2->type)==0) return (-1);
	}
	else {
		if (S_ISREG(entry2->type)) return (1);
	}
	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);

	/* make sure "." and ".." are always first */
	if ( strcmp(entry1->relname, ".")==0 ) return (-1);
	if ( strcmp(entry2->relname, ".")==0 ) return (1);
	if ( strcmp(entry1->relname, "..")==0 ) return (-1);
	if ( strcmp(entry2->relname, "..")==0 ) return (1);
	
	if ( entry1->s.st_size < entry2->s.st_size) return 1;
	if ( entry1->s.st_size > entry2->s.st_size) return -1;
	else return BLI_natstrcmp(entry1->relname,entry2->relname);
}
コード例 #3
0
ファイル: storage.c プロジェクト: Eibriel/kiriblender
/*
 * Ordering function for sorting lists of files/directories. Returns -1 if
 * entry1 belongs before entry2, 0 if they are equal, 1 if they should be swapped.
 */
static int bli_compare(struct direntry *entry1, struct direntry *entry2)
{
	/* type is equal to stat.st_mode */

	/* directories come before non-directories */
	if (S_ISDIR(entry1->type)) {
		if (S_ISDIR(entry2->type) == 0) return (-1);
	}
	else {
		if (S_ISDIR(entry2->type)) return (1);
	}
	/* non-regular files come after regular files */
	if (S_ISREG(entry1->type)) {
		if (S_ISREG(entry2->type) == 0) return (-1);
	}
	else {
		if (S_ISREG(entry2->type)) return (1);
	}
	/* arbitrary, but consistent, ordering of different types of non-regular files */
	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);

	/* OK, now we know their S_IFMT fields are the same, go on to a name comparison */
	/* make sure "." and ".." are always first */
	if (strcmp(entry1->relname, ".") == 0) return (-1);
	if (strcmp(entry2->relname, ".") == 0) return (1);
	if (strcmp(entry1->relname, "..") == 0) return (-1);
	if (strcmp(entry2->relname, "..") == 0) return (1);

	return (BLI_natstrcmp(entry1->relname, entry2->relname));
}
コード例 #4
0
ファイル: filelist.c プロジェクト: bitfusionio/blender
static int compare_name(const void *a1, const void *a2)
{
	const struct direntry *entry1 = a1, *entry2 = a2;
	int ret;

	if ((ret = compare_direntry_generic(entry1, entry2))) {
		return ret;
	}

	return (BLI_natstrcmp(entry1->relname, entry2->relname));
}
コード例 #5
0
ファイル: filelist.c プロジェクト: bitfusionio/blender
static int compare_size(const void *a1, const void *a2)	
{
	const struct direntry *entry1 = a1, *entry2 = a2;
	int ret;

	if ((ret = compare_direntry_generic(entry1, entry2))) {
		return ret;
	}
	
	if (entry1->s.st_size < entry2->s.st_size) return 1;
	if (entry1->s.st_size > entry2->s.st_size) return -1;

	return BLI_natstrcmp(entry1->relname, entry2->relname);
}
コード例 #6
0
ファイル: node_templates.c プロジェクト: mgschwan/blensor
static int ui_node_item_name_compare(const void *a, const void *b)
{
	const bNodeType *type_a = *(const bNodeType **)a;
	const bNodeType *type_b = *(const bNodeType **)b;
	return BLI_natstrcmp(type_a->ui_name, type_b->ui_name);
}