diff options
author | Max Kellermann <max@duempel.org> | 2013-01-02 23:06:20 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-03 01:10:47 +0100 |
commit | 3e8047e5831b4cc7dabae596746066698ad7c8cd (patch) | |
tree | 51cf8e3cc3b5b373f11ffbd6d7c0b34b3c0acb6c /src | |
parent | 440ac51cf0250904813dfc9398ca8c9e6467328f (diff) | |
download | mpd-3e8047e5831b4cc7dabae596746066698ad7c8cd.tar.gz mpd-3e8047e5831b4cc7dabae596746066698ad7c8cd.tar.xz mpd-3e8047e5831b4cc7dabae596746066698ad7c8cd.zip |
Directory: rename struct directory to Directory
Diffstat (limited to 'src')
34 files changed, 177 insertions, 181 deletions
diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx index 3325c5ecc..283ef9943 100644 --- a/src/DatabaseGlue.cxx +++ b/src/DatabaseGlue.cxx @@ -109,7 +109,7 @@ db_is_simple(void) return is_simple; } -struct directory * +Directory * db_get_root(void) { assert(db != NULL); @@ -118,13 +118,13 @@ db_get_root(void) return ((SimpleDatabase *)db)->GetRoot(); } -struct directory * +Directory * db_get_directory(const char *name) { if (db == NULL) return NULL; - struct directory *music_root = db_get_root(); + Directory *music_root = db_get_root(); if (name == NULL) return music_root; diff --git a/src/DatabasePrint.cxx b/src/DatabasePrint.cxx index 1d78bed44..755224e9a 100644 --- a/src/DatabasePrint.cxx +++ b/src/DatabasePrint.cxx @@ -38,7 +38,7 @@ extern "C" { #include <functional> static bool -PrintDirectory(struct client *client, const directory &directory) +PrintDirectory(struct client *client, const Directory &directory) { if (!directory.IsRoot()) client_printf(client, "directory: %s\n", directory.GetPath()); @@ -48,7 +48,7 @@ PrintDirectory(struct client *client, const directory &directory) static void print_playlist_in_directory(struct client *client, - const directory &directory, + const Directory &directory, const char *name_utf8) { if (directory.IsRoot()) @@ -89,7 +89,7 @@ PrintSongFull(struct client *client, song &song) static bool PrintPlaylistBrief(struct client *client, const PlaylistInfo &playlist, - const directory &directory) + const Directory &directory) { print_playlist_in_directory(client, directory, playlist.name.c_str()); return true; @@ -98,7 +98,7 @@ PrintPlaylistBrief(struct client *client, static bool PrintPlaylistFull(struct client *client, const PlaylistInfo &playlist, - const directory &directory) + const Directory &directory) { print_playlist_in_directory(client, directory, playlist.name.c_str()); diff --git a/src/DatabaseSave.cxx b/src/DatabaseSave.cxx index 32ae7441d..0424fbe29 100644 --- a/src/DatabaseSave.cxx +++ b/src/DatabaseSave.cxx @@ -58,7 +58,7 @@ db_quark(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); @@ -77,7 +77,7 @@ db_save_internal(FILE *fp, const struct directory *music_root) } 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); char *line; diff --git a/src/DatabaseSave.hxx b/src/DatabaseSave.hxx index f96bf5e21..5133961fe 100644 --- a/src/DatabaseSave.hxx +++ b/src/DatabaseSave.hxx @@ -24,12 +24,12 @@ #include <stdio.h> -struct directory; +struct Directory; void -db_save_internal(FILE *file, const struct directory *root); +db_save_internal(FILE *file, const Directory *root); bool -db_load_internal(FILE *file, struct directory *root, GError **error); +db_load_internal(FILE *file, Directory *root, GError **error); #endif diff --git a/src/DatabaseSimple.hxx b/src/DatabaseSimple.hxx index 20f038024..e57ae41bf 100644 --- a/src/DatabaseSimple.hxx +++ b/src/DatabaseSimple.hxx @@ -28,7 +28,7 @@ #include <stdbool.h> struct config_param; -struct directory; +struct Directory; struct db_selection; struct db_visitor; @@ -47,7 +47,7 @@ db_is_simple(void); * May only be used if db_is_simple() returns true. */ gcc_pure -struct directory * +Directory * db_get_root(void); /** @@ -55,7 +55,7 @@ db_get_root(void); */ gcc_nonnull(1) gcc_pure -struct directory * +Directory * db_get_directory(const char *name); /** diff --git a/src/DatabaseVisitor.hxx b/src/DatabaseVisitor.hxx index c10deae19..c90441415 100644 --- a/src/DatabaseVisitor.hxx +++ b/src/DatabaseVisitor.hxx @@ -24,13 +24,13 @@ #include <functional> -struct directory; +struct Directory; struct song; 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(const PlaylistInfo &, const directory &, +typedef std::function<bool(const PlaylistInfo &, const Directory &, GError **)> VisitPlaylist; typedef std::function<bool(const char *, GError **)> VisitString; diff --git a/src/Directory.cxx b/src/Directory.cxx index 8457a421b..c2c5d2816 100644 --- a/src/Directory.cxx +++ b/src/Directory.cxx @@ -36,16 +36,16 @@ extern "C" { #include <string.h> #include <stdlib.h> -static directory * +static Directory * directory_allocate(const char *path) { assert(path != NULL); const size_t path_size = strlen(path) + 1; - directory *directory = - (struct directory *)g_malloc0(sizeof(*directory) - - sizeof(directory->path) - + path_size); + Directory *directory = + (Directory *)g_malloc0(sizeof(*directory) + - sizeof(directory->path) + + path_size); INIT_LIST_HEAD(&directory->children); INIT_LIST_HEAD(&directory->songs); INIT_LIST_HEAD(&directory->playlists); @@ -55,13 +55,13 @@ directory_allocate(const char *path) return directory; } -struct directory * -directory::NewGeneric(const char *path, struct directory *parent) +Directory * +Directory::NewGeneric(const char *path, Directory *parent) { assert(path != NULL); assert((*path == 0) == (parent == NULL)); - directory *directory = directory_allocate(path); + Directory *directory = directory_allocate(path); directory->parent = parent; @@ -69,7 +69,7 @@ directory::NewGeneric(const char *path, struct directory *parent) } void -directory::Free() +Directory::Free() { playlist_vector_deinit(&playlists); @@ -77,7 +77,7 @@ directory::Free() directory_for_each_song_safe(song, ns, this) song_free(song); - struct directory *child, *n; + Directory *child, *n; directory_for_each_child_safe(child, n, this) child->Free(); @@ -85,7 +85,7 @@ directory::Free() } void -directory::Delete() +Directory::Delete() { assert(holding_db_lock()); assert(parent != nullptr); @@ -95,7 +95,7 @@ directory::Delete() } const char * -directory::GetName() const +Directory::GetName() const { assert(!IsRoot()); assert(path != nullptr); @@ -108,8 +108,8 @@ directory::GetName() const : path; } -struct directory * -directory::CreateChild(const char *name_utf8) +Directory * +Directory::CreateChild(const char *name_utf8) { assert(holding_db_lock()); assert(name_utf8 != NULL); @@ -126,19 +126,19 @@ directory::CreateChild(const char *name_utf8) path_utf8 = allocated; } - directory *child = NewGeneric(path_utf8, this); + Directory *child = NewGeneric(path_utf8, this); g_free(allocated); list_add_tail(&child->siblings, &children); return child; } -const directory * -directory::FindChild(const char *name) const +const Directory * +Directory::FindChild(const char *name) const { assert(holding_db_lock()); - const struct directory *child; + const Directory *child; directory_for_each_child(child, this) if (strcmp(child->GetName(), name) == 0) return child; @@ -147,11 +147,11 @@ directory::FindChild(const char *name) const } void -directory::PruneEmpty() +Directory::PruneEmpty() { assert(holding_db_lock()); - struct directory *child, *n; + Directory *child, *n; directory_for_each_child_safe(child, n, this) { child->PruneEmpty(); @@ -160,8 +160,8 @@ directory::PruneEmpty() } } -struct directory * -directory::LookupDirectory(const char *uri) +Directory * +Directory::LookupDirectory(const char *uri) { assert(holding_db_lock()); assert(uri != NULL); @@ -171,7 +171,7 @@ directory::LookupDirectory(const char *uri) char *duplicated = g_strdup(uri), *name = duplicated; - struct directory *d = this; + Directory *d = this; while (1) { char *slash = strchr(name, '/'); if (slash == name) { @@ -195,7 +195,7 @@ directory::LookupDirectory(const char *uri) } void -directory::AddSong(struct song *song) +Directory::AddSong(struct song *song) { assert(holding_db_lock()); assert(song != NULL); @@ -205,7 +205,7 @@ directory::AddSong(struct song *song) } void -directory::RemoveSong(struct song *song) +Directory::RemoveSong(struct song *song) { assert(holding_db_lock()); assert(song != NULL); @@ -215,7 +215,7 @@ directory::RemoveSong(struct song *song) } const song * -directory::FindSong(const char *name_utf8) const +Directory::FindSong(const char *name_utf8) const { assert(holding_db_lock()); assert(name_utf8 != NULL); @@ -232,7 +232,7 @@ directory::FindSong(const char *name_utf8) const } struct song * -directory::LookupSong(const char *uri) +Directory::LookupSong(const char *uri) { char *duplicated, *base; @@ -242,7 +242,7 @@ directory::LookupSong(const char *uri) duplicated = g_strdup(uri); base = strrchr(duplicated, '/'); - struct directory *d = this; + Directory *d = this; if (base != NULL) { *base++ = 0; d = d->LookupDirectory(duplicated); @@ -265,26 +265,26 @@ static int directory_cmp(G_GNUC_UNUSED void *priv, struct list_head *_a, struct list_head *_b) { - const struct directory *a = (const struct directory *)_a; - const struct directory *b = (const struct directory *)_b; + const Directory *a = (const Directory *)_a; + const Directory *b = (const Directory *)_b; return g_utf8_collate(a->path, b->path); } void -directory::Sort() +Directory::Sort() { assert(holding_db_lock()); list_sort(NULL, &children, directory_cmp); song_list_sort(&songs); - struct directory *child; + Directory *child; directory_for_each_child(child, this) child->Sort(); } bool -directory::Walk(bool recursive, const SongFilter *filter, +Directory::Walk(bool recursive, const SongFilter *filter, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist, GError **error_r) const @@ -306,7 +306,7 @@ directory::Walk(bool recursive, const SongFilter *filter, return false; } - struct directory *child; + Directory *child; directory_for_each_child(child, this) { if (visit_directory && !visit_directory(*child, error_r)) diff --git a/src/Directory.hxx b/src/Directory.hxx index dccb51ae5..29c69d6d6 100644 --- a/src/Directory.hxx +++ b/src/Directory.hxx @@ -54,7 +54,7 @@ struct song; struct db_visitor; class SongFilter; -struct directory { +struct Directory { /** * Pointers to the siblings of this directory within the * parent directory. It is unused (undefined) in the root @@ -83,7 +83,7 @@ struct directory { struct list_head playlists; - struct directory *parent; + Directory *parent; time_t mtime; ino_t inode; dev_t device; @@ -91,53 +91,53 @@ struct directory { char path[sizeof(long)]; /** - * Generic constructor for #directory object. + * Generic constructor for #Directory object. */ 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 - static directory *NewRoot() { + static Directory *NewRoot() { 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. */ void Free(); /** - * Remove this #directory object from its parent and free it. This - * must not be called with the root directory. + * Remove this #Directory object from its parent and free it. This + * must not be called with the root Directory. * * Caller must lock the #db_mutex. */ 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. * * @param name_utf8 the UTF-8 encoded name of the new sub directory */ gcc_malloc - directory *CreateChild(const char *name_utf8); + Directory *CreateChild(const char *name_utf8); /** * Caller must lock the #db_mutex. */ gcc_pure - const directory *FindChild(const char *name) const; + const Directory *FindChild(const char *name) const; gcc_pure - directory *FindChild(const char *name) { - const directory *cthis = this; - return const_cast<directory *>(cthis->FindChild(name)); + Directory *FindChild(const char *name) { + const Directory *cthis = this; + return const_cast<Directory *>(cthis->FindChild(name)); } /** @@ -146,8 +146,8 @@ struct directory { * * Caller must lock the #db_mutex. */ - struct directory *MakeChild(const char *name_utf8) { - struct directory *child = FindChild(name_utf8); + Directory *MakeChild(const char *name_utf8) { + Directory *child = FindChild(name_utf8); if (child == nullptr) child = CreateChild(name_utf8); return child; @@ -157,10 +157,10 @@ struct directory { * Looks up a directory by its 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 - directory *LookupDirectory(const char *uri); + Directory *LookupDirectory(const char *uri); gcc_pure bool IsEmpty() const { @@ -198,7 +198,7 @@ struct directory { gcc_pure song *FindSong(const char *name_utf8) { - const directory *cthis = this; + const Directory *cthis = this; return const_cast<song *>(cthis->FindSong(name_utf8)); } diff --git a/src/DirectorySave.cxx b/src/DirectorySave.cxx index 6bbda19cf..6fcc9ccc0 100644 --- a/src/DirectorySave.cxx +++ b/src/DirectorySave.cxx @@ -46,7 +46,7 @@ directory_quark(void) } void -directory_save(FILE *fp, const struct directory *directory) +directory_save(FILE *fp, const Directory *directory) { if (!directory->IsRoot()) { fprintf(fp, DIRECTORY_MTIME "%lu\n", @@ -55,7 +55,7 @@ directory_save(FILE *fp, const struct directory *directory) fprintf(fp, "%s%s\n", DIRECTORY_BEGIN, directory->GetPath()); } - struct directory *cur; + Directory *cur; directory_for_each_child(cur, directory) { char *base = g_path_get_basename(cur->path); @@ -78,8 +78,8 @@ directory_save(FILE *fp, const struct directory *directory) fprintf(fp, DIRECTORY_END "%s\n", directory->GetPath()); } -static struct directory * -directory_load_subdir(FILE *fp, struct directory *parent, const char *name, +static Directory * +directory_load_subdir(FILE *fp, Directory *parent, const char *name, GString *buffer, GError **error_r) { const char *line; @@ -91,7 +91,7 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name, return NULL; } - struct directory *directory = parent->CreateChild(name); + Directory *directory = parent->CreateChild(name); line = read_text_line(fp, buffer); if (line == NULL) { @@ -132,7 +132,7 @@ directory_load_subdir(FILE *fp, struct directory *parent, const char *name, } bool -directory_load(FILE *fp, struct directory *directory, +directory_load(FILE *fp, Directory *directory, GString *buffer, GError **error) { const char *line; @@ -140,7 +140,7 @@ directory_load(FILE *fp, struct directory *directory, while ((line = read_text_line(fp, buffer)) != NULL && !g_str_has_prefix(line, DIRECTORY_END)) { if (g_str_has_prefix(line, DIRECTORY_DIR)) { - struct directory *subdir = + Directory *subdir = directory_load_subdir(fp, directory, line + sizeof(DIRECTORY_DIR) - 1, buffer, error); diff --git a/src/DirectorySave.hxx b/src/DirectorySave.hxx index 18c3bf64e..83b820618 100644 --- a/src/DirectorySave.hxx +++ b/src/DirectorySave.hxx @@ -24,13 +24,13 @@ #include <stdio.h> -struct directory; +struct Directory; void -directory_save(FILE *fp, const struct directory *directory); +directory_save(FILE *fp, const Directory *directory); bool -directory_load(FILE *fp, struct directory *directory, +directory_load(FILE *fp, Directory *directory, GString *buffer, GError **error); #endif diff --git a/src/Mapper.cxx b/src/Mapper.cxx index aef0858ac..4d863418b 100644 --- a/src/Mapper.cxx +++ b/src/Mapper.cxx @@ -181,7 +181,7 @@ map_uri_fs(const char *uri) } char * -map_directory_fs(const struct directory *directory) +map_directory_fs(const Directory *directory) { assert(music_dir_utf8 != NULL); assert(music_dir_fs != NULL); @@ -193,7 +193,7 @@ map_directory_fs(const struct directory *directory) } 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_fs != NULL); diff --git a/src/Mapper.hxx b/src/Mapper.hxx index d7e4ea1a9..2ced38a10 100644 --- a/src/Mapper.hxx +++ b/src/Mapper.hxx @@ -29,7 +29,7 @@ #define PLAYLIST_FILE_SUFFIX ".m3u" -struct directory; +struct Directory; struct song; void mapper_init(const char *_music_dir, const char *_playlist_dir); @@ -87,7 +87,7 @@ map_uri_fs(const char *uri); */ gcc_malloc 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 @@ -99,7 +99,7 @@ map_directory_fs(const struct directory *directory); */ gcc_malloc 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 diff --git a/src/Song.cxx b/src/Song.cxx index 9da21645c..c845384ae 100644 --- a/src/Song.cxx +++ b/src/Song.cxx @@ -29,10 +29,10 @@ extern "C" { #include <assert.h> -struct directory detached_root; +Directory detached_root; static struct song * -song_alloc(const char *uri, struct directory *parent) +song_alloc(const char *uri, Directory *parent) { size_t uri_length; @@ -59,7 +59,7 @@ song_remote_new(const char *uri) } struct song * -song_file_new(const char *path, struct directory *parent) +song_file_new(const char *path, Directory *parent) { assert((parent == nullptr) == (*path == '/')); @@ -117,14 +117,14 @@ song_free(struct song *song) gcc_pure 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; } gcc_pure 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 || (a != nullptr && b != nullptr && diff --git a/src/SongSave.cxx b/src/SongSave.cxx index d78eb3f78..1aaf15481 100644 --- a/src/SongSave.cxx +++ b/src/SongSave.cxx @@ -63,7 +63,7 @@ song_save(FILE *fp, const struct song *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) { struct song *song = parent != NULL diff --git a/src/SongSave.hxx b/src/SongSave.hxx index d8805acd7..81838a3ee 100644 --- a/src/SongSave.hxx +++ b/src/SongSave.hxx @@ -27,7 +27,7 @@ #define SONG_BEGIN "song_begin: " struct song; -struct directory; +struct Directory; void 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 */ 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); #endif diff --git a/src/SongSticker.cxx b/src/SongSticker.cxx index 14b3a1580..40af50b31 100644 --- a/src/SongSticker.cxx +++ b/src/SongSticker.cxx @@ -109,7 +109,7 @@ sticker_song_get(const struct song *song) } struct sticker_song_find_data { - struct directory *directory; + Directory *directory; const char *base_uri; size_t base_uri_length; @@ -134,7 +134,7 @@ sticker_song_find_cb(const char *uri, const char *value, gpointer user_data) } 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, gpointer user_data), gpointer user_data) diff --git a/src/SongSticker.hxx b/src/SongSticker.hxx index 81b76cef5..fd25af4c8 100644 --- a/src/SongSticker.hxx +++ b/src/SongSticker.hxx @@ -23,7 +23,7 @@ #include <glib.h> struct song; -struct directory; +struct Directory; struct sticker; /** @@ -75,7 +75,7 @@ sticker_song_get(const struct song *song); * failure */ 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, gpointer user_data), gpointer user_data); diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index 83937b99b..2d22f27c4 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -45,7 +45,7 @@ extern "C" { #include <stdio.h> struct song * -song_file_load(const char *path, struct directory *parent) +song_file_load(const char *path, Directory *parent) { struct song *song; bool ret; diff --git a/src/StickerCommands.cxx b/src/StickerCommands.cxx index dfb92df38..3383b9553 100644 --- a/src/StickerCommands.cxx +++ b/src/StickerCommands.cxx @@ -127,7 +127,6 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) /* find song dir key */ } else if (argc == 5 && strcmp(argv[1], "find") == 0) { /* "sticker find song a/directory name" */ - struct directory *directory; bool success; struct sticker_song_find_data data = { client, @@ -135,7 +134,7 @@ handle_sticker_song(struct client *client, int argc, char *argv[]) }; db_lock(); - directory = db_get_directory(argv[3]); + Directory *directory = db_get_directory(argv[3]); if (directory == NULL) { db_unlock(); command_error(client, ACK_ERROR_NO_EXIST, diff --git a/src/UpdateArchive.cxx b/src/UpdateArchive.cxx index d0d180fdd..72f7aaf19 100644 --- a/src/UpdateArchive.cxx +++ b/src/UpdateArchive.cxx @@ -35,14 +35,14 @@ extern "C" { #include <string.h> static void -update_archive_tree(struct directory *directory, char *name) +update_archive_tree(Directory *directory, char *name) { char *tmp = strchr(name, '/'); if (tmp) { *tmp = 0; //add dir is not there already db_lock(); - struct directory *subdir = + Directory *subdir = directory->MakeChild(name); subdir->device = DEVICE_INARCHIVE; db_unlock(); @@ -82,12 +82,12 @@ update_archive_tree(struct directory *directory, char *name) * @param plugin the archive plugin which fits this archive type */ 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 archive_plugin *plugin) { db_lock(); - directory *directory = parent->FindChild(name); + Directory *directory = parent->FindChild(name); db_unlock(); if (directory != NULL && directory->mtime == st->st_mtime && @@ -136,7 +136,7 @@ update_archive_file2(struct directory *parent, const char *name, } bool -update_archive_file(struct directory *directory, +update_archive_file(Directory *directory, const char *name, const char *suffix, const struct stat *st) { diff --git a/src/UpdateArchive.hxx b/src/UpdateArchive.hxx index 5ce63978e..aa9882ae0 100644 --- a/src/UpdateArchive.hxx +++ b/src/UpdateArchive.hxx @@ -25,13 +25,13 @@ #include <sys/stat.h> -struct directory; +struct Directory; struct archive_plugin; #ifdef ENABLE_ARCHIVE bool -update_archive_file(struct directory *directory, +update_archive_file(Directory *directory, const char *name, const char *suffix, const struct stat *st); @@ -40,7 +40,7 @@ update_archive_file(struct directory *directory, #include <glib.h> 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 *suffix, gcc_unused const struct stat *st) diff --git a/src/UpdateContainer.cxx b/src/UpdateContainer.cxx index 1d6508457..07bf0cee1 100644 --- a/src/UpdateContainer.cxx +++ b/src/UpdateContainer.cxx @@ -42,11 +42,11 @@ extern "C" { * * The caller must lock the database. */ -static struct directory * -make_directory_if_modified(struct directory *parent, const char *name, +static Directory * +make_directory_if_modified(Directory *parent, const char *name, const struct stat *st) { - directory *directory = parent->FindChild(name); + Directory *directory = parent->FindChild(name); // directory exists already if (directory != NULL) { @@ -66,7 +66,7 @@ make_directory_if_modified(struct directory *parent, const char *name, } bool -update_container_file(struct directory *directory, +update_container_file(Directory *directory, const char *name, const struct stat *st, const struct decoder_plugin *plugin) @@ -75,8 +75,7 @@ update_container_file(struct directory *directory, return false; db_lock(); - struct directory *contdir = - make_directory_if_modified(directory, name, st); + Directory *contdir = make_directory_if_modified(directory, name, st); if (contdir == NULL) { /* not modified */ db_unlock(); diff --git a/src/UpdateContainer.hxx b/src/UpdateContainer.hxx index 81f081a59..0078730d6 100644 --- a/src/UpdateContainer.hxx +++ b/src/UpdateContainer.hxx @@ -24,11 +24,11 @@ #include <sys/stat.h> -struct directory; +struct Directory; struct decoder_plugin; bool -update_container_file(struct directory *directory, +update_container_file(Directory *directory, const char *name, const struct stat *st, const struct decoder_plugin *plugin); diff --git a/src/UpdateDatabase.cxx b/src/UpdateDatabase.cxx index cf95236f4..50697511c 100644 --- a/src/UpdateDatabase.cxx +++ b/src/UpdateDatabase.cxx @@ -29,7 +29,7 @@ #include <assert.h> void -delete_song(struct directory *dir, struct song *del) +delete_song(Directory *dir, struct song *del) { assert(del->parent == dir); @@ -54,9 +54,9 @@ delete_song(struct directory *dir, struct song *del) * Caller must lock the #db_mutex. */ 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) delete_directory(child); @@ -68,7 +68,7 @@ clear_directory(struct directory *directory) } void -delete_directory(struct directory *directory) +delete_directory(Directory *directory) { assert(directory->parent != NULL); @@ -78,12 +78,12 @@ delete_directory(struct directory *directory) } bool -delete_name_in(struct directory *parent, const char *name) +delete_name_in(Directory *parent, const char *name) { bool modified = false; db_lock(); - directory *directory = parent->FindChild(name); + Directory *directory = parent->FindChild(name); if (directory != NULL) { delete_directory(directory); diff --git a/src/UpdateDatabase.hxx b/src/UpdateDatabase.hxx index 511f75690..7b55ce95d 100644 --- a/src/UpdateDatabase.hxx +++ b/src/UpdateDatabase.hxx @@ -22,14 +22,14 @@ #include "check.h" -struct directory; +struct Directory; struct song; /** * Caller must lock the #db_mutex. */ void -delete_song(struct directory *parent, struct song *song); +delete_song(Directory *parent, struct song *song); /** * Recursively free a directory and all its contents. @@ -37,7 +37,7 @@ delete_song(struct directory *parent, struct song *song); * Caller must lock the #db_mutex. */ void -delete_directory(struct directory *directory); +delete_directory(Directory *directory); /** * Caller must NOT lock the #db_mutex. @@ -45,6 +45,6 @@ delete_directory(struct directory *directory); * @return true if the database was modified */ bool -delete_name_in(struct directory *parent, const char *name); +delete_name_in(Directory *parent, const char *name); #endif diff --git a/src/UpdateIO.cxx b/src/UpdateIO.cxx index 200a6136d..2aee56514 100644 --- a/src/UpdateIO.cxx +++ b/src/UpdateIO.cxx @@ -29,7 +29,7 @@ #include <unistd.h> 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); if (path_fs == NULL) @@ -44,7 +44,7 @@ stat_directory(const struct directory *directory, struct stat *st) } int -stat_directory_child(const struct directory *parent, const char *name, +stat_directory_child(const Directory *parent, const char *name, struct stat *st) { char *path_fs = map_directory_child_fs(parent, name); @@ -60,7 +60,7 @@ stat_directory_child(const struct directory *parent, const char *name, } bool -directory_exists(const struct directory *directory) +directory_exists(const Directory *directory) { char *path_fs = map_directory_fs(directory); if (path_fs == NULL) @@ -79,7 +79,7 @@ directory_exists(const struct directory *directory) } bool -directory_child_is_regular(const struct directory *directory, +directory_child_is_regular(const Directory *directory, const char *name_utf8) { char *path_fs = map_directory_child_fs(directory, name_utf8); @@ -94,7 +94,7 @@ directory_child_is_regular(const struct directory *directory, } bool -directory_child_access(const struct directory *directory, +directory_child_access(const Directory *directory, const char *name, int mode) { #ifdef WIN32 diff --git a/src/UpdateIO.hxx b/src/UpdateIO.hxx index 7b6175fdf..ee47b2682 100644 --- a/src/UpdateIO.hxx +++ b/src/UpdateIO.hxx @@ -24,27 +24,27 @@ #include <sys/stat.h> -struct directory; +struct Directory; int -stat_directory(const struct directory *directory, struct stat *st); +stat_directory(const Directory *directory, struct stat *st); int -stat_directory_child(const struct directory *parent, const char *name, +stat_directory_child(const Directory *parent, const char *name, struct stat *st); bool -directory_exists(const struct directory *directory); +directory_exists(const Directory *directory); bool -directory_child_is_regular(const struct directory *directory, +directory_child_is_regular(const Directory *directory, const char *name_utf8); /** * Checks if the given permissions on the mapped file are given. */ bool -directory_child_access(const struct directory *directory, +directory_child_access(const Directory *directory, const char *name, int mode); #endif diff --git a/src/UpdateSong.cxx b/src/UpdateSong.cxx index 299457884..7994ea754 100644 --- a/src/UpdateSong.cxx +++ b/src/UpdateSong.cxx @@ -37,7 +37,7 @@ extern "C" { #include <unistd.h> static void -update_song_file2(struct directory *directory, +update_song_file2(Directory *directory, const char *name, const struct stat *st, const struct decoder_plugin *plugin) { @@ -101,7 +101,7 @@ update_song_file2(struct directory *directory, } bool -update_song_file(struct directory *directory, +update_song_file(Directory *directory, const char *name, const char *suffix, const struct stat *st) { diff --git a/src/UpdateSong.hxx b/src/UpdateSong.hxx index abf25aae9..60a532e3a 100644 --- a/src/UpdateSong.hxx +++ b/src/UpdateSong.hxx @@ -24,10 +24,10 @@ #include <sys/stat.h> -struct directory; +struct Directory; bool -update_song_file(struct directory *directory, +update_song_file(Directory *directory, const char *name, const char *suffix, const struct stat *st); diff --git a/src/UpdateWalk.cxx b/src/UpdateWalk.cxx index b848f124e..4923f083a 100644 --- a/src/UpdateWalk.cxx +++ b/src/UpdateWalk.cxx @@ -87,7 +87,7 @@ update_walk_global_finish(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->device = st->st_dev; @@ -95,12 +95,11 @@ directory_set_stat(struct directory *dir, const struct stat *st) } static void -remove_excluded_from_directory(struct directory *directory, - GSList *exclude_list) +remove_excluded_from_directory(Directory *directory, GSList *exclude_list) { db_lock(); - struct directory *child, *n; + Directory *child, *n; directory_for_each_child_safe(child, n, directory) { char *name_fs = utf8_to_fs_charset(child->GetName()); @@ -129,9 +128,9 @@ remove_excluded_from_directory(struct directory *directory, } 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) { if (directory_exists(child)) continue; @@ -172,7 +171,7 @@ purge_deleted_from_directory(struct directory *directory) #ifndef G_OS_WIN32 static int -update_directory_stat(struct directory *directory) +update_directory_stat(Directory *directory) { struct stat st; if (stat_directory(directory, &st) < 0) @@ -184,7 +183,7 @@ update_directory_stat(struct directory *directory) #endif 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 while (parent) { @@ -208,7 +207,7 @@ find_inode_ancestor(struct directory *parent, ino_t inode, dev_t device) } static bool -update_playlist_file2(struct directory *directory, +update_playlist_file2(Directory *directory, const char *name, const char *suffix, const struct stat *st) { @@ -226,7 +225,7 @@ update_playlist_file2(struct directory *directory, } static bool -update_regular_file(struct directory *directory, +update_regular_file(Directory *directory, const char *name, const struct stat *st) { const char *suffix = uri_get_suffix(name); @@ -239,10 +238,10 @@ update_regular_file(struct directory *directory, } static bool -update_directory(struct directory *directory, const struct stat *st); +update_directory(Directory *directory, const struct stat *st); static void -update_directory_child(struct directory *directory, +update_directory_child(Directory *directory, const char *name, const struct stat *st) { assert(strchr(name, '/') == NULL); @@ -254,7 +253,7 @@ update_directory_child(struct directory *directory, return; db_lock(); - struct directory *subdir = directory->MakeChild(name); + Directory *subdir = directory->MakeChild(name); db_unlock(); assert(directory == subdir->parent); @@ -280,7 +279,7 @@ static bool skip_path(const char *path) G_GNUC_PURE static bool -skip_symlink(const struct directory *directory, const char *utf8_name) +skip_symlink(const Directory *directory, const char *utf8_name) { #ifndef WIN32 char *path_fs = map_directory_child_fs(directory, utf8_name); @@ -353,7 +352,7 @@ skip_symlink(const struct directory *directory, const char *utf8_name) } 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)); @@ -418,11 +417,11 @@ update_directory(struct directory *directory, const struct stat *st) return true; } -static struct directory * -directory_make_child_checked(struct directory *parent, const char *name_utf8) +static Directory * +directory_make_child_checked(Directory *parent, const char *name_utf8) { db_lock(); - directory *directory = parent->FindChild(name_utf8); + Directory *directory = parent->FindChild(name_utf8); db_unlock(); if (directory != NULL) @@ -450,10 +449,10 @@ directory_make_child_checked(struct directory *parent, const char *name_utf8) return directory; } -static struct directory * +static Directory * 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 *name_utf8 = duplicated, *slash; @@ -477,7 +476,7 @@ directory_make_uri_parent_checked(const char *uri) static void 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) return; @@ -502,7 +501,7 @@ update_walk(const char *path, bool discard) if (path != NULL && !isRootDirectory(path)) { update_uri(path); } else { - struct directory *directory = db_get_root(); + Directory *directory = db_get_root(); struct stat st; if (stat_directory(directory, &st) == 0) diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index 938440046..e41ee8819 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -45,7 +45,7 @@ class ProxyDatabase : public Database { unsigned port; struct mpd_connection *connection; - struct directory *root; + Directory *root; public: static Database *Create(const struct config_param *param, @@ -168,7 +168,7 @@ ProxyDatabase::Open(GError **error_r) return false; } - root = directory::NewRoot(); + root = Directory::NewRoot(); return true; } @@ -240,8 +240,7 @@ Visit(struct mpd_connection *connection, const char *path = mpd_directory_get_path(directory); if (visit_directory) { - struct directory *d = - directory::NewGeneric(path, &detached_root); + Directory *d = Directory::NewGeneric(path, &detached_root); bool success = visit_directory(*d, error_r); d->Free(); if (!success) diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index ac2de1b61..04e319498 100644 --- a/src/db/SimpleDatabasePlugin.cxx +++ b/src/db/SimpleDatabasePlugin.cxx @@ -180,7 +180,7 @@ SimpleDatabase::Load(GError **error_r) bool SimpleDatabase::Open(GError **error_r) { - root = directory::NewRoot(); + root = Directory::NewRoot(); mtime = 0; #ifndef NDEBUG @@ -197,7 +197,7 @@ SimpleDatabase::Open(GError **error_r) if (!Check(error_r)) return false; - root = directory::NewRoot(); + root = Directory::NewRoot(); } return true; @@ -243,7 +243,7 @@ SimpleDatabase::ReturnSong(gcc_unused struct song *song) const } G_GNUC_PURE -const struct directory * +const Directory * SimpleDatabase::LookupDirectory(const char *uri) const { assert(root != NULL); @@ -262,7 +262,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, { ScopeDatabaseLock protect; - const directory *directory = root->LookupDirectory(selection.uri); + const Directory *directory = root->LookupDirectory(selection.uri); if (directory == NULL) { if (visit_song) { song *song = root->LookupSong(selection.uri); diff --git a/src/db/SimpleDatabasePlugin.hxx b/src/db/SimpleDatabasePlugin.hxx index 4de39b46c..789dcdae9 100644 --- a/src/db/SimpleDatabasePlugin.hxx +++ b/src/db/SimpleDatabasePlugin.hxx @@ -28,12 +28,12 @@ #include <time.h> -struct directory; +struct Directory; class SimpleDatabase : public Database { std::string path; - struct directory *root; + Directory *root; time_t mtime; @@ -43,7 +43,7 @@ class SimpleDatabase : public Database { public: gcc_pure - struct directory *GetRoot() { + Directory *GetRoot() { assert(root != NULL); return root; @@ -90,7 +90,7 @@ protected: bool Load(GError **error_r); gcc_pure - const struct directory *LookupDirectory(const char *uri) const; + const Directory *LookupDirectory(const char *uri) const; }; extern const DatabasePlugin simple_db_plugin; diff --git a/src/song.h b/src/song.h index 39f916a6a..119d89ccd 100644 --- a/src/song.h +++ b/src/song.h @@ -43,7 +43,7 @@ struct song { struct list_head siblings; struct tag *tag; - struct directory *parent; + struct Directory *parent; time_t mtime; /** @@ -64,7 +64,7 @@ struct song { * A dummy #directory instance that is used for "detached" song * copies. */ -extern struct directory detached_root; +extern struct Directory detached_root; G_BEGIN_DECLS @@ -74,7 +74,7 @@ song_remote_new(const char *uri); /** allocate a new song with a local file name */ 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 @@ -82,7 +82,7 @@ song_file_new(const char *path, struct directory *parent); * data, NULL is returned. */ 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 |