mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-09 07:08:07 +02:00
UpHistory: Add method to set history dir
Add up_history_set_directory() method to change the directory for history files. This is mainly useful for our test suite.
This commit is contained in:
parent
809eefc145
commit
a4353d0801
2 changed files with 16 additions and 1 deletions
|
|
@ -53,6 +53,7 @@ struct UpHistoryPrivate
|
|||
GPtrArray *data_time_empty;
|
||||
guint save_id;
|
||||
guint max_data_age;
|
||||
gchar *dir;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -394,11 +395,21 @@ up_history_get_filename (UpHistory *history, const gchar *type)
|
|||
gchar *filename;
|
||||
|
||||
filename = g_strdup_printf ("history-%s-%s.dat", type, history->priv->id);
|
||||
path = g_build_filename (PACKAGE_LOCALSTATE_DIR, "lib", "upower", filename, NULL);
|
||||
path = g_build_filename (history->priv->dir, filename, NULL);
|
||||
g_free (filename);
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* up_history_set_directory:
|
||||
**/
|
||||
void
|
||||
up_history_set_directory (UpHistory *history, const gchar *dir)
|
||||
{
|
||||
g_free (history->priv->dir);
|
||||
history->priv->dir = g_strdup (dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* up_history_array_to_file:
|
||||
* @list: a valid #GPtrArray instance
|
||||
|
|
@ -877,6 +888,7 @@ up_history_init (UpHistory *history)
|
|||
history->priv->data_time_empty = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||
history->priv->save_id = 0;
|
||||
history->priv->max_data_age = UP_HISTORY_DEFAULT_MAX_DATA_AGE;
|
||||
history->priv->dir = g_build_filename (PACKAGE_LOCALSTATE_DIR, "lib", "upower", NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ void up_history_set_max_data_age (UpHistory *history,
|
|||
guint max_data_age);
|
||||
gboolean up_history_save_data (UpHistory *history);
|
||||
|
||||
void up_history_set_directory (UpHistory *history,
|
||||
const gchar *dir);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __UP_HISTORY_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue