예제 #1
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_add(const char *spath, const char *lpath)
{
	struct music_file *n;
	struct music_file **tmp;
	int count;

	if (spath == NULL || lpath == NULL)
		return -EINVAL;

	if (!fs_is_music(spath, lpath))
		return -EINVAL;

	tmp = &g_music_files;
	count = 0;

	while (*tmp) {
		if (!strcmp((*tmp)->shortpath->ptr, spath) &&
			!strcmp((*tmp)->longpath->ptr, lpath)) {
			return -EBUSY;
		}
		tmp = &(*tmp)->next;
		count++;
	}

	n = new_music_file(spath, lpath);
	if (n != NULL)
		*tmp = n;
	else
		return -ENOMEM;
	music_lock();
	rebuild_shuffle_data();
	music_unlock();
	return count;
}
예제 #2
0
extern t_fs_filetype fs_file_get_type(const char *filename)
{
	const char *ext = utils_fileext(filename);
	t_fs_filetype_entry *entry = ft_table;
	t_fs_specfiletype_entry *entry2 = ft_spec_table;

	if (ext) {
		while (entry->ext != NULL) {
			if (stricmp(ext, entry->ext) == 0)
				return entry->ft;
			entry++;
		}
	}

	while (entry2->fname != NULL) {
		const char *shortname = strrchr(filename, '/');

		if (!shortname)
			shortname = filename;
		else
			shortname++;
		if (stricmp(shortname, entry2->fname) == 0)
			return entry2->ft;
		entry2++;
	}

#ifdef ENABLE_MUSIC
	if (fs_is_music(filename, filename)) {
		return fs_filetype_music;
	}
#endif

	return fs_filetype_unknown;
}
예제 #3
0
int music_add(const char *spath, const char *lpath)
{
	int pos;

	if (spath == NULL || lpath == NULL)
		return -EINVAL;

	if (!fs_is_music(spath, lpath))
		return -EINVAL;

	pos = music_find(spath, lpath);

	if (pos >= 0) {
		return -1;
	}

	return musiclist_add(&g_music_list, spath, lpath);
}
예제 #4
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_add_dir(const char *spath, const char *lpath)
{
	p_fat_info info;
	dword i, count;

	if (spath == NULL || lpath == NULL)
		return -EINVAL;

	count = fat_readdir(lpath, (char *) spath, &info);

	if (count == INVALID)
		return -EBADF;
	for (i = 0; i < count; i++) {
		char sfn[PATH_MAX];
		char lfn[PATH_MAX];
		
		if ((info[i].attr & FAT_FILEATTR_DIRECTORY) > 0) {
			char lpath2[PATH_MAX], spath2[PATH_MAX];

			if (info[i].filename[0] == '.')
				continue;

			SPRINTF_S(lpath2, "%s%s/", lpath, info[i].longname);
			SPRINTF_S(spath2, "%s%s/", spath, info[i].filename);
			music_add_dir(spath2, lpath2);
			continue;
		}

		if (fs_is_music(info[i].filename, info[i].longname) == false)
			continue;

		SPRINTF_S(sfn, "%s%s", spath, info[i].filename);
		SPRINTF_S(lfn, "%s%s", lpath, info[i].longname);
		music_add(sfn, lfn);
	}
	free((void *) info);

	return 0;
}