src/directory.h File Reference

#include "check.h"
#include "util/list.h"
#include <glib.h>
#include <stdbool.h>
#include <sys/types.h>

Go to the source code of this file.

Data Structures

struct  directory

Defines

#define DEVICE_INARCHIVE   (dev_t)(-1)
#define DEVICE_CONTAINER   (dev_t)(-2)
#define directory_for_each_child(pos, directory)   list_for_each_entry(pos, &directory->children, siblings)
#define directory_for_each_child_safe(pos, n, directory)   list_for_each_entry_safe(pos, n, &directory->children, siblings)
#define directory_for_each_song(pos, directory)   list_for_each_entry(pos, &directory->songs, siblings)
#define directory_for_each_song_safe(pos, n, directory)   list_for_each_entry_safe(pos, n, &directory->songs, siblings)
#define directory_for_each_playlist(pos, directory)   list_for_each_entry(pos, &directory->playlists, siblings)
#define directory_for_each_playlist_safe(pos, n, directory)   list_for_each_entry_safe(pos, n, &directory->playlists, siblings)

Functions

static bool isRootDirectory (const char *name)
G_GNUC_MALLOC struct directorydirectory_new (const char *dirname, struct directory *parent)
 Generic constructor for directory object.
static G_GNUC_MALLOC struct
directory
directory_new_root (void)
 Create a new root directory object.
void directory_free (struct directory *directory)
 Free this directory object (and the whole object tree within it), assuming it was already removed from the parent.
void directory_delete (struct directory *directory)
 Remove this directory object from its parent and free it.
static bool directory_is_empty (const struct directory *directory)
static const char * directory_get_path (const struct directory *directory)
static bool directory_is_root (const struct directory *directory)
 Is this the root directory of the music database?
G_GNUC_PURE const char * directory_get_name (const struct directory *directory)
 Returns the base name of the directory.
G_GNUC_PURE struct directorydirectory_get_child (const struct directory *directory, const char *name)
 Caller must lock the db_mutex.
G_GNUC_MALLOC struct directorydirectory_new_child (struct directory *parent, const char *name_utf8)
 Create a new directory object as a child of the given one.
static struct directorydirectory_make_child (struct directory *directory, const char *name_utf8)
 Look up a sub directory, and create the object if it does not exist.
void directory_prune_empty (struct directory *directory)
 Caller must lock the db_mutex.
struct directorydirectory_lookup_directory (struct directory *directory, const char *uri)
 Looks up a directory by its relative URI.
void directory_add_song (struct directory *directory, struct song *song)
 Add a song object to this directory.
void directory_remove_song (struct directory *directory, struct song *song)
 Remove a song object from this directory (which effectively invalidates the song object, because the "parent" attribute becomes stale), but does not free it.
G_GNUC_PURE struct songdirectory_get_song (const struct directory *directory, const char *name_utf8)
 Look up a song in this directory by its name.
struct songdirectory_lookup_song (struct directory *directory, const char *uri)
 Looks up a song by its relative URI.
void directory_sort (struct directory *directory)
 Sort all directory entries recursively.
bool directory_walk (const struct directory *directory, bool recursive, const struct db_visitor *visitor, void *ctx, GError **error_r)
 Caller must lock db_mutex.

Define Documentation

#define DEVICE_CONTAINER   (dev_t)(-2)

Definition at line 31 of file directory.h.

#define DEVICE_INARCHIVE   (dev_t)(-1)

Definition at line 30 of file directory.h.

#define directory_for_each_child ( pos,
directory   )     list_for_each_entry(pos, &directory->children, siblings)

Definition at line 33 of file directory.h.

#define directory_for_each_child_safe ( pos,
n,
directory   )     list_for_each_entry_safe(pos, n, &directory->children, siblings)

Definition at line 36 of file directory.h.

#define directory_for_each_playlist ( pos,
directory   )     list_for_each_entry(pos, &directory->playlists, siblings)

Definition at line 45 of file directory.h.

#define directory_for_each_playlist_safe ( pos,
n,
directory   )     list_for_each_entry_safe(pos, n, &directory->playlists, siblings)

Definition at line 48 of file directory.h.

#define directory_for_each_song ( pos,
directory   )     list_for_each_entry(pos, &directory->songs, siblings)

Definition at line 39 of file directory.h.

#define directory_for_each_song_safe ( pos,
n,
directory   )     list_for_each_entry_safe(pos, n, &directory->songs, siblings)

Definition at line 42 of file directory.h.


Function Documentation

void directory_add_song ( struct directory directory,
struct song song 
)

Add a song object to this directory.

Its "parent" attribute must be set already.

void directory_delete ( struct directory 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 directory_free ( struct directory directory  ) 

Free this directory object (and the whole object tree within it), assuming it was already removed from the parent.

G_GNUC_PURE struct directory* directory_get_child ( const struct directory directory,
const char *  name 
) [read]

Caller must lock the db_mutex.

G_GNUC_PURE const char* directory_get_name ( const struct directory directory  ) 

Returns the base name of the directory.

static const char* directory_get_path ( const struct directory directory  )  [inline, static]

Definition at line 139 of file directory.h.

G_GNUC_PURE struct song* directory_get_song ( const struct directory directory,
const char *  name_utf8 
) [read]

Look up a song in this directory by its name.

Caller must lock the db_mutex.

static bool directory_is_empty ( const struct directory directory  )  [inline, static]

Definition at line 131 of file directory.h.

static bool directory_is_root ( const struct directory directory  )  [inline, static]

Is this the root directory of the music database?

Definition at line 148 of file directory.h.

struct directory* directory_lookup_directory ( struct directory directory,
const char *  uri 
) [read]

Looks up a directory by its relative URI.

Parameters:
directory the parent (or grandparent, ...) directory
uri the relative URI
Returns:
the directory, or NULL if none was found
struct song* directory_lookup_song ( struct directory directory,
const char *  uri 
) [read]

Looks up a song by its relative URI.

Caller must lock the db_mutex.

Parameters:
directory the parent (or grandparent, ...) directory
uri the relative URI
Returns:
the song, or NULL if none was found
static struct directory* directory_make_child ( struct directory directory,
const char *  name_utf8 
) [static, read]

Look up a sub directory, and create the object if it does not exist.

Caller must lock the db_mutex.

Definition at line 186 of file directory.h.

G_GNUC_MALLOC struct directory* directory_new ( const char *  dirname,
struct directory parent 
) [read]

Generic constructor for directory object.

G_GNUC_MALLOC struct directory* directory_new_child ( struct directory parent,
const char *  name_utf8 
) [read]

Create a new directory object as a child of the given one.

Caller must lock the db_mutex.

Parameters:
parent the parent directory the new one will be added to
name_utf8 the UTF-8 encoded name of the new sub directory
static G_GNUC_MALLOC struct directory* directory_new_root ( void   )  [static, read]

Create a new root directory object.

Definition at line 109 of file directory.h.

void directory_prune_empty ( struct directory directory  ) 

Caller must lock the db_mutex.

void directory_remove_song ( struct directory directory,
struct song song 
)

Remove a song object from this directory (which effectively invalidates the song object, because the "parent" attribute becomes stale), but does not free it.

void directory_sort ( struct directory directory  ) 

Sort all directory entries recursively.

Caller must lock the db_mutex.

bool directory_walk ( const struct directory directory,
bool  recursive,
const struct db_visitor visitor,
void *  ctx,
GError **  error_r 
)

Caller must lock db_mutex.

static bool isRootDirectory ( const char *  name  )  [inline, static]

Definition at line 92 of file directory.h.


Generated on 9 Aug 2013 for MPD by  doxygen 1.6.1