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