Commit 3e8047e5 authored by Max Kellermann's avatar Max Kellermann

Directory: rename struct directory to Directory

parent 440ac51c
...@@ -109,7 +109,7 @@ db_is_simple(void) ...@@ -109,7 +109,7 @@ db_is_simple(void)
return is_simple; return is_simple;
} }
struct directory * Directory *
db_get_root(void) db_get_root(void)
{ {
assert(db != NULL); assert(db != NULL);
...@@ -118,13 +118,13 @@ db_get_root(void) ...@@ -118,13 +118,13 @@ db_get_root(void)
return ((SimpleDatabase *)db)->GetRoot(); return ((SimpleDatabase *)db)->GetRoot();
} }
struct directory * Directory *
db_get_directory(const char *name) db_get_directory(const char *name)
{ {
if (db == NULL) if (db == NULL)
return NULL; return NULL;
struct directory *music_root = db_get_root(); Directory *music_root = db_get_root();
if (name == NULL) if (name == NULL)
return music_root; return music_root;
......
...@@ -38,7 +38,7 @@ extern "C" { ...@@ -38,7 +38,7 @@ extern "C" {
#include <functional> #include <functional>
static bool static bool
PrintDirectory(struct client *client, const directory &directory) PrintDirectory(struct client *client, const Directory &directory)
{ {
if (!directory.IsRoot()) if (!directory.IsRoot())
client_printf(client, "directory: %s\n", directory.GetPath()); client_printf(client, "directory: %s\n", directory.GetPath());
...@@ -48,7 +48,7 @@ PrintDirectory(struct client *client, const directory &directory) ...@@ -48,7 +48,7 @@ PrintDirectory(struct client *client, const directory &directory)
static void static void
print_playlist_in_directory(struct client *client, print_playlist_in_directory(struct client *client,
const directory &directory, const Directory &directory,
const char *name_utf8) const char *name_utf8)
{ {
if (directory.IsRoot()) if (directory.IsRoot())
...@@ -89,7 +89,7 @@ PrintSongFull(struct client *client, song &song) ...@@ -89,7 +89,7 @@ PrintSongFull(struct client *client, song &song)
static bool static bool
PrintPlaylistBrief(struct client *client, PrintPlaylistBrief(struct client *client,
const PlaylistInfo &playlist, const PlaylistInfo &playlist,
const directory &directory) const Directory &directory)
{ {
print_playlist_in_directory(client, directory, playlist.name.c_str()); print_playlist_in_directory(client, directory, playlist.name.c_str());
return true; return true;
...@@ -98,7 +98,7 @@ PrintPlaylistBrief(struct client *client, ...@@ -98,7 +98,7 @@ PrintPlaylistBrief(struct client *client,
static bool static bool
PrintPlaylistFull(struct client *client, PrintPlaylistFull(struct client *client,
const PlaylistInfo &playlist, const PlaylistInfo &playlist,
const directory &directory) const Directory &directory)
{ {
print_playlist_in_directory(client, directory, playlist.name.c_str()); print_playlist_in_directory(client, directory, playlist.name.c_str());
......
...@@ -58,7 +58,7 @@ db_quark(void) ...@@ -58,7 +58,7 @@ db_quark(void)
} }
void void
db_save_internal(FILE *fp, const struct directory *music_root) db_save_internal(FILE *fp, const Directory *music_root)
{ {
assert(music_root != NULL); assert(music_root != NULL);
...@@ -77,7 +77,7 @@ db_save_internal(FILE *fp, const struct directory *music_root) ...@@ -77,7 +77,7 @@ db_save_internal(FILE *fp, const struct directory *music_root)
} }
bool bool
db_load_internal(FILE *fp, struct directory *music_root, GError **error) db_load_internal(FILE *fp, Directory *music_root, GError **error)
{ {
GString *buffer = g_string_sized_new(1024); GString *buffer = g_string_sized_new(1024);
char *line; char *line;
......
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
#include <stdio.h> #include <stdio.h>
struct directory; struct Directory;
void void
db_save_internal(FILE *file, const struct directory *root); db_save_internal(FILE *file, const Directory *root);
bool bool
db_load_internal(FILE *file, struct directory *root, GError **error); db_load_internal(FILE *file, Directory *root, GError **error);
#endif #endif
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <stdbool.h> #include <stdbool.h>
struct config_param; struct config_param;
struct directory; struct Directory;
struct db_selection; struct db_selection;
struct db_visitor; struct db_visitor;
...@@ -47,7 +47,7 @@ db_is_simple(void); ...@@ -47,7 +47,7 @@ db_is_simple(void);
* May only be used if db_is_simple() returns true. * May only be used if db_is_simple() returns true.
*/ */
gcc_pure gcc_pure
struct directory * Directory *
db_get_root(void); db_get_root(void);
/** /**
...@@ -55,7 +55,7 @@ db_get_root(void); ...@@ -55,7 +55,7 @@ db_get_root(void);
*/ */
gcc_nonnull(1) gcc_nonnull(1)
gcc_pure gcc_pure
struct directory * Directory *
db_get_directory(const char *name); db_get_directory(const char *name);
/** /**
......
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
#include <functional> #include <functional>
struct directory; struct Directory;
struct song; struct song;
struct PlaylistInfo; struct PlaylistInfo;
typedef std::function<bool(const directory &, GError **)> VisitDirectory; typedef std::function<bool(const Directory &, GError **)> VisitDirectory;
typedef std::function<bool(struct song &, GError **)> VisitSong; typedef std::function<bool(struct song &, GError **)> VisitSong;
typedef std::function<bool(const PlaylistInfo &, const directory &, typedef std::function<bool(const PlaylistInfo &, const Directory &,
GError **)> VisitPlaylist; GError **)> VisitPlaylist;
typedef std::function<bool(const char *, GError **)> VisitString; typedef std::function<bool(const char *, GError **)> VisitString;
......
...@@ -36,16 +36,16 @@ extern "C" { ...@@ -36,16 +36,16 @@ extern "C" {
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
static directory * static Directory *
directory_allocate(const char *path) directory_allocate(const char *path)
{ {
assert(path != NULL); assert(path != NULL);
const size_t path_size = strlen(path) + 1; const size_t path_size = strlen(path) + 1;
directory *directory = Directory *directory =
(struct directory *)g_malloc0(sizeof(*directory) (Directory *)g_malloc0(sizeof(*directory)
- sizeof(directory->path) - sizeof(directory->path)
+ path_size); + path_size);
INIT_LIST_HEAD(&directory->children); INIT_LIST_HEAD(&directory->children);
INIT_LIST_HEAD(&directory->songs); INIT_LIST_HEAD(&directory->songs);
INIT_LIST_HEAD(&directory->playlists); INIT_LIST_HEAD(&directory->playlists);
...@@ -55,13 +55,13 @@ directory_allocate(const char *path) ...@@ -55,13 +55,13 @@ directory_allocate(const char *path)
return directory; return directory;
} }
struct directory * Directory *
directory::NewGeneric(const char *path, struct directory *parent) Directory::NewGeneric(const char *path, Directory *parent)
{ {
assert(path != NULL); assert(path != NULL);
assert((*path == 0) == (parent == NULL)); assert((*path == 0) == (parent == NULL));
directory *directory = directory_allocate(path); Directory *directory = directory_allocate(path);
directory->parent = parent; directory->parent = parent;
...@@ -69,7 +69,7 @@ directory::NewGeneric(const char *path, struct directory *parent) ...@@ -69,7 +69,7 @@ directory::NewGeneric(const char *path, struct directory *parent)
} }
void void
directory::Free() Directory::Free()
{ {
playlist_vector_deinit(&playlists); playlist_vector_deinit(&playlists);
...@@ -77,7 +77,7 @@ directory::Free() ...@@ -77,7 +77,7 @@ directory::Free()
directory_for_each_song_safe(song, ns, this) directory_for_each_song_safe(song, ns, this)
song_free(song); song_free(song);
struct directory *child, *n; Directory *child, *n;
directory_for_each_child_safe(child, n, this) directory_for_each_child_safe(child, n, this)
child->Free(); child->Free();
...@@ -85,7 +85,7 @@ directory::Free() ...@@ -85,7 +85,7 @@ directory::Free()
} }
void void
directory::Delete() Directory::Delete()
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(parent != nullptr); assert(parent != nullptr);
...@@ -95,7 +95,7 @@ directory::Delete() ...@@ -95,7 +95,7 @@ directory::Delete()
} }
const char * const char *
directory::GetName() const Directory::GetName() const
{ {
assert(!IsRoot()); assert(!IsRoot());
assert(path != nullptr); assert(path != nullptr);
...@@ -108,8 +108,8 @@ directory::GetName() const ...@@ -108,8 +108,8 @@ directory::GetName() const
: path; : path;
} }
struct directory * Directory *
directory::CreateChild(const char *name_utf8) Directory::CreateChild(const char *name_utf8)
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(name_utf8 != NULL); assert(name_utf8 != NULL);
...@@ -126,19 +126,19 @@ directory::CreateChild(const char *name_utf8) ...@@ -126,19 +126,19 @@ directory::CreateChild(const char *name_utf8)
path_utf8 = allocated; path_utf8 = allocated;
} }
directory *child = NewGeneric(path_utf8, this); Directory *child = NewGeneric(path_utf8, this);
g_free(allocated); g_free(allocated);
list_add_tail(&child->siblings, &children); list_add_tail(&child->siblings, &children);
return child; return child;
} }
const directory * const Directory *
directory::FindChild(const char *name) const Directory::FindChild(const char *name) const
{ {
assert(holding_db_lock()); assert(holding_db_lock());
const struct directory *child; const Directory *child;
directory_for_each_child(child, this) directory_for_each_child(child, this)
if (strcmp(child->GetName(), name) == 0) if (strcmp(child->GetName(), name) == 0)
return child; return child;
...@@ -147,11 +147,11 @@ directory::FindChild(const char *name) const ...@@ -147,11 +147,11 @@ directory::FindChild(const char *name) const
} }
void void
directory::PruneEmpty() Directory::PruneEmpty()
{ {
assert(holding_db_lock()); assert(holding_db_lock());
struct directory *child, *n; Directory *child, *n;
directory_for_each_child_safe(child, n, this) { directory_for_each_child_safe(child, n, this) {
child->PruneEmpty(); child->PruneEmpty();
...@@ -160,8 +160,8 @@ directory::PruneEmpty() ...@@ -160,8 +160,8 @@ directory::PruneEmpty()
} }
} }
struct directory * Directory *
directory::LookupDirectory(const char *uri) Directory::LookupDirectory(const char *uri)
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(uri != NULL); assert(uri != NULL);
...@@ -171,7 +171,7 @@ directory::LookupDirectory(const char *uri) ...@@ -171,7 +171,7 @@ directory::LookupDirectory(const char *uri)
char *duplicated = g_strdup(uri), *name = duplicated; char *duplicated = g_strdup(uri), *name = duplicated;
struct directory *d = this; Directory *d = this;
while (1) { while (1) {
char *slash = strchr(name, '/'); char *slash = strchr(name, '/');
if (slash == name) { if (slash == name) {
...@@ -195,7 +195,7 @@ directory::LookupDirectory(const char *uri) ...@@ -195,7 +195,7 @@ directory::LookupDirectory(const char *uri)
} }
void void
directory::AddSong(struct song *song) Directory::AddSong(struct song *song)
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(song != NULL); assert(song != NULL);
...@@ -205,7 +205,7 @@ directory::AddSong(struct song *song) ...@@ -205,7 +205,7 @@ directory::AddSong(struct song *song)
} }
void void
directory::RemoveSong(struct song *song) Directory::RemoveSong(struct song *song)
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(song != NULL); assert(song != NULL);
...@@ -215,7 +215,7 @@ directory::RemoveSong(struct song *song) ...@@ -215,7 +215,7 @@ directory::RemoveSong(struct song *song)
} }
const song * const song *
directory::FindSong(const char *name_utf8) const Directory::FindSong(const char *name_utf8) const
{ {
assert(holding_db_lock()); assert(holding_db_lock());
assert(name_utf8 != NULL); assert(name_utf8 != NULL);
...@@ -232,7 +232,7 @@ directory::FindSong(const char *name_utf8) const ...@@ -232,7 +232,7 @@ directory::FindSong(const char *name_utf8) const
} }
struct song * struct song *
directory::LookupSong(const char *uri) Directory::LookupSong(const char *uri)
{ {
char *duplicated, *base; char *duplicated, *base;
...@@ -242,7 +242,7 @@ directory::LookupSong(const char *uri) ...@@ -242,7 +242,7 @@ directory::LookupSong(const char *uri)
duplicated = g_strdup(uri); duplicated = g_strdup(uri);
base = strrchr(duplicated, '/'); base = strrchr(duplicated, '/');
struct directory *d = this; Directory *d = this;
if (base != NULL) { if (base != NULL) {
*base++ = 0; *base++ = 0;
d = d->LookupDirectory(duplicated); d = d->LookupDirectory(duplicated);
...@@ -265,26 +265,26 @@ static int ...@@ -265,26 +265,26 @@ static int
directory_cmp(G_GNUC_UNUSED void *priv, directory_cmp(G_GNUC_UNUSED void *priv,
struct list_head *_a, struct list_head *_b) struct list_head *_a, struct list_head *_b)
{ {
const struct directory *a = (const struct directory *)_a; const Directory *a = (const Directory *)_a;
const struct directory *b = (const struct directory *)_b; const Directory *b = (const Directory *)_b;
return g_utf8_collate(a->path, b->path); return g_utf8_collate(a->path, b->path);
} }
void void
directory::Sort() Directory::Sort()
{ {
assert(holding_db_lock()); assert(holding_db_lock());
list_sort(NULL, &children, directory_cmp); list_sort(NULL, &children, directory_cmp);
song_list_sort(&songs); song_list_sort(&songs);
struct directory *child; Directory *child;
directory_for_each_child(child, this) directory_for_each_child(child, this)
child->Sort(); child->Sort();
} }
bool bool
directory::Walk(bool recursive, const SongFilter *filter, Directory::Walk(bool recursive, const SongFilter *filter,
VisitDirectory visit_directory, VisitSong visit_song, VisitDirectory visit_directory, VisitSong visit_song,
VisitPlaylist visit_playlist, VisitPlaylist visit_playlist,
GError **error_r) const GError **error_r) const
...@@ -306,7 +306,7 @@ directory::Walk(bool recursive, const SongFilter *filter, ...@@ -306,7 +306,7 @@ directory::Walk(bool recursive, const SongFilter *filter,
return false; return false;
} }
struct directory *child; Directory *child;
directory_for_each_child(child, this) { directory_for_each_child(child, this) {
if (visit_directory && if (visit_directory &&
!visit_directory(*child, error_r)) !visit_directory(*child, error_r))
......
...@@ -54,7 +54,7 @@ struct song; ...@@ -54,7 +54,7 @@ struct song;
struct db_visitor; struct db_visitor;
class SongFilter; class SongFilter;
struct directory { struct Directory {
/** /**
* Pointers to the siblings of this directory within the * Pointers to the siblings of this directory within the
* parent directory. It is unused (undefined) in the root * parent directory. It is unused (undefined) in the root
...@@ -83,7 +83,7 @@ struct directory { ...@@ -83,7 +83,7 @@ struct directory {
struct list_head playlists; struct list_head playlists;
struct directory *parent; Directory *parent;
time_t mtime; time_t mtime;
ino_t inode; ino_t inode;
dev_t device; dev_t device;
...@@ -91,53 +91,53 @@ struct directory { ...@@ -91,53 +91,53 @@ struct directory {
char path[sizeof(long)]; char path[sizeof(long)];
/** /**
* Generic constructor for #directory object. * Generic constructor for #Directory object.
*/ */
gcc_malloc gcc_malloc
static directory *NewGeneric(const char *path_utf8, directory *parent); static Directory *NewGeneric(const char *path_utf8, Directory *parent);
/** /**
* Create a new root #directory object. * Create a new root #Directory object.
*/ */
gcc_malloc gcc_malloc
static directory *NewRoot() { static Directory *NewRoot() {
return NewGeneric("", nullptr); return NewGeneric("", nullptr);
} }
/** /**
* Free this #directory object (and the whole object tree within it), * Free this #Directory object (and the whole object tree within it),
* assuming it was already removed from the parent. * assuming it was already removed from the parent.
*/ */
void Free(); void Free();
/** /**
* Remove this #directory object from its parent and free it. This * Remove this #Directory object from its parent and free it. This
* must not be called with the root directory. * must not be called with the root Directory.
* *
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
void Delete(); void Delete();
/** /**
* Create a new #directory object as a child of the given one. * Create a new #Directory object as a child of the given one.
* *
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
* *
* @param name_utf8 the UTF-8 encoded name of the new sub directory * @param name_utf8 the UTF-8 encoded name of the new sub directory
*/ */
gcc_malloc gcc_malloc
directory *CreateChild(const char *name_utf8); Directory *CreateChild(const char *name_utf8);
/** /**
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
gcc_pure gcc_pure
const directory *FindChild(const char *name) const; const Directory *FindChild(const char *name) const;
gcc_pure gcc_pure
directory *FindChild(const char *name) { Directory *FindChild(const char *name) {
const directory *cthis = this; const Directory *cthis = this;
return const_cast<directory *>(cthis->FindChild(name)); return const_cast<Directory *>(cthis->FindChild(name));
} }
/** /**
...@@ -146,8 +146,8 @@ struct directory { ...@@ -146,8 +146,8 @@ struct directory {
* *
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
struct directory *MakeChild(const char *name_utf8) { Directory *MakeChild(const char *name_utf8) {
struct directory *child = FindChild(name_utf8); Directory *child = FindChild(name_utf8);
if (child == nullptr) if (child == nullptr)
child = CreateChild(name_utf8); child = CreateChild(name_utf8);
return child; return child;
...@@ -157,10 +157,10 @@ struct directory { ...@@ -157,10 +157,10 @@ struct directory {
* Looks up a directory by its relative URI. * Looks up a directory by its relative URI.
* *
* @param uri the relative URI * @param uri the relative URI
* @return the directory, or NULL if none was found * @return the Directory, or NULL if none was found
*/ */
gcc_pure gcc_pure
directory *LookupDirectory(const char *uri); Directory *LookupDirectory(const char *uri);
gcc_pure gcc_pure
bool IsEmpty() const { bool IsEmpty() const {
...@@ -198,7 +198,7 @@ struct directory { ...@@ -198,7 +198,7 @@ struct directory {
gcc_pure gcc_pure
song *FindSong(const char *name_utf8) { song *FindSong(const char *name_utf8) {
const directory *cthis = this; const Directory *cthis = this;
return const_cast<song *>(cthis->FindSong(name_utf8)); return const_cast<song *>(cthis->FindSong(name_utf8));
} }
......
...@@ -46,7 +46,7 @@ directory_quark(void) ...@@ -46,7 +46,7 @@ directory_quark(void)
} }
void void
directory_save(FILE *fp, const struct directory *directory) directory_save(FILE *fp, const Directory *directory)
{ {
if (!directory->IsRoot()) { if (!directory->IsRoot()) {
fprintf(fp, DIRECTORY_MTIME "%lu\n", fprintf(fp, DIRECTORY_MTIME "%lu\n",
...@@ -55,7 +55,7 @@ directory_save(FILE *fp, const struct directory *directory) ...@@ -55,7 +55,7 @@ directory_save(FILE *fp, const struct directory *directory)
fprintf(fp, "%s%s\n", DIRECTORY_BEGIN, directory->GetPath()); fprintf(fp, "%s%s\n", DIRECTORY_BEGIN, directory->GetPath());
} }
struct directory *cur; Directory *cur;
directory_for_each_child(cur, directory) { directory_for_each_child(cur, directory) {
char *base = g_path_get_basename(cur->path); char *base = g_path_get_basename(cur->path);
...@@ -78,8 +78,8 @@ directory_save(FILE *fp, const struct directory *directory) ...@@ -78,8 +78,8 @@ directory_save(FILE *fp, const struct directory *directory)
fprintf(fp, DIRECTORY_END "%s\n", directory->GetPath()); fprintf(fp, DIRECTORY_END "%s\n", directory->GetPath());
} }
static struct directory * static Directory *
directory_load_subdir(FILE *fp, struct directory *parent, const char *name, directory_load_subdir(FILE *fp, Directory *parent, const char *name,
GString *buffer, GError **error_r) GString *buffer, GError **error_r)
{ {
const char *line; const char *line;
...@@ -91,7 +91,7 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name, ...@@ -91,7 +91,7 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name,
return NULL; return NULL;
} }
struct directory *directory = parent->CreateChild(name); Directory *directory = parent->CreateChild(name);
line = read_text_line(fp, buffer); line = read_text_line(fp, buffer);
if (line == NULL) { if (line == NULL) {
...@@ -132,7 +132,7 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name, ...@@ -132,7 +132,7 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name,
} }
bool bool
directory_load(FILE *fp, struct directory *directory, directory_load(FILE *fp, Directory *directory,
GString *buffer, GError **error) GString *buffer, GError **error)
{ {
const char *line; const char *line;
...@@ -140,7 +140,7 @@ directory_load(FILE *fp, struct directory *directory, ...@@ -140,7 +140,7 @@ directory_load(FILE *fp, struct directory *directory,
while ((line = read_text_line(fp, buffer)) != NULL && while ((line = read_text_line(fp, buffer)) != NULL &&
!g_str_has_prefix(line, DIRECTORY_END)) { !g_str_has_prefix(line, DIRECTORY_END)) {
if (g_str_has_prefix(line, DIRECTORY_DIR)) { if (g_str_has_prefix(line, DIRECTORY_DIR)) {
struct directory *subdir = Directory *subdir =
directory_load_subdir(fp, directory, directory_load_subdir(fp, directory,
line + sizeof(DIRECTORY_DIR) - 1, line + sizeof(DIRECTORY_DIR) - 1,
buffer, error); buffer, error);
......
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
#include <stdio.h> #include <stdio.h>
struct directory; struct Directory;
void void
directory_save(FILE *fp, const struct directory *directory); directory_save(FILE *fp, const Directory *directory);
bool bool
directory_load(FILE *fp, struct directory *directory, directory_load(FILE *fp, Directory *directory,
GString *buffer, GError **error); GString *buffer, GError **error);
#endif #endif
...@@ -181,7 +181,7 @@ map_uri_fs(const char *uri) ...@@ -181,7 +181,7 @@ map_uri_fs(const char *uri)
} }
char * char *
map_directory_fs(const struct directory *directory) map_directory_fs(const Directory *directory)
{ {
assert(music_dir_utf8 != NULL); assert(music_dir_utf8 != NULL);
assert(music_dir_fs != NULL); assert(music_dir_fs != NULL);
...@@ -193,7 +193,7 @@ map_directory_fs(const struct directory *directory) ...@@ -193,7 +193,7 @@ map_directory_fs(const struct directory *directory)
} }
char * char *
map_directory_child_fs(const struct directory *directory, const char *name) map_directory_child_fs(const Directory *directory, const char *name)
{ {
assert(music_dir_utf8 != NULL); assert(music_dir_utf8 != NULL);
assert(music_dir_fs != NULL); assert(music_dir_fs != NULL);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define PLAYLIST_FILE_SUFFIX ".m3u" #define PLAYLIST_FILE_SUFFIX ".m3u"
struct directory; struct Directory;
struct song; struct song;
void mapper_init(const char *_music_dir, const char *_playlist_dir); void mapper_init(const char *_music_dir, const char *_playlist_dir);
...@@ -87,7 +87,7 @@ map_uri_fs(const char *uri); ...@@ -87,7 +87,7 @@ map_uri_fs(const char *uri);
*/ */
gcc_malloc gcc_malloc
char * char *
map_directory_fs(const struct directory *directory); map_directory_fs(const Directory *directory);
/** /**
* Determines the file system path of a directory's child (may be a * Determines the file system path of a directory's child (may be a
...@@ -99,7 +99,7 @@ map_directory_fs(const struct directory *directory); ...@@ -99,7 +99,7 @@ map_directory_fs(const struct directory *directory);
*/ */
gcc_malloc gcc_malloc
char * char *
map_directory_child_fs(const struct directory *directory, const char *name); map_directory_child_fs(const Directory *directory, const char *name);
/** /**
* Determines the file system path of a song. This must not be a * Determines the file system path of a song. This must not be a
......
...@@ -29,10 +29,10 @@ extern "C" { ...@@ -29,10 +29,10 @@ extern "C" {
#include <assert.h> #include <assert.h>
struct directory detached_root; Directory detached_root;
static struct song * static struct song *
song_alloc(const char *uri, struct directory *parent) song_alloc(const char *uri, Directory *parent)
{ {
size_t uri_length; size_t uri_length;
...@@ -59,7 +59,7 @@ song_remote_new(const char *uri) ...@@ -59,7 +59,7 @@ song_remote_new(const char *uri)
} }
struct song * struct song *
song_file_new(const char *path, struct directory *parent) song_file_new(const char *path, Directory *parent)
{ {
assert((parent == nullptr) == (*path == '/')); assert((parent == nullptr) == (*path == '/'));
...@@ -117,14 +117,14 @@ song_free(struct song *song) ...@@ -117,14 +117,14 @@ song_free(struct song *song)
gcc_pure gcc_pure
static inline bool static inline bool
directory_equals(const struct directory &a, const struct directory &b) directory_equals(const Directory &a, const Directory &b)
{ {
return strcmp(a.path, b.path) == 0; return strcmp(a.path, b.path) == 0;
} }
gcc_pure gcc_pure
static inline bool static inline bool
directory_is_same(const struct directory *a, const struct directory *b) directory_is_same(const Directory *a, const Directory *b)
{ {
return a == b || return a == b ||
(a != nullptr && b != nullptr && (a != nullptr && b != nullptr &&
......
...@@ -63,7 +63,7 @@ song_save(FILE *fp, const struct song *song) ...@@ -63,7 +63,7 @@ song_save(FILE *fp, const struct song *song)
} }
struct song * struct song *
song_load(FILE *fp, struct directory *parent, const char *uri, song_load(FILE *fp, Directory *parent, const char *uri,
GString *buffer, GError **error_r) GString *buffer, GError **error_r)
{ {
struct song *song = parent != NULL struct song *song = parent != NULL
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#define SONG_BEGIN "song_begin: " #define SONG_BEGIN "song_begin: "
struct song; struct song;
struct directory; struct Directory;
void void
song_save(FILE *fp, const struct song *song); song_save(FILE *fp, const struct song *song);
...@@ -41,7 +41,7 @@ song_save(FILE *fp, const struct song *song); ...@@ -41,7 +41,7 @@ song_save(FILE *fp, const struct song *song);
* @return true on success, false on error * @return true on success, false on error
*/ */
struct song * struct song *
song_load(FILE *fp, struct directory *parent, const char *uri, song_load(FILE *fp, Directory *parent, const char *uri,
GString *buffer, GError **error_r); GString *buffer, GError **error_r);
#endif #endif
...@@ -109,7 +109,7 @@ sticker_song_get(const struct song *song) ...@@ -109,7 +109,7 @@ sticker_song_get(const struct song *song)
} }
struct sticker_song_find_data { struct sticker_song_find_data {
struct directory *directory; Directory *directory;
const char *base_uri; const char *base_uri;
size_t base_uri_length; size_t base_uri_length;
...@@ -134,7 +134,7 @@ sticker_song_find_cb(const char *uri, const char *value, gpointer user_data) ...@@ -134,7 +134,7 @@ sticker_song_find_cb(const char *uri, const char *value, gpointer user_data)
} }
bool bool
sticker_song_find(struct directory *directory, const char *name, sticker_song_find(Directory *directory, const char *name,
void (*func)(struct song *song, const char *value, void (*func)(struct song *song, const char *value,
gpointer user_data), gpointer user_data),
gpointer user_data) gpointer user_data)
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <glib.h> #include <glib.h>
struct song; struct song;
struct directory; struct Directory;
struct sticker; struct sticker;
/** /**
...@@ -75,7 +75,7 @@ sticker_song_get(const struct song *song); ...@@ -75,7 +75,7 @@ sticker_song_get(const struct song *song);
* failure * failure
*/ */
bool bool
sticker_song_find(struct directory *directory, const char *name, sticker_song_find(Directory *directory, const char *name,
void (*func)(struct song *song, const char *value, void (*func)(struct song *song, const char *value,
gpointer user_data), gpointer user_data),
gpointer user_data); gpointer user_data);
......
...@@ -45,7 +45,7 @@ extern "C" { ...@@ -45,7 +45,7 @@ extern "C" {
#include <stdio.h> #include <stdio.h>
struct song * struct song *
song_file_load(const char *path, struct directory *parent) song_file_load(const char *path, Directory *parent)
{ {
struct song *song; struct song *song;
bool ret; bool ret;
......
...@@ -127,7 +127,6 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) ...@@ -127,7 +127,6 @@ handle_sticker_song(struct client *client, int argc, char *argv[])
/* find song dir key */ /* find song dir key */
} else if (argc == 5 && strcmp(argv[1], "find") == 0) { } else if (argc == 5 && strcmp(argv[1], "find") == 0) {
/* "sticker find song a/directory name" */ /* "sticker find song a/directory name" */
struct directory *directory;
bool success; bool success;
struct sticker_song_find_data data = { struct sticker_song_find_data data = {
client, client,
...@@ -135,7 +134,7 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) ...@@ -135,7 +134,7 @@ handle_sticker_song(struct client *client, int argc, char *argv[])
}; };
db_lock(); db_lock();
directory = db_get_directory(argv[3]); Directory *directory = db_get_directory(argv[3]);
if (directory == NULL) { if (directory == NULL) {
db_unlock(); db_unlock();
command_error(client, ACK_ERROR_NO_EXIST, command_error(client, ACK_ERROR_NO_EXIST,
......
...@@ -35,14 +35,14 @@ extern "C" { ...@@ -35,14 +35,14 @@ extern "C" {
#include <string.h> #include <string.h>
static void static void
update_archive_tree(struct directory *directory, char *name) update_archive_tree(Directory *directory, char *name)
{ {
char *tmp = strchr(name, '/'); char *tmp = strchr(name, '/');
if (tmp) { if (tmp) {
*tmp = 0; *tmp = 0;
//add dir is not there already //add dir is not there already
db_lock(); db_lock();
struct directory *subdir = Directory *subdir =
directory->MakeChild(name); directory->MakeChild(name);
subdir->device = DEVICE_INARCHIVE; subdir->device = DEVICE_INARCHIVE;
db_unlock(); db_unlock();
...@@ -82,12 +82,12 @@ update_archive_tree(struct directory *directory, char *name) ...@@ -82,12 +82,12 @@ update_archive_tree(struct directory *directory, char *name)
* @param plugin the archive plugin which fits this archive type * @param plugin the archive plugin which fits this archive type
*/ */
static void static void
update_archive_file2(struct directory *parent, const char *name, update_archive_file2(Directory *parent, const char *name,
const struct stat *st, const struct stat *st,
const struct archive_plugin *plugin) const struct archive_plugin *plugin)
{ {
db_lock(); db_lock();
directory *directory = parent->FindChild(name); Directory *directory = parent->FindChild(name);
db_unlock(); db_unlock();
if (directory != NULL && directory->mtime == st->st_mtime && if (directory != NULL && directory->mtime == st->st_mtime &&
...@@ -136,7 +136,7 @@ update_archive_file2(struct directory *parent, const char *name, ...@@ -136,7 +136,7 @@ update_archive_file2(struct directory *parent, const char *name,
} }
bool bool
update_archive_file(struct directory *directory, update_archive_file(Directory *directory,
const char *name, const char *suffix, const char *name, const char *suffix,
const struct stat *st) const struct stat *st)
{ {
......
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
#include <sys/stat.h> #include <sys/stat.h>
struct directory; struct Directory;
struct archive_plugin; struct archive_plugin;
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
bool bool
update_archive_file(struct directory *directory, update_archive_file(Directory *directory,
const char *name, const char *suffix, const char *name, const char *suffix,
const struct stat *st); const struct stat *st);
...@@ -40,7 +40,7 @@ update_archive_file(struct directory *directory, ...@@ -40,7 +40,7 @@ update_archive_file(struct directory *directory,
#include <glib.h> #include <glib.h>
static inline bool static inline bool
update_archive_file(gcc_unused struct directory *directory, update_archive_file(gcc_unused Directory *directory,
gcc_unused const char *name, gcc_unused const char *name,
gcc_unused const char *suffix, gcc_unused const char *suffix,
gcc_unused const struct stat *st) gcc_unused const struct stat *st)
......
...@@ -42,11 +42,11 @@ extern "C" { ...@@ -42,11 +42,11 @@ extern "C" {
* *
* The caller must lock the database. * The caller must lock the database.
*/ */
static struct directory * static Directory *
make_directory_if_modified(struct directory *parent, const char *name, make_directory_if_modified(Directory *parent, const char *name,
const struct stat *st) const struct stat *st)
{ {
directory *directory = parent->FindChild(name); Directory *directory = parent->FindChild(name);
// directory exists already // directory exists already
if (directory != NULL) { if (directory != NULL) {
...@@ -66,7 +66,7 @@ make_directory_if_modified(struct directory *parent, const char *name, ...@@ -66,7 +66,7 @@ make_directory_if_modified(struct directory *parent, const char *name,
} }
bool bool
update_container_file(struct directory *directory, update_container_file(Directory *directory,
const char *name, const char *name,
const struct stat *st, const struct stat *st,
const struct decoder_plugin *plugin) const struct decoder_plugin *plugin)
...@@ -75,8 +75,7 @@ update_container_file(struct directory *directory, ...@@ -75,8 +75,7 @@ update_container_file(struct directory *directory,
return false; return false;
db_lock(); db_lock();
struct directory *contdir = Directory *contdir = make_directory_if_modified(directory, name, st);
make_directory_if_modified(directory, name, st);
if (contdir == NULL) { if (contdir == NULL) {
/* not modified */ /* not modified */
db_unlock(); db_unlock();
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
#include <sys/stat.h> #include <sys/stat.h>
struct directory; struct Directory;
struct decoder_plugin; struct decoder_plugin;
bool bool
update_container_file(struct directory *directory, update_container_file(Directory *directory,
const char *name, const char *name,
const struct stat *st, const struct stat *st,
const struct decoder_plugin *plugin); const struct decoder_plugin *plugin);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <assert.h> #include <assert.h>
void void
delete_song(struct directory *dir, struct song *del) delete_song(Directory *dir, struct song *del)
{ {
assert(del->parent == dir); assert(del->parent == dir);
...@@ -54,9 +54,9 @@ delete_song(struct directory *dir, struct song *del) ...@@ -54,9 +54,9 @@ delete_song(struct directory *dir, struct song *del)
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
static void static void
clear_directory(struct directory *directory) clear_directory(Directory *directory)
{ {
struct directory *child, *n; Directory *child, *n;
directory_for_each_child_safe(child, n, directory) directory_for_each_child_safe(child, n, directory)
delete_directory(child); delete_directory(child);
...@@ -68,7 +68,7 @@ clear_directory(struct directory *directory) ...@@ -68,7 +68,7 @@ clear_directory(struct directory *directory)
} }
void void
delete_directory(struct directory *directory) delete_directory(Directory *directory)
{ {
assert(directory->parent != NULL); assert(directory->parent != NULL);
...@@ -78,12 +78,12 @@ delete_directory(struct directory *directory) ...@@ -78,12 +78,12 @@ delete_directory(struct directory *directory)
} }
bool bool
delete_name_in(struct directory *parent, const char *name) delete_name_in(Directory *parent, const char *name)
{ {
bool modified = false; bool modified = false;
db_lock(); db_lock();
directory *directory = parent->FindChild(name); Directory *directory = parent->FindChild(name);
if (directory != NULL) { if (directory != NULL) {
delete_directory(directory); delete_directory(directory);
......
...@@ -22,14 +22,14 @@ ...@@ -22,14 +22,14 @@
#include "check.h" #include "check.h"
struct directory; struct Directory;
struct song; struct song;
/** /**
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
void void
delete_song(struct directory *parent, struct song *song); delete_song(Directory *parent, struct song *song);
/** /**
* Recursively free a directory and all its contents. * Recursively free a directory and all its contents.
...@@ -37,7 +37,7 @@ delete_song(struct directory *parent, struct song *song); ...@@ -37,7 +37,7 @@ delete_song(struct directory *parent, struct song *song);
* Caller must lock the #db_mutex. * Caller must lock the #db_mutex.
*/ */
void void
delete_directory(struct directory *directory); delete_directory(Directory *directory);
/** /**
* Caller must NOT lock the #db_mutex. * Caller must NOT lock the #db_mutex.
...@@ -45,6 +45,6 @@ delete_directory(struct directory *directory); ...@@ -45,6 +45,6 @@ delete_directory(struct directory *directory);
* @return true if the database was modified * @return true if the database was modified
*/ */
bool bool
delete_name_in(struct directory *parent, const char *name); delete_name_in(Directory *parent, const char *name);
#endif #endif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <unistd.h> #include <unistd.h>
int int
stat_directory(const struct directory *directory, struct stat *st) stat_directory(const Directory *directory, struct stat *st)
{ {
char *path_fs = map_directory_fs(directory); char *path_fs = map_directory_fs(directory);
if (path_fs == NULL) if (path_fs == NULL)
...@@ -44,7 +44,7 @@ stat_directory(const struct directory *directory, struct stat *st) ...@@ -44,7 +44,7 @@ stat_directory(const struct directory *directory, struct stat *st)
} }
int int
stat_directory_child(const struct directory *parent, const char *name, stat_directory_child(const Directory *parent, const char *name,
struct stat *st) struct stat *st)
{ {
char *path_fs = map_directory_child_fs(parent, name); char *path_fs = map_directory_child_fs(parent, name);
...@@ -60,7 +60,7 @@ stat_directory_child(const struct directory *parent, const char *name, ...@@ -60,7 +60,7 @@ stat_directory_child(const struct directory *parent, const char *name,
} }
bool bool
directory_exists(const struct directory *directory) directory_exists(const Directory *directory)
{ {
char *path_fs = map_directory_fs(directory); char *path_fs = map_directory_fs(directory);
if (path_fs == NULL) if (path_fs == NULL)
...@@ -79,7 +79,7 @@ directory_exists(const struct directory *directory) ...@@ -79,7 +79,7 @@ directory_exists(const struct directory *directory)
} }
bool bool
directory_child_is_regular(const struct directory *directory, directory_child_is_regular(const Directory *directory,
const char *name_utf8) const char *name_utf8)
{ {
char *path_fs = map_directory_child_fs(directory, name_utf8); char *path_fs = map_directory_child_fs(directory, name_utf8);
...@@ -94,7 +94,7 @@ directory_child_is_regular(const struct directory *directory, ...@@ -94,7 +94,7 @@ directory_child_is_regular(const struct directory *directory,
} }
bool bool
directory_child_access(const struct directory *directory, directory_child_access(const Directory *directory,
const char *name, int mode) const char *name, int mode)
{ {
#ifdef WIN32 #ifdef WIN32
......
...@@ -24,27 +24,27 @@ ...@@ -24,27 +24,27 @@
#include <sys/stat.h> #include <sys/stat.h>
struct directory; struct Directory;
int int
stat_directory(const struct directory *directory, struct stat *st); stat_directory(const Directory *directory, struct stat *st);
int int
stat_directory_child(const struct directory *parent, const char *name, stat_directory_child(const Directory *parent, const char *name,
struct stat *st); struct stat *st);
bool bool
directory_exists(const struct directory *directory); directory_exists(const Directory *directory);
bool bool
directory_child_is_regular(const struct directory *directory, directory_child_is_regular(const Directory *directory,
const char *name_utf8); const char *name_utf8);
/** /**
* Checks if the given permissions on the mapped file are given. * Checks if the given permissions on the mapped file are given.
*/ */
bool bool
directory_child_access(const struct directory *directory, directory_child_access(const Directory *directory,
const char *name, int mode); const char *name, int mode);
#endif #endif
...@@ -37,7 +37,7 @@ extern "C" { ...@@ -37,7 +37,7 @@ extern "C" {
#include <unistd.h> #include <unistd.h>
static void static void
update_song_file2(struct directory *directory, update_song_file2(Directory *directory,
const char *name, const struct stat *st, const char *name, const struct stat *st,
const struct decoder_plugin *plugin) const struct decoder_plugin *plugin)
{ {
...@@ -101,7 +101,7 @@ update_song_file2(struct directory *directory, ...@@ -101,7 +101,7 @@ update_song_file2(struct directory *directory,
} }
bool bool
update_song_file(struct directory *directory, update_song_file(Directory *directory,
const char *name, const char *suffix, const char *name, const char *suffix,
const struct stat *st) const struct stat *st)
{ {
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
#include <sys/stat.h> #include <sys/stat.h>
struct directory; struct Directory;
bool bool
update_song_file(struct directory *directory, update_song_file(Directory *directory,
const char *name, const char *suffix, const char *name, const char *suffix,
const struct stat *st); const struct stat *st);
......
...@@ -87,7 +87,7 @@ update_walk_global_finish(void) ...@@ -87,7 +87,7 @@ update_walk_global_finish(void)
} }
static void static void
directory_set_stat(struct directory *dir, const struct stat *st) directory_set_stat(Directory *dir, const struct stat *st)
{ {
dir->inode = st->st_ino; dir->inode = st->st_ino;
dir->device = st->st_dev; dir->device = st->st_dev;
...@@ -95,12 +95,11 @@ directory_set_stat(struct directory *dir, const struct stat *st) ...@@ -95,12 +95,11 @@ directory_set_stat(struct directory *dir, const struct stat *st)
} }
static void static void
remove_excluded_from_directory(struct directory *directory, remove_excluded_from_directory(Directory *directory, GSList *exclude_list)
GSList *exclude_list)
{ {
db_lock(); db_lock();
struct directory *child, *n; Directory *child, *n;
directory_for_each_child_safe(child, n, directory) { directory_for_each_child_safe(child, n, directory) {
char *name_fs = utf8_to_fs_charset(child->GetName()); char *name_fs = utf8_to_fs_charset(child->GetName());
...@@ -129,9 +128,9 @@ remove_excluded_from_directory(struct directory *directory, ...@@ -129,9 +128,9 @@ remove_excluded_from_directory(struct directory *directory,
} }
static void static void
purge_deleted_from_directory(struct directory *directory) purge_deleted_from_directory(Directory *directory)
{ {
struct directory *child, *n; Directory *child, *n;
directory_for_each_child_safe(child, n, directory) { directory_for_each_child_safe(child, n, directory) {
if (directory_exists(child)) if (directory_exists(child))
continue; continue;
...@@ -172,7 +171,7 @@ purge_deleted_from_directory(struct directory *directory) ...@@ -172,7 +171,7 @@ purge_deleted_from_directory(struct directory *directory)
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
static int static int
update_directory_stat(struct directory *directory) update_directory_stat(Directory *directory)
{ {
struct stat st; struct stat st;
if (stat_directory(directory, &st) < 0) if (stat_directory(directory, &st) < 0)
...@@ -184,7 +183,7 @@ update_directory_stat(struct directory *directory) ...@@ -184,7 +183,7 @@ update_directory_stat(struct directory *directory)
#endif #endif
static int static int
find_inode_ancestor(struct directory *parent, ino_t inode, dev_t device) find_inode_ancestor(Directory *parent, ino_t inode, dev_t device)
{ {
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
while (parent) { while (parent) {
...@@ -208,7 +207,7 @@ find_inode_ancestor(struct directory *parent, ino_t inode, dev_t device) ...@@ -208,7 +207,7 @@ find_inode_ancestor(struct directory *parent, ino_t inode, dev_t device)
} }
static bool static bool
update_playlist_file2(struct directory *directory, update_playlist_file2(Directory *directory,
const char *name, const char *suffix, const char *name, const char *suffix,
const struct stat *st) const struct stat *st)
{ {
...@@ -226,7 +225,7 @@ update_playlist_file2(struct directory *directory, ...@@ -226,7 +225,7 @@ update_playlist_file2(struct directory *directory,
} }
static bool static bool
update_regular_file(struct directory *directory, update_regular_file(Directory *directory,
const char *name, const struct stat *st) const char *name, const struct stat *st)
{ {
const char *suffix = uri_get_suffix(name); const char *suffix = uri_get_suffix(name);
...@@ -239,10 +238,10 @@ update_regular_file(struct directory *directory, ...@@ -239,10 +238,10 @@ update_regular_file(struct directory *directory,
} }
static bool static bool
update_directory(struct directory *directory, const struct stat *st); update_directory(Directory *directory, const struct stat *st);
static void static void
update_directory_child(struct directory *directory, update_directory_child(Directory *directory,
const char *name, const struct stat *st) const char *name, const struct stat *st)
{ {
assert(strchr(name, '/') == NULL); assert(strchr(name, '/') == NULL);
...@@ -254,7 +253,7 @@ update_directory_child(struct directory *directory, ...@@ -254,7 +253,7 @@ update_directory_child(struct directory *directory,
return; return;
db_lock(); db_lock();
struct directory *subdir = directory->MakeChild(name); Directory *subdir = directory->MakeChild(name);
db_unlock(); db_unlock();
assert(directory == subdir->parent); assert(directory == subdir->parent);
...@@ -280,7 +279,7 @@ static bool skip_path(const char *path) ...@@ -280,7 +279,7 @@ static bool skip_path(const char *path)
G_GNUC_PURE G_GNUC_PURE
static bool static bool
skip_symlink(const struct directory *directory, const char *utf8_name) skip_symlink(const Directory *directory, const char *utf8_name)
{ {
#ifndef WIN32 #ifndef WIN32
char *path_fs = map_directory_child_fs(directory, utf8_name); char *path_fs = map_directory_child_fs(directory, utf8_name);
...@@ -353,7 +352,7 @@ skip_symlink(const struct directory *directory, const char *utf8_name) ...@@ -353,7 +352,7 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
} }
static bool static bool
update_directory(struct directory *directory, const struct stat *st) update_directory(Directory *directory, const struct stat *st)
{ {
assert(S_ISDIR(st->st_mode)); assert(S_ISDIR(st->st_mode));
...@@ -418,11 +417,11 @@ update_directory(struct directory *directory, const struct stat *st) ...@@ -418,11 +417,11 @@ update_directory(struct directory *directory, const struct stat *st)
return true; return true;
} }
static struct directory * static Directory *
directory_make_child_checked(struct directory *parent, const char *name_utf8) directory_make_child_checked(Directory *parent, const char *name_utf8)
{ {
db_lock(); db_lock();
directory *directory = parent->FindChild(name_utf8); Directory *directory = parent->FindChild(name_utf8);
db_unlock(); db_unlock();
if (directory != NULL) if (directory != NULL)
...@@ -450,10 +449,10 @@ directory_make_child_checked(struct directory *parent, const char *name_utf8) ...@@ -450,10 +449,10 @@ directory_make_child_checked(struct directory *parent, const char *name_utf8)
return directory; return directory;
} }
static struct directory * static Directory *
directory_make_uri_parent_checked(const char *uri) directory_make_uri_parent_checked(const char *uri)
{ {
struct directory *directory = db_get_root(); Directory *directory = db_get_root();
char *duplicated = g_strdup(uri); char *duplicated = g_strdup(uri);
char *name_utf8 = duplicated, *slash; char *name_utf8 = duplicated, *slash;
...@@ -477,7 +476,7 @@ directory_make_uri_parent_checked(const char *uri) ...@@ -477,7 +476,7 @@ directory_make_uri_parent_checked(const char *uri)
static void static void
update_uri(const char *uri) update_uri(const char *uri)
{ {
struct directory *parent = directory_make_uri_parent_checked(uri); Directory *parent = directory_make_uri_parent_checked(uri);
if (parent == NULL) if (parent == NULL)
return; return;
...@@ -502,7 +501,7 @@ update_walk(const char *path, bool discard) ...@@ -502,7 +501,7 @@ update_walk(const char *path, bool discard)
if (path != NULL && !isRootDirectory(path)) { if (path != NULL && !isRootDirectory(path)) {
update_uri(path); update_uri(path);
} else { } else {
struct directory *directory = db_get_root(); Directory *directory = db_get_root();
struct stat st; struct stat st;
if (stat_directory(directory, &st) == 0) if (stat_directory(directory, &st) == 0)
......
...@@ -45,7 +45,7 @@ class ProxyDatabase : public Database { ...@@ -45,7 +45,7 @@ class ProxyDatabase : public Database {
unsigned port; unsigned port;
struct mpd_connection *connection; struct mpd_connection *connection;
struct directory *root; Directory *root;
public: public:
static Database *Create(const struct config_param *param, static Database *Create(const struct config_param *param,
...@@ -168,7 +168,7 @@ ProxyDatabase::Open(GError **error_r) ...@@ -168,7 +168,7 @@ ProxyDatabase::Open(GError **error_r)
return false; return false;
} }
root = directory::NewRoot(); root = Directory::NewRoot();
return true; return true;
} }
...@@ -240,8 +240,7 @@ Visit(struct mpd_connection *connection, ...@@ -240,8 +240,7 @@ Visit(struct mpd_connection *connection,
const char *path = mpd_directory_get_path(directory); const char *path = mpd_directory_get_path(directory);
if (visit_directory) { if (visit_directory) {
struct directory *d = Directory *d = Directory::NewGeneric(path, &detached_root);
directory::NewGeneric(path, &detached_root);
bool success = visit_directory(*d, error_r); bool success = visit_directory(*d, error_r);
d->Free(); d->Free();
if (!success) if (!success)
......
...@@ -180,7 +180,7 @@ SimpleDatabase::Load(GError **error_r) ...@@ -180,7 +180,7 @@ SimpleDatabase::Load(GError **error_r)
bool bool
SimpleDatabase::Open(GError **error_r) SimpleDatabase::Open(GError **error_r)
{ {
root = directory::NewRoot(); root = Directory::NewRoot();
mtime = 0; mtime = 0;
#ifndef NDEBUG #ifndef NDEBUG
...@@ -197,7 +197,7 @@ SimpleDatabase::Open(GError **error_r) ...@@ -197,7 +197,7 @@ SimpleDatabase::Open(GError **error_r)
if (!Check(error_r)) if (!Check(error_r))
return false; return false;
root = directory::NewRoot(); root = Directory::NewRoot();
} }
return true; return true;
...@@ -243,7 +243,7 @@ SimpleDatabase::ReturnSong(gcc_unused struct song *song) const ...@@ -243,7 +243,7 @@ SimpleDatabase::ReturnSong(gcc_unused struct song *song) const
} }
G_GNUC_PURE G_GNUC_PURE
const struct directory * const Directory *
SimpleDatabase::LookupDirectory(const char *uri) const SimpleDatabase::LookupDirectory(const char *uri) const
{ {
assert(root != NULL); assert(root != NULL);
...@@ -262,7 +262,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, ...@@ -262,7 +262,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
{ {
ScopeDatabaseLock protect; ScopeDatabaseLock protect;
const directory *directory = root->LookupDirectory(selection.uri); const Directory *directory = root->LookupDirectory(selection.uri);
if (directory == NULL) { if (directory == NULL) {
if (visit_song) { if (visit_song) {
song *song = root->LookupSong(selection.uri); song *song = root->LookupSong(selection.uri);
......
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
#include <time.h> #include <time.h>
struct directory; struct Directory;
class SimpleDatabase : public Database { class SimpleDatabase : public Database {
std::string path; std::string path;
struct directory *root; Directory *root;
time_t mtime; time_t mtime;
...@@ -43,7 +43,7 @@ class SimpleDatabase : public Database { ...@@ -43,7 +43,7 @@ class SimpleDatabase : public Database {
public: public:
gcc_pure gcc_pure
struct directory *GetRoot() { Directory *GetRoot() {
assert(root != NULL); assert(root != NULL);
return root; return root;
...@@ -90,7 +90,7 @@ protected: ...@@ -90,7 +90,7 @@ protected:
bool Load(GError **error_r); bool Load(GError **error_r);
gcc_pure gcc_pure
const struct directory *LookupDirectory(const char *uri) const; const Directory *LookupDirectory(const char *uri) const;
}; };
extern const DatabasePlugin simple_db_plugin; extern const DatabasePlugin simple_db_plugin;
......
...@@ -43,7 +43,7 @@ struct song { ...@@ -43,7 +43,7 @@ struct song {
struct list_head siblings; struct list_head siblings;
struct tag *tag; struct tag *tag;
struct directory *parent; struct Directory *parent;
time_t mtime; time_t mtime;
/** /**
...@@ -64,7 +64,7 @@ struct song { ...@@ -64,7 +64,7 @@ struct song {
* A dummy #directory instance that is used for "detached" song * A dummy #directory instance that is used for "detached" song
* copies. * copies.
*/ */
extern struct directory detached_root; extern struct Directory detached_root;
G_BEGIN_DECLS G_BEGIN_DECLS
...@@ -74,7 +74,7 @@ song_remote_new(const char *uri); ...@@ -74,7 +74,7 @@ song_remote_new(const char *uri);
/** allocate a new song with a local file name */ /** allocate a new song with a local file name */
struct song * struct song *
song_file_new(const char *path, struct directory *parent); song_file_new(const char *path, struct Directory *parent);
/** /**
* allocate a new song structure with a local file name and attempt to * allocate a new song structure with a local file name and attempt to
...@@ -82,7 +82,7 @@ song_file_new(const char *path, struct directory *parent); ...@@ -82,7 +82,7 @@ song_file_new(const char *path, struct directory *parent);
* data, NULL is returned. * data, NULL is returned.
*/ */
struct song * struct song *
song_file_load(const char *path, struct directory *parent); song_file_load(const char *path, struct Directory *parent);
/** /**
* Replaces the URI of a song object. The given song object is * Replaces the URI of a song object. The given song object is
......
...@@ -48,7 +48,7 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level, ...@@ -48,7 +48,7 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
} }
static bool static bool
DumpDirectory(const directory &directory, GError **) DumpDirectory(const Directory &directory, GError **)
{ {
cout << "D " << directory.path << endl; cout << "D " << directory.path << endl;
return true; return true;
...@@ -63,7 +63,7 @@ DumpSong(song &song, GError **) ...@@ -63,7 +63,7 @@ DumpSong(song &song, GError **)
static bool static bool
DumpPlaylist(const PlaylistInfo &playlist, DumpPlaylist(const PlaylistInfo &playlist,
const directory &directory, GError **) const Directory &directory, GError **)
{ {
cout << "P " << directory.path << "/" << playlist.name.c_str() << endl; cout << "P " << directory.path << "/" << playlist.name.c_str() << endl;
return true; return true;
......
...@@ -5,7 +5,7 @@ extern "C" { ...@@ -5,7 +5,7 @@ extern "C" {
#include "song.h" #include "song.h"
#include "Directory.hxx" #include "Directory.hxx"
struct directory detached_root; Directory detached_root;
struct song * struct song *
song_dup_detached(const struct song *src) song_dup_detached(const struct song *src)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment