forked from len0rd/rockbox
Simulators: lseek() working again for systems with an off_t datatype differing from 'long' (cygwin/x11, maybe others). Removed unused sim_close().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6084 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
00dd42a713
commit
399c081f93
4 changed files with 15 additions and 14 deletions
|
|
@ -135,7 +135,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
(open_func)PREFIX(open),
|
(open_func)PREFIX(open),
|
||||||
close,
|
close,
|
||||||
(read_func)read,
|
(read_func)read,
|
||||||
lseek,
|
PREFIX(lseek),
|
||||||
(creat_func)PREFIX(creat),
|
(creat_func)PREFIX(creat),
|
||||||
(write_func)write,
|
(write_func)write,
|
||||||
PREFIX(remove),
|
PREFIX(remove),
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ struct plugin_api {
|
||||||
int (*PREFIX(open))(const char* pathname, int flags);
|
int (*PREFIX(open))(const char* pathname, int flags);
|
||||||
int (*close)(int fd);
|
int (*close)(int fd);
|
||||||
ssize_t (*read)(int fd, void* buf, size_t count);
|
ssize_t (*read)(int fd, void* buf, size_t count);
|
||||||
off_t (*lseek)(int fd, off_t offset, int whence);
|
off_t (*PREFIX(lseek))(int fd, off_t offset, int whence);
|
||||||
int (*PREFIX(creat))(const char *pathname, mode_t mode);
|
int (*PREFIX(creat))(const char *pathname, mode_t mode);
|
||||||
ssize_t (*write)(int fd, const void* buf, size_t count);
|
ssize_t (*write)(int fd, const void* buf, size_t count);
|
||||||
int (*PREFIX(remove))(const char* pathname);
|
int (*PREFIX(remove))(const char* pathname);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@
|
||||||
#define filesize(x) sim_filesize(x)
|
#define filesize(x) sim_filesize(x)
|
||||||
#define fsync(x) sim_fsync(x)
|
#define fsync(x) sim_fsync(x)
|
||||||
#define ftruncate(x,y) sim_ftruncate(x,y)
|
#define ftruncate(x,y) sim_ftruncate(x,y)
|
||||||
|
#define lseek(x,y,z) sim_lseek(x,y,z)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int (*open_func)(const char* pathname, int flags);
|
typedef int (*open_func)(const char* pathname, int flags);
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,6 @@ void sim_closedir(MYDIR *dir)
|
||||||
free(dir);
|
free(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int sim_open(const char *name, int o)
|
int sim_open(const char *name, int o)
|
||||||
{
|
{
|
||||||
char buffer[256]; /* sufficiently big */
|
char buffer[256]; /* sufficiently big */
|
||||||
|
|
@ -153,7 +152,7 @@ int sim_open(const char *name, int o)
|
||||||
|
|
||||||
if(name[0] == '/') {
|
if(name[0] == '/') {
|
||||||
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
||||||
|
|
||||||
debugf("We open the real file '%s'\n", buffer);
|
debugf("We open the real file '%s'\n", buffer);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
return (open)(buffer, opts);
|
return (open)(buffer, opts);
|
||||||
|
|
@ -166,11 +165,6 @@ int sim_open(const char *name, int o)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sim_close(int fd)
|
|
||||||
{
|
|
||||||
return (close)(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
int sim_creat(const char *name, mode_t mode)
|
int sim_creat(const char *name, mode_t mode)
|
||||||
{
|
{
|
||||||
char buffer[256]; /* sufficiently big */
|
char buffer[256]; /* sufficiently big */
|
||||||
|
|
@ -184,7 +178,7 @@ int sim_creat(const char *name, mode_t mode)
|
||||||
fprintf(stderr, "WARNING, bad file name lacks slash: %s\n",
|
fprintf(stderr, "WARNING, bad file name lacks slash: %s\n",
|
||||||
name);
|
name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sim_mkdir(const char *name, mode_t mode)
|
int sim_mkdir(const char *name, mode_t mode)
|
||||||
{
|
{
|
||||||
|
|
@ -242,13 +236,19 @@ int sim_rename(const char *oldpath, const char* newpath)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t sim_filesize(int fd)
|
/* rockbox off_t may be different from system off_t */
|
||||||
|
long sim_lseek(int fildes, long offset, int whence)
|
||||||
{
|
{
|
||||||
int old = lseek(fd, 0, SEEK_CUR);
|
return lseek(fildes, offset, whence);
|
||||||
int size = lseek(fd, 0, SEEK_END);
|
}
|
||||||
|
|
||||||
|
long sim_filesize(int fd)
|
||||||
|
{
|
||||||
|
long old = lseek(fd, 0, SEEK_CUR);
|
||||||
|
long size = lseek(fd, 0, SEEK_END);
|
||||||
lseek(fd, old, SEEK_SET);
|
lseek(fd, old, SEEK_SET);
|
||||||
|
|
||||||
return(size);
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fat_size(unsigned int* size, unsigned int* free)
|
void fat_size(unsigned int* size, unsigned int* free)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue