summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-03-09 19:26:59 +0000
committerJens Arnold <amiconn@rockbox.org>2005-03-09 19:26:59 +0000
commitbb9dfa0b02f00f94168640f18491dd65f4309782 (patch)
tree059914415e05ba395840fcb8fca8c6479fc27065 /uisimulator
parent7be04578ec829a04f98bf8c1ac5eca60d799a833 (diff)
downloadrockbox-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')
-rw-r--r--uisimulator/common/io.c15
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)
long sim_filesize(int fd)
{
- long old = lseek(fd, 0, SEEK_CUR);
- long size = lseek(fd, 0, SEEK_END);
- lseek(fd, old, SEEK_SET);
-
- return size;
+#ifdef WIN32
+ return _filelength(fd);
+#else
+ struct stat buf;
+
+ if (!fstat(fd, &buf))
+ return buf.st_size;
+ else
+ return -1;
+#endif
}
void fat_size(unsigned int* size, unsigned int* free)