summaryrefslogtreecommitdiffstats
path: root/uisimulator/common
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2007-04-06 23:33:33 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2007-04-06 23:33:33 +0000
commit832e0dfb161fcdcab97c2152331b7b2ef5246fa6 (patch)
tree0758f8b96760fece471ebc6e74cd1e2081d2f2e3 /uisimulator/common
parentf9b90e91031dbd23fed24e832de4d8d2e15151a0 (diff)
downloadrockbox-832e0dfb161fcdcab97c2152331b7b2ef5246fa6.tar.gz
rockbox-832e0dfb161fcdcab97c2152331b7b2ef5246fa6.tar.bz2
rockbox-832e0dfb161fcdcab97c2152331b7b2ef5246fa6.zip
Fix file date and time reading in the simulator (used by the properties plugin)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13051 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/common')
-rw-r--r--uisimulator/common/io.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index b03dc01a64..c74629fb18 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdarg.h>
#include <sys/stat.h>
+#include <sys/time.h>
#ifdef __FreeBSD__
#include <sys/param.h>
#include <sys/mount.h>
@@ -136,6 +137,7 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
static struct sim_dirent secret;
struct stat s;
struct dirent *x11 = (readdir)(dir->dir);
+ struct tm* tm;
if(!x11)
return (struct sim_dirent *)0;
@@ -155,9 +157,14 @@ struct sim_dirent *sim_readdir(MYDIR *dir)
secret.attribute = S_ISDIR(s.st_mode)?ATTR_DIRECTORY:0;
secret.size = s.st_size;
- secret.wrtdate = (unsigned short)(s.st_mtime >> 16);
- secret.wrttime = (unsigned short)(s.st_mtime & 0xFFFF);
+ tm = localtime(&(s.st_mtime));
+ secret.wrtdate = ((tm->tm_year - 80) << 9) |
+ ((tm->tm_mon + 1) << 5) |
+ tm->tm_mday;
+ secret.wrttime = (tm->tm_hour << 11) |
+ (tm->tm_min << 5) |
+ (tm->tm_sec >> 1);
return &secret;
}