fat: move fattime_mktime to timefuncs
This moves the time conversion function to timefuncs since it has uses on ports that don't use the FAT driver. This function has no dependency on the FAT driver as it is so this should not cause any issues. To reflect this separation the function was renamed to dostime_mktime since it is really for DOS timestamps. The places where it was used have also been updated. Change-Id: Id98b1448d5c6fcda286846e1d2c736db682bfb52
This commit is contained in:
parent
d1a92aafff
commit
c9f2308a1d
6 changed files with 19 additions and 17 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "debug.h"
|
||||
#include "dir.h"
|
||||
#include "pathfuncs.h"
|
||||
#include "timefuncs.h"
|
||||
#include "fileobj_mgr.h"
|
||||
#include "dircache_redirect.h"
|
||||
|
||||
|
@ -406,7 +407,7 @@ struct dirinfo dir_get_info(DIR *dirp, struct dirent *entry)
|
|||
{
|
||||
.attribute = entry->info.attr,
|
||||
.size = entry->info.size,
|
||||
.mtime = fattime_mktime(entry->info.wrtdate, entry->info.wrttime),
|
||||
.mtime = dostime_mktime(entry->info.wrtdate, entry->info.wrttime),
|
||||
};
|
||||
|
||||
file_error:
|
||||
|
|
|
@ -2956,7 +2956,7 @@ void dircache_dump(void)
|
|||
FOR_EACH_CACHE_ENTRY(ce)
|
||||
{
|
||||
#ifdef DIRCACHE_NATIVE
|
||||
time_t mtime = fattime_mktime(ce->wrtdate, ce->wrttime);
|
||||
time_t mtime = dostime_mktime(ce->wrtdate, ce->wrttime);
|
||||
#else
|
||||
time_t mtime = ce->mtime;
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,20 @@
|
|||
|
||||
static struct tm tm;
|
||||
|
||||
time_t dostime_mktime(uint16_t dosdate, uint16_t dostime)
|
||||
{
|
||||
/* this knows our mktime() only uses these struct tm fields */
|
||||
struct tm tm;
|
||||
tm.tm_sec = ((dostime ) & 0x1f) * 2;
|
||||
tm.tm_min = ((dostime >> 5) & 0x3f);
|
||||
tm.tm_hour = ((dostime >> 11) );
|
||||
tm.tm_mday = ((dosdate ) & 0x1f);
|
||||
tm.tm_mon = ((dosdate >> 5) & 0x0f) - 1;
|
||||
tm.tm_year = ((dosdate >> 9) ) + 80;
|
||||
|
||||
return mktime(&tm);
|
||||
}
|
||||
|
||||
#if !CONFIG_RTC
|
||||
static inline bool rtc_dirty(void)
|
||||
{
|
||||
|
|
|
@ -2954,20 +2954,6 @@ void fat_empty_fat_direntry(struct fat_direntry *entry)
|
|||
entry->firstcluster = 0;
|
||||
}
|
||||
|
||||
time_t fattime_mktime(uint16_t fatdate, uint16_t fattime)
|
||||
{
|
||||
/* this knows our mktime() only uses these struct tm fields */
|
||||
struct tm tm;
|
||||
tm.tm_sec = ((fattime ) & 0x1f) * 2;
|
||||
tm.tm_min = ((fattime >> 5) & 0x3f);
|
||||
tm.tm_hour = ((fattime >> 11) );
|
||||
tm.tm_mday = ((fatdate ) & 0x1f);
|
||||
tm.tm_mon = ((fatdate >> 5) & 0x0f) - 1;
|
||||
tm.tm_year = ((fatdate >> 9) ) + 80;
|
||||
|
||||
return mktime(&tm);
|
||||
}
|
||||
|
||||
void fat_init(void)
|
||||
{
|
||||
dc_lock_cache();
|
||||
|
|
|
@ -174,7 +174,6 @@ void fat_recalc_free(IF_MV_NONVOID(int volume));
|
|||
bool fat_size(IF_MV(int volume,) unsigned long *size, unsigned long *free);
|
||||
|
||||
/** Misc. **/
|
||||
time_t fattime_mktime(uint16_t fatdate, uint16_t fattime);
|
||||
void fat_empty_fat_direntry(struct fat_direntry *entry);
|
||||
void fat_init(void);
|
||||
|
||||
|
|
|
@ -24,8 +24,10 @@
|
|||
|
||||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "time.h"
|
||||
|
||||
time_t dostime_mktime(uint16_t dosdate, uint16_t dostime);
|
||||
struct tm *get_time(void);
|
||||
int set_time(const struct tm *tm);
|
||||
#if CONFIG_RTC
|
||||
|
|
Loading…
Reference in a new issue