summaryrefslogtreecommitdiff
path: root/firmware/common
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common')
-rw-r--r--firmware/common/file.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c
index cb918c6eab..c090c40be5 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -1123,6 +1123,44 @@ file_error:
1123 return rc; 1123 return rc;
1124} 1124}
1125 1125
1126int utime(const char *path, const struct utimbuf* times)
1127{
1128 DEBUGF("utime(path=\"%s\",times->modtime=%u)\n", path, times->modtime);
1129
1130 int rc, open1rc = -1;
1131 struct filestr_base pathstr;
1132 struct path_component_info pathinfo;
1133
1134 file_internal_lock_WRITER();
1135
1136 if (!times)
1137 FILE_ERROR(EINVAL, -1);
1138
1139 open1rc = open_stream_internal(path, FF_ANYTYPE | FF_PARENTINFO,
1140 &pathstr, &pathinfo);
1141 if (open1rc <= 0)
1142 {
1143 DEBUGF("Failed opening path: %d\n", open1rc);
1144 if (open1rc == 0)
1145 FILE_ERROR(ENOENT, -2);
1146 else
1147 FILE_ERROR(ERRNO, open1rc * 10 - 1);
1148 }
1149
1150 rc = fat_utime(&pathinfo.parentinfo.fatfile, pathstr.fatstr.fatfilep,
1151 times);
1152 if (rc < 0)
1153 {
1154 DEBUGF("I/O error during utime: %d\n", rc);
1155 FILE_ERROR(ERRNO, rc * 10 - 2);
1156 }
1157
1158file_error:
1159 if (open1rc >= 0)
1160 close_stream_internal(&pathstr);
1161 file_internal_unlock_WRITER();
1162 return rc;
1163}
1126 1164
1127/** Extensions **/ 1165/** Extensions **/
1128 1166