Mapper.hxx 2.01 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2017 The Music Player Daemon Project
3
 * http://www.musicpd.org
4 5 6 7 8 9 10 11 12 13
 *
 * 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.
14 15 16 17
 *
 * 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.
18 19 20 21 22 23
 */

/*
 * Maps directory and song objects to file system paths.
 */

Max Kellermann's avatar
Max Kellermann committed
24 25
#ifndef MPD_MAPPER_HXX
#define MPD_MAPPER_HXX
26

27 28
#include <string>

29
#include "util/Compiler.h"
30

31
#define PLAYLIST_FILE_SUFFIX ".m3u"
32

Max Kellermann's avatar
Max Kellermann committed
33
class Path;
34
class AllocatedPath;
35

36
void
37
mapper_init(AllocatedPath &&playlist_dir);
38

39
void
40
mapper_finish() noexcept;
41

42 43
#ifdef ENABLE_DATABASE

44 45 46 47 48
/**
 * Determines the absolute file system path of a relative URI.  This
 * is basically done by converting the URI to the file system charset
 * and prepending the music directory.
 */
49
gcc_pure
50
AllocatedPath
51
map_uri_fs(const char *uri) noexcept;
52

53 54 55 56 57
/**
 * Maps a file system path (relative to the music directory or
 * absolute) to a relative path in UTF-8 encoding.
 *
 * @param path_fs a path in file system encoding
58 59
 * @return the relative path in UTF-8, or an empty string if mapping
 * failed
60
 */
61 62
gcc_pure
std::string
63
map_fs_to_utf8(Path path_fs) noexcept;
64

65 66
#endif

67 68 69
/**
 * Returns the playlist directory.
 */
70
gcc_const
71
const AllocatedPath &
72
map_spl_path() noexcept;
73 74 75

/**
 * Maps a playlist name (without the ".m3u" suffix) to a file system
76
 * path.
77
 *
Max Kellermann's avatar
Max Kellermann committed
78
 * @return the path in file system encoding, or nullptr if mapping failed
79
 */
80
gcc_pure
81
AllocatedPath
82
map_spl_utf8_to_fs(const char *name) noexcept;
83

84
#endif