MPD 0.17~git
src/database.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003-2011 The Music Player Daemon Project
00003  * http://www.musicpd.org
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 
00020 #ifndef MPD_DATABASE_H
00021 #define MPD_DATABASE_H
00022 
00023 #include "gcc.h"
00024 
00025 #include <glib.h>
00026 
00027 #include <sys/time.h>
00028 #include <stdbool.h>
00029 
00030 struct config_param;
00031 struct directory;
00032 struct db_selection;
00033 struct db_visitor;
00034 
00040 bool
00041 db_init(const struct config_param *path, GError **error_r);
00042 
00043 void
00044 db_finish(void);
00045 
00050 struct directory *
00051 db_get_root(void);
00052 
00056 gcc_nonnull(1)
00057 struct directory *
00058 db_get_directory(const char *name);
00059 
00060 gcc_nonnull(1)
00061 struct song *
00062 db_get_song(const char *file);
00063 
00064 gcc_nonnull(1,2)
00065 bool
00066 db_visit(const struct db_selection *selection,
00067          const struct db_visitor *visitor, void *ctx,
00068          GError **error_r);
00069 
00070 gcc_nonnull(1,2)
00071 bool
00072 db_walk(const char *uri,
00073         const struct db_visitor *visitor, void *ctx,
00074         GError **error_r);
00075 
00076 bool
00077 db_check(GError **error_r);
00078 
00079 bool
00080 db_save(GError **error_r);
00081 
00082 bool
00083 db_load(GError **error);
00084 
00085 time_t
00086 db_get_mtime(void);
00087 
00091 static inline bool
00092 db_exists(void)
00093 {
00094         /* mtime is set only if the database file was loaded or saved
00095            successfully */
00096         return db_get_mtime() > 0;
00097 }
00098 
00099 #endif