1 /* 2 * Copyright 2003-2021 The Music Player Daemon Project 3 * http://www.musicpd.org 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 /* 21 * Maps directory and song objects to file system paths. 22 */ 23 24 #ifndef MPD_MAPPER_HXX 25 #define MPD_MAPPER_HXX 26 27 #include "config.h" 28 29 #include <string> 30 31 #define PLAYLIST_FILE_SUFFIX ".m3u" 32 33 class Path; 34 class AllocatedPath; 35 36 void 37 mapper_init(AllocatedPath &&playlist_dir); 38 39 #ifdef ENABLE_DATABASE 40 41 /** 42 * Determines the absolute file system path of a relative URI. This 43 * is basically done by converting the URI to the file system charset 44 * and prepending the music directory. 45 */ 46 [[gnu::pure]] 47 AllocatedPath 48 map_uri_fs(const char *uri) noexcept; 49 50 /** 51 * Maps a file system path (relative to the music directory or 52 * absolute) to a relative path in UTF-8 encoding. 53 * 54 * @param path_fs a path in file system encoding 55 * @return the relative path in UTF-8, or an empty string if mapping 56 * failed 57 */ 58 [[gnu::pure]] 59 std::string 60 map_fs_to_utf8(Path path_fs) noexcept; 61 62 #endif 63 64 /** 65 * Returns the playlist directory. 66 */ 67 [[gnu::const]] 68 const AllocatedPath & 69 map_spl_path() noexcept; 70 71 /** 72 * Maps a playlist name (without the ".m3u" suffix) to a file system 73 * path. 74 * 75 * @return the path in file system encoding, or nullptr if mapping failed 76 */ 77 [[gnu::pure]] 78 AllocatedPath 79 map_spl_utf8_to_fs(const char *name) noexcept; 80 81 #endif 82