Example #1
0
static bool
spl_save(GPtrArray *list, const char *utf8path, GError **error_r)
{
    FILE *file;

    assert(utf8path != NULL);

    if (spl_map(error_r) == NULL)
        return false;

    char *path_fs = spl_map_to_fs(utf8path, error_r);
    if (path_fs == NULL)
        return false;

    file = fopen(path_fs, "w");
    g_free(path_fs);
    if (file == NULL) {
        playlist_errno(error_r);
        return false;
    }

    for (unsigned i = 0; i < list->len; ++i) {
        const char *uri = g_ptr_array_index(list, i);
        playlist_print_uri(file, uri);
    }

    fclose(file);
    return true;
}
Example #2
0
static enum playlist_result
spl_save(GPtrArray *list, const char *utf8path)
{
	FILE *file;
	char *path_fs;

	assert(utf8path != NULL);

	path_fs = map_spl_utf8_to_fs(utf8path);
	if (path_fs == NULL)
		return PLAYLIST_RESULT_DISABLED;

	while (!(file = fopen(path_fs, "w")) && errno == EINTR);
	g_free(path_fs);
	if (file == NULL)
		return PLAYLIST_RESULT_ERRNO;

	for (unsigned i = 0; i < list->len; ++i) {
		const char *uri = g_ptr_array_index(list, i);
		playlist_print_uri(file, uri);
	}

	while (fclose(file) != 0 && errno == EINTR);
	return PLAYLIST_RESULT_SUCCESS;
}