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 | |
| parent | 7be04578ec829a04f98bf8c1ac5eca60d799a833 (diff) | |
| download | rockbox-bb9dfa0b02f00f94168640f18491dd65f4309782.zip rockbox-bb9dfa0b02f00f94168640f18491dd65f4309782.tar.gz rockbox-bb9dfa0b02f00f94168640f18491dd65f4309782.tar.bz2 rockbox-bb9dfa0b02f00f94168640f18491dd65f4309782.tar.xz | |
Simulators: more efficient implementation of sim_filesize().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6175 a1c6a512-1295-4272-9138-f99709370657
| -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 53e2022..8f72d4f 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) |