Mapper.hxx 2 KB
Newer Older
1
/*
2
 * Copyright 2003-2018 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
#include "util/Compiler.h"
28 29 30
#include "config.h"

#include <string>
31

32
#define PLAYLIST_FILE_SUFFIX ".m3u"
33

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

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

40 41
#ifdef ENABLE_DATABASE

42 43 44 45 46
/**
 * 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.
 */
47
gcc_pure
48
AllocatedPath
49
map_uri_fs(const char *uri) noexcept;
50

51 52 53 54 55
/**
 * 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
56 57
 * @return the relative path in UTF-8, or an empty string if mapping
 * failed
58
 */
59 60
gcc_pure
std::string
61
map_fs_to_utf8(Path path_fs) noexcept;
62

63 64
#endif

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

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

82
#endif