storage: add storage_network_get_mtime

This commit is contained in:
Denis Kenzior 2015-06-18 03:19:28 -05:00
parent e153d94989
commit cbff1372e8
2 changed files with 28 additions and 0 deletions

View File

@ -203,6 +203,32 @@ int storage_network_touch(const char *type, const char *ssid)
return -errno;
}
int storage_network_get_mtime(const char *type, const char *ssid,
struct timespec *mtim)
{
char *path;
int ret;
struct stat sb;
if (ssid == NULL || type == NULL)
return -EINVAL;
path = l_strdup_printf(STORAGEDIR "/%s.%s", ssid, type);
ret = stat(path, &sb);
l_free(path);
if (ret < 0)
return -errno;
if (!S_ISREG(sb.st_mode))
return -EINVAL;
if (mtim)
memcpy(mtim, &sb.st_mtim, sizeof(struct timespec));
return 0;
}
void storage_network_sync(const char *type, const char *ssid,
struct l_settings *settings)
{

View File

@ -32,5 +32,7 @@ ssize_t write_file(const void *buffer, size_t len, const char *path_fmt, ...)
struct l_settings *storage_network_open(const char *type, const char *ssid);
int storage_network_touch(const char *type, const char *ssid);
int storage_network_get_mtime(const char *type, const char *ssid,
struct timespec *mtim);
void storage_network_sync(const char *type, const char *ssid,
struct l_settings *settings);