diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/fat.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index cc9735d0f7..28d4eb1987 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -2276,6 +2276,41 @@ fat_error: | |||
2276 | return rc; | 2276 | return rc; |
2277 | } | 2277 | } |
2278 | 2278 | ||
2279 | int fat_utime(struct fat_file *parent, struct fat_file *file, | ||
2280 | const struct utimbuf *times) | ||
2281 | { | ||
2282 | struct bpb * const fat_bpb = FAT_BPB(parent->volume); | ||
2283 | |||
2284 | if (!fat_bpb) | ||
2285 | return -1; | ||
2286 | |||
2287 | int rc; | ||
2288 | |||
2289 | struct fat_filestr parentstr; | ||
2290 | fat_filestr_init(&parentstr, parent); | ||
2291 | |||
2292 | dc_lock_cache(); | ||
2293 | |||
2294 | union raw_dirent *ent = cache_direntry(fat_bpb, &parentstr, file->e.entry); | ||
2295 | if (!ent) | ||
2296 | FAT_ERROR(-2); | ||
2297 | |||
2298 | uint16_t date; | ||
2299 | uint16_t time; | ||
2300 | dostime_localtime(times->modtime, &date, &time); | ||
2301 | |||
2302 | ent->wrttime = htole16(time); | ||
2303 | ent->wrtdate = htole16(date); | ||
2304 | ent->lstaccdate = htole16(date); | ||
2305 | |||
2306 | dc_dirty_buf(ent); | ||
2307 | |||
2308 | rc = 0; | ||
2309 | fat_error: | ||
2310 | dc_unlock_cache(); | ||
2311 | cache_commit(fat_bpb); | ||
2312 | return rc; | ||
2313 | } | ||
2279 | 2314 | ||
2280 | /** File stream functions **/ | 2315 | /** File stream functions **/ |
2281 | 2316 | ||