diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-03-09 19:26:59 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-03-09 19:26:59 +0000 |
commit | bb9dfa0b02f00f94168640f18491dd65f4309782 (patch) | |
tree | 059914415e05ba395840fcb8fca8c6479fc27065 /uisimulator/common/io.c | |
parent | 7be04578ec829a04f98bf8c1ac5eca60d799a833 (diff) | |
download | rockbox-bb9dfa0b02f00f94168640f18491dd65f4309782.tar.gz rockbox-bb9dfa0b02f00f94168640f18491dd65f4309782.zip |
Simulators: more efficient implementation of sim_filesize().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6175 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/common/io.c')
-rw-r--r-- | uisimulator/common/io.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index 53e2022062..8f72d4f94d 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c | |||
@@ -251,11 +251,16 @@ long sim_lseek(int fildes, long offset, int whence) | |||
251 | 251 | ||
252 | long sim_filesize(int fd) | 252 | long sim_filesize(int fd) |
253 | { | 253 | { |
254 | long old = lseek(fd, 0, SEEK_CUR); | 254 | #ifdef WIN32 |
255 | long size = lseek(fd, 0, SEEK_END); | 255 | return _filelength(fd); |
256 | lseek(fd, old, SEEK_SET); | 256 | #else |
257 | 257 | struct stat buf; | |
258 | return size; | 258 | |
259 | if (!fstat(fd, &buf)) | ||
260 | return buf.st_size; | ||
261 | else | ||
262 | return -1; | ||
263 | #endif | ||
259 | } | 264 | } |
260 | 265 | ||
261 | void fat_size(unsigned int* size, unsigned int* free) | 266 | void fat_size(unsigned int* size, unsigned int* free) |