diff options
-rw-r--r-- | firmware/SOURCES | 4 | ||||
-rw-r--r-- | firmware/common/rbpaths.c | 14 | ||||
-rw-r--r-- | firmware/target/hosted/android/dir-target.h | 9 | ||||
-rw-r--r-- | firmware/target/hosted/android/fs-android.c | 141 | ||||
-rw-r--r-- | firmware/target/hosted/filesystem-unix.c (renamed from firmware/target/hosted/ypr0/fs-ypr0.c) | 0 | ||||
-rw-r--r-- | firmware/target/hosted/ypr0/dir-target.h | 9 |
6 files changed, 9 insertions, 168 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 19b0efd089..b2ddc246ec 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -78,10 +78,10 @@ drivers/rtc/rtc_as3514.c | |||
78 | target/hosted/rtc.c | 78 | target/hosted/rtc.c |
79 | #endif | 79 | #endif |
80 | target/hosted/kernel-unix.c | 80 | target/hosted/kernel-unix.c |
81 | target/hosted/filesystem-unix.c | ||
81 | target/hosted/ypr0/button-ypr0.c | 82 | target/hosted/ypr0/button-ypr0.c |
82 | target/hosted/ypr0/lcd-ypr0.c | 83 | target/hosted/ypr0/lcd-ypr0.c |
83 | target/hosted/ypr0/system-ypr0.c | 84 | target/hosted/ypr0/system-ypr0.c |
84 | target/hosted/ypr0/fs-ypr0.c | ||
85 | target/hosted/ypr0/lc-ypr0.c | 85 | target/hosted/ypr0/lc-ypr0.c |
86 | thread.c | 86 | thread.c |
87 | #ifdef HAVE_BACKLIGHT | 87 | #ifdef HAVE_BACKLIGHT |
@@ -1693,7 +1693,7 @@ target/arm/rk27xx/hm801/power-hm801.c | |||
1693 | 1693 | ||
1694 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) | 1694 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) |
1695 | target/hosted/kernel-unix.c | 1695 | target/hosted/kernel-unix.c |
1696 | target/hosted/android/fs-android.c | 1696 | target/hosted/filesystem-unix.c |
1697 | target/hosted/android/lcd-android.c | 1697 | target/hosted/android/lcd-android.c |
1698 | target/hosted/android/lc-android.c | 1698 | target/hosted/android/lc-android.c |
1699 | target/hosted/android/button-android.c | 1699 | target/hosted/android/button-android.c |
diff --git a/firmware/common/rbpaths.c b/firmware/common/rbpaths.c index aacd949430..f5a484273c 100644 --- a/firmware/common/rbpaths.c +++ b/firmware/common/rbpaths.c | |||
@@ -40,17 +40,13 @@ | |||
40 | #undef rmdir | 40 | #undef rmdir |
41 | 41 | ||
42 | 42 | ||
43 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) | 43 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) || defined(SAMSUNG_YPR0) |
44 | #include "dir-target.h" | 44 | #include "dir-target.h" |
45 | #define opendir opendir_android | 45 | #define opendir _opendir |
46 | #define mkdir mkdir_android | 46 | #define mkdir _mkdir |
47 | #define rmdir rmdir_android | 47 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) |
48 | static const char rbhome[] = "/sdcard"; | 48 | static const char rbhome[] = "/sdcard"; |
49 | #elif defined(SAMSUNG_YPR0) | 49 | #endif |
50 | #include "dir-target.h" | ||
51 | #define opendir opendir_ypr0 | ||
52 | #define mkdir mkdir_ypr0 | ||
53 | #define rmdir rmdir_ypr0 | ||
54 | #elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) | 50 | #elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) |
55 | #define open sim_open | 51 | #define open sim_open |
56 | #define remove sim_remove | 52 | #define remove sim_remove |
diff --git a/firmware/target/hosted/android/dir-target.h b/firmware/target/hosted/android/dir-target.h index c6c6b4b2b0..6962d943fe 100644 --- a/firmware/target/hosted/android/dir-target.h +++ b/firmware/target/hosted/android/dir-target.h | |||
@@ -32,16 +32,9 @@ | |||
32 | #define mkdir_uncached _mkdir | 32 | #define mkdir_uncached _mkdir |
33 | #define rmdir_uncached rmdir | 33 | #define rmdir_uncached rmdir |
34 | 34 | ||
35 | #define dirent_android dirent | ||
36 | #define DIR_android DIR | ||
37 | #define opendir_android _opendir | ||
38 | #define readdir_android _readdir | ||
39 | #define closedir_android _closedir | ||
40 | #define mkdir_android _mkdir | ||
41 | #define rmdir_android rmdir | ||
42 | |||
43 | extern DIR* _opendir(const char* name); | 35 | extern DIR* _opendir(const char* name); |
44 | extern int _mkdir(const char* name); | 36 | extern int _mkdir(const char* name); |
37 | extern int rmdir(const char* name); | ||
45 | extern int _closedir(DIR* dir); | 38 | extern int _closedir(DIR* dir); |
46 | extern struct dirent *_readdir(DIR* dir); | 39 | extern struct dirent *_readdir(DIR* dir); |
47 | extern void fat_size(unsigned long *size, unsigned long *free); | 40 | extern void fat_size(unsigned long *size, unsigned long *free); |
diff --git a/firmware/target/hosted/android/fs-android.c b/firmware/target/hosted/android/fs-android.c deleted file mode 100644 index c6d22a477e..0000000000 --- a/firmware/target/hosted/android/fs-android.c +++ /dev/null | |||
@@ -1,141 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 by Thomas Martitz | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include <sys/stat.h> /* stat() */ | ||
24 | #include <stdio.h> /* snprintf */ | ||
25 | #include <string.h> /* size_t */ | ||
26 | #include <dirent.h> | ||
27 | #include <time.h> /* localtime() */ | ||
28 | #include "system-target.h" | ||
29 | #include "dir-target.h" | ||
30 | #include "file.h" | ||
31 | #include "dir.h" | ||
32 | #include "rbpaths.h" | ||
33 | |||
34 | |||
35 | long filesize(int fd) | ||
36 | { | ||
37 | struct stat buf; | ||
38 | |||
39 | if (!fstat(fd, &buf)) | ||
40 | return buf.st_size; | ||
41 | else | ||
42 | return -1; | ||
43 | } | ||
44 | |||
45 | /* do we really need this in the app? */ | ||
46 | void fat_size(unsigned long* size, unsigned long* free) | ||
47 | { | ||
48 | *size = *free = 0; | ||
49 | } | ||
50 | |||
51 | #undef opendir | ||
52 | #undef closedir | ||
53 | #undef mkdir | ||
54 | #undef readdir | ||
55 | |||
56 | /* need to wrap around DIR* because we need to save the parent's | ||
57 | * directory path in order to determine dirinfo */ | ||
58 | struct __dir { | ||
59 | DIR *dir; | ||
60 | char *path; | ||
61 | }; | ||
62 | |||
63 | DIR* _opendir(const char *name) | ||
64 | { | ||
65 | char *buf = malloc(sizeof(struct __dir) + strlen(name)+1); | ||
66 | if (!buf) | ||
67 | return NULL; | ||
68 | |||
69 | struct __dir *this = (struct __dir*)buf; | ||
70 | |||
71 | this->path = buf+sizeof(struct __dir); | ||
72 | /* definitely fits due to strlen() */ | ||
73 | strcpy(this->path, name); | ||
74 | |||
75 | this->dir = opendir(name); | ||
76 | |||
77 | if (!this->dir) | ||
78 | { | ||
79 | free(buf); | ||
80 | return NULL; | ||
81 | } | ||
82 | return (DIR*)this; | ||
83 | } | ||
84 | |||
85 | int _mkdir(const char *name) | ||
86 | { | ||
87 | return mkdir(name, 0777); | ||
88 | } | ||
89 | |||
90 | int _closedir(DIR *dir) | ||
91 | { | ||
92 | struct __dir *this = (struct __dir*)dir; | ||
93 | int ret = closedir(this->dir); | ||
94 | free(this); | ||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | struct dirent* _readdir(DIR* dir) | ||
99 | { | ||
100 | struct __dir *d = (struct __dir*)dir; | ||
101 | return readdir(d->dir); | ||
102 | } | ||
103 | |||
104 | struct dirinfo dir_get_info(struct DIR* _parent, struct dirent *dir) | ||
105 | { | ||
106 | struct __dir *parent = (struct __dir*)_parent; | ||
107 | struct stat s; | ||
108 | struct tm *tm = NULL; | ||
109 | struct dirinfo ret; | ||
110 | char path[MAX_PATH]; | ||
111 | |||
112 | snprintf(path, sizeof(path), "%s/%s", parent->path, dir->d_name); | ||
113 | memset(&ret, 0, sizeof(ret)); | ||
114 | |||
115 | if (!stat(path, &s)) | ||
116 | { | ||
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); | ||
138 | } | ||
139 | |||
140 | return ret; | ||
141 | } | ||
diff --git a/firmware/target/hosted/ypr0/fs-ypr0.c b/firmware/target/hosted/filesystem-unix.c index 7f49a5f91a..7f49a5f91a 100644 --- a/firmware/target/hosted/ypr0/fs-ypr0.c +++ b/firmware/target/hosted/filesystem-unix.c | |||
diff --git a/firmware/target/hosted/ypr0/dir-target.h b/firmware/target/hosted/ypr0/dir-target.h index 48859526df..7df9554e92 100644 --- a/firmware/target/hosted/ypr0/dir-target.h +++ b/firmware/target/hosted/ypr0/dir-target.h | |||
@@ -35,16 +35,9 @@ extern int rmdir(const char* name); | |||
35 | #define mkdir_uncached _mkdir | 35 | #define mkdir_uncached _mkdir |
36 | #define rmdir_uncached rmdir | 36 | #define rmdir_uncached rmdir |
37 | 37 | ||
38 | #define dirent_ypr0 dirent | ||
39 | #define DIR_ypr0 DIR | ||
40 | #define opendir_ypr0 _opendir | ||
41 | #define readdir_ypr0 _readdir | ||
42 | #define closedir_ypr0 _closedir | ||
43 | #define mkdir_ypr0 _mkdir | ||
44 | #define rmdir_ypr0 rmdir | ||
45 | |||
46 | extern DIR* _opendir(const char* name); | 38 | extern DIR* _opendir(const char* name); |
47 | extern int _mkdir(const char* name); | 39 | extern int _mkdir(const char* name); |
40 | extern int _rmdir(const char* name); | ||
48 | extern int _closedir(DIR* dir); | 41 | extern int _closedir(DIR* dir); |
49 | extern struct dirent *_readdir(DIR* dir); | 42 | extern struct dirent *_readdir(DIR* dir); |
50 | extern void fat_size(unsigned long *size, unsigned long *free); | 43 | extern void fat_size(unsigned long *size, unsigned long *free); |