2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2021-01-01 19:54:25 +01:00
|
|
|
* Copyright 2003-2021 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2007-05-16 14:02:10 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2007-05-16 14:02:10 +02:00
|
|
|
*/
|
|
|
|
|
2012-09-28 00:40:00 +02:00
|
|
|
#ifndef MPD_PLAYLIST_FILE_HXX
|
|
|
|
#define MPD_PLAYLIST_FILE_HXX
|
2007-05-16 14:02:10 +02:00
|
|
|
|
2021-10-23 13:35:57 +02:00
|
|
|
#include "fs/AllocatedPath.hxx"
|
|
|
|
|
2012-09-27 23:48:29 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2018-07-17 22:31:33 +02:00
|
|
|
struct ConfigData;
|
2014-01-07 21:39:47 +01:00
|
|
|
class DetachedSong;
|
2014-02-03 23:30:34 +01:00
|
|
|
class SongLoader;
|
2013-01-04 00:02:09 +01:00
|
|
|
class PlaylistVector;
|
2012-09-27 23:48:29 +02:00
|
|
|
|
|
|
|
typedef std::vector<std::string> PlaylistFileContents;
|
|
|
|
|
2009-01-25 13:53:16 +01:00
|
|
|
extern bool playlist_saveAbsolutePaths;
|
|
|
|
|
2021-10-23 13:35:57 +02:00
|
|
|
class PlaylistFileEditor {
|
|
|
|
const AllocatedPath path;
|
|
|
|
|
|
|
|
PlaylistFileContents contents;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum class LoadMode {
|
|
|
|
NO,
|
|
|
|
YES,
|
|
|
|
TRY,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws on error.
|
|
|
|
*/
|
|
|
|
explicit PlaylistFileEditor(const char *name_utf8, LoadMode load_mode);
|
|
|
|
|
2021-10-25 08:43:42 +02:00
|
|
|
auto size() const noexcept {
|
|
|
|
return contents.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Insert(std::size_t i, const char *uri);
|
|
|
|
void Insert(std::size_t i, const DetachedSong &song);
|
|
|
|
|
2021-10-23 13:35:57 +02:00
|
|
|
void MoveIndex(unsigned src, unsigned dest);
|
|
|
|
void RemoveIndex(unsigned i);
|
|
|
|
|
|
|
|
void Save();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Load();
|
|
|
|
};
|
|
|
|
|
2009-01-25 13:53:16 +01:00
|
|
|
/**
|
|
|
|
* Perform some global initialization, e.g. load configuration values.
|
|
|
|
*/
|
|
|
|
void
|
2018-07-17 22:31:33 +02:00
|
|
|
spl_global_init(const ConfigData &config);
|
2009-01-25 13:53:16 +01:00
|
|
|
|
2009-01-25 14:19:28 +01:00
|
|
|
/**
|
|
|
|
* Determines whether the specified string is a valid name for a
|
|
|
|
* stored playlist.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
spl_valid_name(const char *name_utf8);
|
|
|
|
|
2015-03-24 20:40:35 +01:00
|
|
|
AllocatedPath
|
2015-12-26 06:30:25 +01:00
|
|
|
spl_map_to_fs(const char *name_utf8);
|
2015-03-24 20:40:35 +01:00
|
|
|
|
2008-10-22 19:15:50 +02:00
|
|
|
/**
|
2015-12-29 12:41:45 +01:00
|
|
|
* Returns a list of stored_playlist_info struct pointers.
|
2008-10-22 19:15:50 +02:00
|
|
|
*/
|
2013-01-04 00:02:09 +01:00
|
|
|
PlaylistVector
|
2015-12-29 12:41:45 +01:00
|
|
|
ListPlaylistFiles();
|
2008-10-22 19:15:50 +02:00
|
|
|
|
2015-12-28 07:22:10 +01:00
|
|
|
void
|
|
|
|
spl_clear(const char *utf8path);
|
2007-05-16 14:02:10 +02:00
|
|
|
|
2015-12-28 07:22:10 +01:00
|
|
|
void
|
|
|
|
spl_delete(const char *name_utf8);
|
2008-10-23 09:54:32 +02:00
|
|
|
|
2015-12-26 06:30:25 +01:00
|
|
|
void
|
|
|
|
spl_append_song(const char *utf8path, const DetachedSong &song);
|
2008-09-07 13:44:12 +02:00
|
|
|
|
2016-10-27 21:59:17 +02:00
|
|
|
/**
|
|
|
|
* Throws #std::runtime_error on error.
|
|
|
|
*/
|
|
|
|
void
|
2014-02-03 23:30:34 +01:00
|
|
|
spl_append_uri(const char *path_utf8,
|
2016-10-27 21:59:17 +02:00
|
|
|
const SongLoader &loader, const char *uri_utf8);
|
2008-10-22 17:23:11 +02:00
|
|
|
|
2015-12-28 07:22:10 +01:00
|
|
|
void
|
|
|
|
spl_rename(const char *utf8from, const char *utf8to);
|
2007-05-24 20:07:19 +02:00
|
|
|
|
2012-09-27 23:48:29 +02:00
|
|
|
#endif
|