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)
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;
......
......@@ -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());
......
......@@ -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;
......
......@@ -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
......@@ -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);
/**
......
......@@ -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;
......
......@@ -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))
......
......@@ -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));
}
......
......@@ -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);
......
......@@ -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
......@@ -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);
......
......@@ -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
......
......@@ -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 &&
......
......@@ -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
......
......@@ -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
......@@ -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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -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,
......
......@@ -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)
{
......
......@@ -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)
......
......@@ -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();
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......@@ -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
......
......@@ -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
......@@ -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)
{
......
......@@ -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);
......
......@@ -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)
......
......@@ -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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -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
......
......@@ -48,7 +48,7 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
}
static bool
DumpDirectory(const directory &directory, GError **)
DumpDirectory(const Directory &directory, GError **)
{
cout << "D " << directory.path << endl;
return true;
......@@ -63,7 +63,7 @@ DumpSong(song &song, GError **)
static bool
DumpPlaylist(const PlaylistInfo &playlist,
const directory &directory, GError **)
const Directory &directory, GError **)
{
cout << "P " << directory.path << "/" << playlist.name.c_str() << endl;
return true;
......
......@@ -5,7 +5,7 @@ extern "C" {
#include "song.h"
#include "Directory.hxx"
struct directory detached_root;
Directory detached_root;
struct song *
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