MPD  0.20.6
StorageInterface.hxx
Go to the documentation of this file.
1 /*
2  * Copyright 2003-2017 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 #ifndef MPD_STORAGE_INTERFACE_HXX
21 #define MPD_STORAGE_INTERFACE_HXX
22 
23 #include "check.h"
24 #include "Compiler.h"
25 
26 #include <string>
27 
28 struct StorageFileInfo;
29 class AllocatedPath;
30 
32 public:
33  StorageDirectoryReader() = default;
36 
37  virtual const char *Read() = 0;
38 
42  gcc_pure
43  virtual StorageFileInfo GetInfo(bool follow) = 0;
44 };
45 
46 class Storage {
47 public:
48  Storage() = default;
49  Storage(const Storage &) = delete;
50  virtual ~Storage() {}
51 
55  gcc_pure
56  virtual StorageFileInfo GetInfo(const char *uri_utf8, bool follow) = 0;
57 
61  virtual StorageDirectoryReader *OpenDirectory(const char *uri_utf8) = 0;
62 
66  gcc_pure
67  virtual std::string MapUTF8(const char *uri_utf8) const = 0;
68 
74  gcc_pure
75  virtual AllocatedPath MapFS(const char *uri_utf8) const;
76 
77  gcc_pure
78  AllocatedPath MapChildFS(const char *uri_utf8,
79  const char *child_utf8) const;
80 
86  gcc_pure
87  virtual const char *MapToRelativeUTF8(const char *uri_utf8) const = 0;
88 };
89 
90 #endif
gcc_pure AllocatedPath MapChildFS(const char *uri_utf8, const char *child_utf8) const
Storage()=default
virtual StorageDirectoryReader * OpenDirectory(const char *uri_utf8)=0
Throws #std::runtime_error on error.
virtual const char * Read()=0
A path name in the native file system character set.
virtual gcc_pure std::string MapUTF8(const char *uri_utf8) const =0
Map the given relative URI to an absolute URI.
virtual gcc_pure const char * MapToRelativeUTF8(const char *uri_utf8) const =0
Check if the given URI points inside this storage.
virtual gcc_pure StorageFileInfo GetInfo(bool follow)=0
Throws #std::runtime_error on error.
virtual ~Storage()
virtual gcc_pure AllocatedPath MapFS(const char *uri_utf8) const
Map the given relative URI to a local file path.
StorageDirectoryReader()=default
virtual gcc_pure StorageFileInfo GetInfo(const char *uri_utf8, bool follow)=0
Throws #std::runtime_error on error.
#define gcc_pure
Definition: Compiler.h:116