MPD  0.20.18
Walk.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_UPDATE_WALK_HXX
21 #define MPD_UPDATE_WALK_HXX
22 
23 #include "check.h"
24 #include "Editor.hxx"
25 #include "Compiler.h"
26 
27 struct StorageFileInfo;
28 struct Directory;
29 struct ArchivePlugin;
30 class ArchiveFile;
31 class Storage;
32 class ExcludeList;
33 
34 class UpdateWalk final {
35 #ifdef ENABLE_ARCHIVE
36  friend class UpdateArchiveVisitor;
37 #endif
38 
39 #ifndef _WIN32
40  static constexpr bool DEFAULT_FOLLOW_INSIDE_SYMLINKS = true;
41  static constexpr bool DEFAULT_FOLLOW_OUTSIDE_SYMLINKS = true;
42 
43  bool follow_inside_symlinks;
44  bool follow_outside_symlinks;
45 #endif
46 
47  bool walk_discard;
48  bool modified;
49 
55  volatile bool cancel;
56 
58 
59  DatabaseEditor editor;
60 
61 public:
62  UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
63  Storage &_storage);
64 
69  void Cancel() {
70  cancel = true;
71  }
72 
76  bool Walk(Directory &root, const char *path, bool discard);
77 
78 private:
79  gcc_pure
80  bool SkipSymlink(const Directory *directory,
81  const char *utf8_name) const noexcept;
82 
83  void RemoveExcludedFromDirectory(Directory &directory,
84  const ExcludeList &exclude_list);
85 
86  void PurgeDeletedFromDirectory(Directory &directory);
87 
88  void UpdateSongFile2(Directory &directory,
89  const char *name, const char *suffix,
90  const StorageFileInfo &info);
91 
92  bool UpdateSongFile(Directory &directory,
93  const char *name, const char *suffix,
94  const StorageFileInfo &info);
95 
96  bool UpdateContainerFile(Directory &directory,
97  const char *name, const char *suffix,
98  const StorageFileInfo &info);
99 
100 
101 #ifdef ENABLE_ARCHIVE
102  void UpdateArchiveTree(ArchiveFile &archive, Directory &parent,
103  const char *name);
104 
105  bool UpdateArchiveFile(Directory &directory,
106  const char *name, const char *suffix,
107  const StorageFileInfo &info);
108 
109  void UpdateArchiveFile(Directory &directory, const char *name,
110  const StorageFileInfo &info,
111  const ArchivePlugin &plugin);
112 
113 
114 #else
115  bool UpdateArchiveFile(gcc_unused Directory &directory,
116  gcc_unused const char *name,
117  gcc_unused const char *suffix,
118  gcc_unused const StorageFileInfo &info) {
119  return false;
120  }
121 #endif
122 
123  bool UpdatePlaylistFile(Directory &directory,
124  const char *name, const char *suffix,
125  const StorageFileInfo &info);
126 
127  bool UpdateRegularFile(Directory &directory,
128  const char *name, const StorageFileInfo &info);
129 
130  void UpdateDirectoryChild(Directory &directory,
131  const ExcludeList &exclude_list,
132  const char *name,
133  const StorageFileInfo &info);
134 
135  bool UpdateDirectory(Directory &directory,
136  const ExcludeList &exclude_list,
137  const StorageFileInfo &info);
138 
147  Directory *MakeDirectoryIfModified(Directory &parent, const char *name,
148  const StorageFileInfo &info);
149 
150  Directory *DirectoryMakeChildChecked(Directory &parent,
151  const char *uri_utf8,
152  const char *name_utf8);
153 
154  Directory *DirectoryMakeUriParentChecked(Directory &root,
155  const char *uri);
156 
157  void UpdateUri(Directory &root, const char *uri);
158 };
159 
160 #endif
An event loop that polls for events on file/socket descriptors.
Definition: Loop.hxx:52
An object that listens to events from the Database.
void Cancel()
Cancel the current update and quit the Walk() method as soon as possible.
Definition: Walk.hxx:69
const Storage & storage
#define gcc_unused
Definition: Compiler.h:118
UpdateWalk(EventLoop &_loop, DatabaseListener &_listener, Storage &_storage)
#define gcc_pure
Definition: Compiler.h:116
const Storage const char * uri
bool Walk(Directory &root, const char *path, bool discard)
Returns true if the database was modified.
const Partition const char * name
Definition: Count.hxx:34