summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/include/dir.h1
-rw-r--r--firmware/target/hosted/android/fs-android.c35
2 files changed, 24 insertions, 12 deletions
diff --git a/firmware/include/dir.h b/firmware/include/dir.h
index 3a582c3865..4f1993143c 100644
--- a/firmware/include/dir.h
+++ b/firmware/include/dir.h
@@ -48,6 +48,7 @@
48#define ATTR_DIRECTORY 0x10 48#define ATTR_DIRECTORY 0x10
49#define ATTR_ARCHIVE 0x20 49#define ATTR_ARCHIVE 0x20
50#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */ 50#define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */
51#define ATTR_LINK 0x80
51 52
52#ifdef HAVE_DIRCACHE 53#ifdef HAVE_DIRCACHE
53# include "dircache.h" 54# include "dircache.h"
diff --git a/firmware/target/hosted/android/fs-android.c b/firmware/target/hosted/android/fs-android.c
index 1967198d3d..c6d22a477e 100644
--- a/firmware/target/hosted/android/fs-android.c
+++ b/firmware/target/hosted/android/fs-android.c
@@ -105,26 +105,37 @@ struct dirinfo dir_get_info(struct DIR* _parent, struct dirent *dir)
105{ 105{
106 struct __dir *parent = (struct __dir*)_parent; 106 struct __dir *parent = (struct __dir*)_parent;
107 struct stat s; 107 struct stat s;
108 struct tm *tm; 108 struct tm *tm = NULL;
109 struct dirinfo ret; 109 struct dirinfo ret;
110 char path[MAX_PATH]; 110 char path[MAX_PATH];
111 111
112 snprintf(path, sizeof(path), "%s/%s", parent->path, dir->d_name); 112 snprintf(path, sizeof(path), "%s/%s", parent->path, dir->d_name);
113 stat(path, &s);
114 memset(&ret, 0, sizeof(ret)); 113 memset(&ret, 0, sizeof(ret));
115 114
116 if (S_ISDIR(s.st_mode)) 115 if (!stat(path, &s))
117 { 116 {
118 ret.attribute = ATTR_DIRECTORY; 117 if (S_ISDIR(s.st_mode))
118 {
119 ret.attribute = ATTR_DIRECTORY;
120 }
121 ret.size = s.st_size;
122 tm = localtime(&(s.st_mtime));
123 }
124
125 if (!lstat(path, &s) && S_ISLNK(s.st_mode))
126 {
127 ret.attribute |= ATTR_LINK;
128 }
129
130 if (tm)
131 {
132 ret.wrtdate = ((tm->tm_year - 80) << 9) |
133 ((tm->tm_mon + 1) << 5) |
134 tm->tm_mday;
135 ret.wrttime = (tm->tm_hour << 11) |
136 (tm->tm_min << 5) |
137 (tm->tm_sec >> 1);
119 } 138 }
120 139
121 ret.size = s.st_size;
122 tm = localtime(&(s.st_mtime));
123 ret.wrtdate = ((tm->tm_year - 80) << 9) |
124 ((tm->tm_mon + 1) << 5) |
125 tm->tm_mday;
126 ret.wrttime = (tm->tm_hour << 11) |
127 (tm->tm_min << 5) |
128 (tm->tm_sec >> 1);
129 return ret; 140 return ret;
130} 141}