mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-09 23:53:28 -04:00
Add "rbfs" prefix to native filesystem functions
Most of the churn here occurs because 'filesize' is one of the redefined filesystem functions, but some of the structs used by the native FS code also include a 'filesize' member variable which gets renamed by the macro in some but not all source files. It's easier to rename 'filesize()' to 'ffilesize()' rather than try to clean up the macro mess or renaming the struct members. There is weirdness with root_realpath() which now breaks on native builds because it was assumed to be unprefixed there. dir_get_info() was unprefixed everywhere but this just seems inconsistent; make it follow the FS_PREFIX() convention too. Change-Id: Ic3700c6234ea45f32679c1a8429d70fdb8f4088a
This commit is contained in:
parent
6958f6638e
commit
3a57f2f721
105 changed files with 188 additions and 182 deletions
|
|
@ -692,7 +692,7 @@ static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((first_line != 0) && ((size_t) filesize(file) < bookmarks->buffer_size
|
||||
if ((first_line != 0) && ((size_t) ffilesize(file) < bookmarks->buffer_size
|
||||
- sizeof(*bookmarks) - (sizeof(char*) * bookmarks->total_count)))
|
||||
{
|
||||
/* Entire file fits in buffer */
|
||||
|
|
|
|||
|
|
@ -982,7 +982,7 @@ int bufopen(const char *file, off_t offset, enum data_type type,
|
|||
#endif /* HAVE_ALBUMART */
|
||||
|
||||
if (size == 0)
|
||||
size = filesize(fd);
|
||||
size = ffilesize(fd);
|
||||
|
||||
unsigned int hflags = 0;
|
||||
if (type == TYPE_PACKET_AUDIO || type == TYPE_CODEC)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ static int open_key_remap(const char *filename, int *countp)
|
|||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
size_t fsize = filesize(fd);
|
||||
size_t fsize = ffilesize(fd);
|
||||
int count = fsize / sizeof(struct button_mapping);
|
||||
if (count == 0 || (size_t)(count * sizeof(struct button_mapping)) != fsize)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ static void read_viewers_config_init(void)
|
|||
if(fd < 0)
|
||||
return;
|
||||
|
||||
off_t filesz = filesize(fd);
|
||||
off_t filesz = ffilesize(fd);
|
||||
if(filesz <= 0)
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ void wps_playlist_percent_prepare(void)
|
|||
if (fd >= 0)
|
||||
{
|
||||
unsigned int afmt = probe_file_format(info.filename);
|
||||
off_t size = filesize(fd);
|
||||
off_t size = ffilesize(fd);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3218,7 +3218,7 @@ int playlist_resume(void)
|
|||
}
|
||||
playlist->control_created = true;
|
||||
|
||||
control_file_size = filesize(playlist->control_fd);
|
||||
control_file_size = ffilesize(playlist->control_fd);
|
||||
if (control_file_size <= 0)
|
||||
{
|
||||
notify_control_access_error();
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ int catalog_insert_into(const char* playlist, bool new_playlist,
|
|||
goto exit;
|
||||
|
||||
i = lseek(f, 0, SEEK_CUR);
|
||||
fs = filesize(f);
|
||||
fs = ffilesize(f);
|
||||
while (i < fs)
|
||||
{
|
||||
int n;
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ static const struct plugin_api rockbox_api = {
|
|||
FS_PREFIX(remove),
|
||||
FS_PREFIX(rename),
|
||||
FS_PREFIX(ftruncate),
|
||||
FS_PREFIX(filesize),
|
||||
FS_PREFIX(ffilesize),
|
||||
fdprintf,
|
||||
read_line,
|
||||
settings_parseline,
|
||||
|
|
@ -460,7 +460,7 @@ static const struct plugin_api rockbox_api = {
|
|||
FS_PREFIX(mkdir),
|
||||
FS_PREFIX(rmdir),
|
||||
FS_PREFIX(dir_exists),
|
||||
dir_get_info,
|
||||
FS_PREFIX(dir_get_info),
|
||||
|
||||
/* browsing */
|
||||
rockbox_browse,
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ struct plugin_api {
|
|||
int (*remove)(const char *path);
|
||||
int (*rename)(const char *old, const char *new);
|
||||
int (*ftruncate)(int fildes, off_t length);
|
||||
off_t (*filesize)(int fildes);
|
||||
off_t (*ffilesize)(int fildes);
|
||||
int (*fdprintf)(int fildes, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
|
||||
int (*read_line)(int fd, char* buffer, int buffer_size);
|
||||
bool (*settings_parseline)(char* line, char** name, char** value);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
lcd_printf("file open failed: %d", fd);
|
||||
goto wait;
|
||||
}
|
||||
unsigned long filesize = rb->filesize(fd);
|
||||
unsigned long filesize = rb->ffilesize(fd);
|
||||
if (filesize > plugin_buf_len)
|
||||
{
|
||||
lcd_printf("file too large");
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ static enum settings_file_status clock_settings_load(
|
|||
if(fd >= 0)
|
||||
{
|
||||
/* basic consistency check */
|
||||
if(rb->filesize(fd) != sizeof(*settings))
|
||||
if(rb->ffilesize(fd) != sizeof(*settings))
|
||||
rb->close(fd);
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
return PLUGIN_ERROR;
|
||||
}
|
||||
|
||||
length = rb->filesize(fd);
|
||||
length = rb->ffilesize(fd);
|
||||
|
||||
if (length < 12) {
|
||||
rb->splash(HZ*2, "File too small");
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
return PLUGIN_ERROR;
|
||||
}
|
||||
|
||||
filesize = rb->filesize(fIndex); /* get filesize */
|
||||
filesize = rb->ffilesize(fIndex); /* get filesize */
|
||||
|
||||
DEBUGF("Filesize: %d bytes = %d words \n", filesize,
|
||||
(filesize / (int)sizeof(struct stWord)));
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ int dehfeof(DEHFILE *fp)
|
|||
{
|
||||
if (fp->fd >= 0)
|
||||
{
|
||||
off_t size = filesize(fp->fd);
|
||||
off_t size = ffilesize(fp->fd);
|
||||
off_t offset = lseek(fp->fd, 0, SEEK_CUR);
|
||||
return (size <= 0 || offset < 0 || offset >= size) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ int M_ReadFile(char const* name,byte** buffer)
|
|||
if ((handle < 0))
|
||||
I_Error ("M_ReadFile: Couldn't read file %s", name);
|
||||
|
||||
length = filesize(handle);
|
||||
length = ffilesize(handle);
|
||||
buf = Z_Malloc (length, PU_STATIC, NULL);
|
||||
count = read (handle, buf, length);
|
||||
close (handle);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ int my_close(int id);
|
|||
#endif
|
||||
|
||||
#define lseek(a,b,c) rb->lseek((a),(b),(c))
|
||||
#define filesize(a) rb->filesize((a))
|
||||
#define ffilesize(a) rb->ffilesize((a))
|
||||
#define read(a,b,c) rb->read((a),(b),(c))
|
||||
#define write(a,b,c) rb->write((a),(b),(c))
|
||||
#undef strtok
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ static int W_Filelength(int handle)
|
|||
I_Error("W_Filelength: Error fstating");
|
||||
return fileinfo.st_size;
|
||||
*/
|
||||
return filesize(handle);
|
||||
return ffilesize(handle);
|
||||
}
|
||||
|
||||
void ExtractFileBase (const char *path, char *dest)
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ static int load_image(char *filename, struct image_info *info,
|
|||
}
|
||||
else
|
||||
{
|
||||
filesize = rb->filesize(fd);
|
||||
filesize = rb->ffilesize(fd);
|
||||
}
|
||||
|
||||
/* allocate JPEG buffer */
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ static int load_image(char *filename, struct image_info *info,
|
|||
}
|
||||
else
|
||||
{
|
||||
file_size = rb->filesize(fd);
|
||||
file_size = rb->ffilesize(fd);
|
||||
}
|
||||
|
||||
DEBUGF("reading file '%s'\n", filename);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ static int load_image(char *filename, struct image_info *info,
|
|||
}
|
||||
else
|
||||
{
|
||||
filesize = rb->filesize(fd);
|
||||
filesize = rb->ffilesize(fd);
|
||||
}
|
||||
DEBUGF("reading file '%s'\n", filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ static bool load_firmware(const char* filename, enum firmware firmware,
|
|||
}
|
||||
|
||||
/* get file and buffer lengths and acquire the buffer */
|
||||
fd_len = rb->filesize(fd);
|
||||
fd_len = rb->ffilesize(fd);
|
||||
buffer = rb->plugin_get_audio_buffer(&buffer_len);
|
||||
|
||||
/* ensure there's enough space in the buffer */
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ static int keyremap_open_file(const char *filename, int *fd, size_t *fsize)
|
|||
*fd = rb->open(filename, O_RDONLY);
|
||||
if (*fd)
|
||||
{
|
||||
*fsize = rb->filesize(*fd);
|
||||
*fsize = rb->ffilesize(*fd);
|
||||
|
||||
count = *fsize / sizeof(struct button_mapping);
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ static size_t file_open(const char *filename, int *fd)
|
|||
*fd = rb->open(filename, O_RDONLY);
|
||||
if (*fd >= 0)
|
||||
{
|
||||
fsize = rb->filesize(*fd);
|
||||
fsize = rb->ffilesize(*fd);
|
||||
}
|
||||
}
|
||||
return fsize;
|
||||
|
|
|
|||
|
|
@ -1944,7 +1944,7 @@ static void save_changes(void)
|
|||
rb->write(fd, BOM, BOM_SIZE);
|
||||
}
|
||||
else
|
||||
size = rb->filesize(fe);
|
||||
size = rb->ffilesize(fe);
|
||||
while (curr < size)
|
||||
{
|
||||
/* find offset of next tag */
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ static int read_number (lua_State *L, int *f) {
|
|||
static int test_eof (lua_State *L, int *f) {
|
||||
off_t s = lseek(*f, 0, SEEK_CUR);
|
||||
lua_pushlstring(L, NULL, 0);
|
||||
return s < filesize(*f);
|
||||
return s < ffilesize(*f);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ extern int errno;
|
|||
#define open(...) rb->open(__VA_ARGS__)
|
||||
#define close(fd) rb->close(fd)
|
||||
#define lseek(fd,off,w) rb->lseek(fd,off,w)
|
||||
#define filesize(fd) rb->filesize(fd)
|
||||
#define ffilesize(fd) rb->ffilesize(fd)
|
||||
#define ftruncate(fd,l) rb->ftruncate(fd,l)
|
||||
#define file_exists(p) rb->file_exists(p)
|
||||
#define remove(f) rb->remove(f)
|
||||
|
|
@ -71,7 +71,7 @@ extern int errno;
|
|||
#define open(...) PREFIX(open)(__VA_ARGS__)
|
||||
#define close(fd) PREFIX(close)(fd)
|
||||
#define lseek(fd,off,w) PREFIX(lseek)(fd,off,w)
|
||||
#define filesize(fd) PREFIX(filesize)(fd)
|
||||
#define ffilesize(fd) PREFIX(ffilesize)(fd)
|
||||
#define ftruncate(fd,l) PREFIX(ftruncate)(fd,l)
|
||||
#define file_exists(p) PREFIX(file_exists)(p)
|
||||
#define remove(f) PREFIX(remove)(f)
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@
|
|||
#define read(a,b,c) rb->read(a,b,c)
|
||||
#undef write
|
||||
#define write(a,b,c) rb->write(a,b,c)
|
||||
#undef filesize
|
||||
#define filesize(a) rb->filesize(a)
|
||||
#undef ffilesize
|
||||
#define ffilesize(a) rb->ffilesize(a)
|
||||
#endif
|
||||
|
||||
#define malloc(x) tlsf_malloc(x)
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ typedef struct MFILEREADER {
|
|||
static int _mm_FileReader_Eof(MREADER* reader)
|
||||
{
|
||||
//return feof(((MFILEREADER*)reader)->file);
|
||||
int size = filesize(((MFILEREADER*)reader)->file);
|
||||
int size = ffilesize(((MFILEREADER*)reader)->file);
|
||||
int offset = lseek(((MFILEREADER*)reader)->file, 0, SEEK_CUR);
|
||||
return (size <= 0 || offset < 0 || offset >= size) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -906,7 +906,7 @@ static int wave_open(void)
|
|||
(cfg.samplerate != 44100) && (cfg.samplerate != 48000)) return -9;
|
||||
|
||||
header_size = 0x28;
|
||||
wav_size = rb->filesize(wavfile);
|
||||
wav_size = rb->ffilesize(wavfile);
|
||||
rb->lseek(wavfile, header_size, SEEK_SET);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ int disk_buf_open(const char *filename)
|
|||
|
||||
if (fd >= 0)
|
||||
{
|
||||
ssize_t filesize = rb->filesize(fd);
|
||||
ssize_t filesize = rb->ffilesize(fd);
|
||||
|
||||
if (filesize <= 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ static int op_entry_read_opx(const char *path)
|
|||
fd_opx = rb->open(path, O_RDONLY);
|
||||
if (fd_opx >= 0)
|
||||
{
|
||||
filesize = rb->filesize(fd_opx);
|
||||
filesize = rb->ffilesize(fd_opx);
|
||||
ret = filesize;
|
||||
if (filesize == op_entry_sz && !op_entry_read(fd_opx, 0, op_entry_sz))
|
||||
ret = 0;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ void sfread_open(t_sfread *x,t_symbol *filename)
|
|||
|
||||
/* get the size */
|
||||
#ifdef ROCKBOX
|
||||
x->x_size = rb->filesize(x->x_fd);
|
||||
x->x_size = rb->ffilesize(x->x_fd);
|
||||
#else
|
||||
fstat(x->x_fd,&fstate);
|
||||
x->x_size = fstate.st_size;
|
||||
|
|
|
|||
|
|
@ -1584,7 +1584,7 @@ static int load_album_index(void){
|
|||
int album_idx, artist_idx;
|
||||
|
||||
if (fr >= 0){
|
||||
const unsigned long filesize = rb->filesize(fr);
|
||||
const unsigned long filesize = rb->ffilesize(fr);
|
||||
if (filesize > sizeof(data))
|
||||
{
|
||||
if (rb->read(fr, &data, sizeof(data)) == sizeof(data) &&
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ static void setoptions (void)
|
|||
int optionssize = sizeof(options);
|
||||
int filesize = 0;
|
||||
if(fd >= 0)
|
||||
filesize = rb->filesize(fd);
|
||||
filesize = rb->ffilesize(fd);
|
||||
|
||||
/* don't read the option file if the size
|
||||
* is not as expected to avoid crash */
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ static bool logdump(bool append);
|
|||
|
||||
#define vsnprintf rb->vsnprintf
|
||||
#define mkdir rb->mkdir
|
||||
#define filesize rb->filesize
|
||||
#define ffilesize rb->ffilesize
|
||||
|
||||
#define strtok_r rb->strtok_r
|
||||
#define strncasecmp rb->strncasecmp
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ void init_wav(char* filename)
|
|||
|
||||
void close_wav(void)
|
||||
{
|
||||
int filesize = rb->filesize(wavinfo.fd);
|
||||
int filesize = rb->ffilesize(wavinfo.fd);
|
||||
int channels = (wavinfo.stereomode == STEREO_MONO) ? 1 : 2;
|
||||
int bps = 16; /* TODO */
|
||||
|
||||
|
|
@ -658,7 +658,7 @@ static enum plugin_status test_track(const char* filename)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
track.filesize = rb->filesize(fd);
|
||||
track.filesize = rb->ffilesize(fd);
|
||||
|
||||
/* Clear the id3 struct */
|
||||
rb->memset(&track.id3, 0, sizeof(struct mp3entry));
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
int fd = rb->open(filename, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return PLUGIN_ERROR;
|
||||
unsigned long filesize = rb->filesize(fd);
|
||||
unsigned long filesize = rb->ffilesize(fd);
|
||||
if (filesize > plugin_buf_len)
|
||||
return PLUGIN_ERROR;
|
||||
plugin_buf_len -= filesize;
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
if (c && !rb->strcmp(c, ".colours"))
|
||||
edit_colors_file = true;
|
||||
#endif
|
||||
if (buffer_size <= (size_t)rb->filesize(fd) + 0x400)
|
||||
if (buffer_size <= (size_t)rb->ffilesize(fd) + 0x400)
|
||||
{
|
||||
buffer = rb->plugin_get_audio_buffer(&buffer_size);
|
||||
audio_buf = true;
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ static int tv_change_preferences(const struct tv_preferences *oldp)
|
|||
if (fd < 0)
|
||||
return TV_CALLBACK_ERROR;
|
||||
|
||||
file_size = rb->filesize(fd);
|
||||
file_size = rb->ffilesize(fd);
|
||||
change_file = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2085,7 +2085,7 @@ int clip_jpeg_fd(int fd, int flags,
|
|||
#else
|
||||
p_jpeg->fd = fd;
|
||||
if (p_jpeg->len == 0)
|
||||
p_jpeg->len = filesize(p_jpeg->fd);
|
||||
p_jpeg->len = ffilesize(p_jpeg->fd);
|
||||
|
||||
p_jpeg->read_buf = read_buf;
|
||||
p_jpeg->skip_bytes_seek = skip_bytes_seek;
|
||||
|
|
|
|||
|
|
@ -3096,7 +3096,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
|||
*/
|
||||
masterfd_pos = lseek(masterfd, tcmh.tch.entry_count * sizeof(struct index_entry),
|
||||
SEEK_CUR);
|
||||
if (masterfd_pos == filesize(masterfd))
|
||||
if (masterfd_pos == ffilesize(masterfd))
|
||||
{
|
||||
logf("appending...");
|
||||
init = true;
|
||||
|
|
|
|||
|
|
@ -1117,7 +1117,7 @@ static int _talk_file(const char* filename,
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
size = filesize(fd);
|
||||
size = ffilesize(fd);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ int load_raw_firmware(unsigned char* buf, char* firmware, int buffer_size)
|
|||
return EFILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
len = filesize(fd);
|
||||
len = ffilesize(fd);
|
||||
|
||||
if (len > buffer_size)
|
||||
return EFILE_TOO_BIG;
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ static void untar(int tar_fd)
|
|||
char path[102];
|
||||
int fd, i;
|
||||
int ret;
|
||||
size_t size = filesize(tar_fd);
|
||||
size_t size = ffilesize(tar_fd);
|
||||
|
||||
if (size > tarbuf_size)
|
||||
{
|
||||
|
|
@ -159,7 +159,7 @@ static void untar(int tar_fd)
|
|||
return;
|
||||
}
|
||||
|
||||
ret = read(tar_fd, tarbuf, filesize(tar_fd));
|
||||
ret = read(tar_fd, tarbuf, ffilesize(tar_fd));
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("couldn't read tar file (%d)", ret);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ static int read_linux_args(const char* filename)
|
|||
}
|
||||
|
||||
/* this isn't 100% correct but will be good enough */
|
||||
off_t fsize = filesize(fd);
|
||||
off_t fsize = ffilesize(fd);
|
||||
if(fsize < 0 || fsize+1 > (off_t)max_size) {
|
||||
splashf(5*HZ, "Arguments too long");
|
||||
ret = -4;
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ static struct dirstr_desc * alloc_dirstr(void)
|
|||
/** POSIX interface **/
|
||||
|
||||
/* open a directory */
|
||||
DIR * opendir(const char *dirname)
|
||||
DIR * rbfs_opendir(const char *dirname)
|
||||
{
|
||||
DEBUGF("opendir(dirname=\"%s\"\n", dirname);
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* close a directory stream */
|
||||
int closedir(DIR *dirp)
|
||||
int rbfs_closedir(DIR *dirp)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* read a directory */
|
||||
struct dirent * readdir(DIR *dirp)
|
||||
struct dirent * rbfs_readdir(DIR *dirp)
|
||||
{
|
||||
struct dirstr_desc * const dir = GET_DIRSTR(READER, dirp);
|
||||
if (!dir)
|
||||
|
|
@ -184,7 +184,7 @@ file_error:
|
|||
|
||||
#if 0 /* not included now but probably should be */
|
||||
/* read a directory (reentrant) */
|
||||
int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
|
||||
int rbfs_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
|
||||
{
|
||||
if (!result)
|
||||
FILE_ERROR_RETURN(EFAULT, -2);
|
||||
|
|
@ -218,7 +218,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* reset the position of a directory stream to the beginning of a directory */
|
||||
void rewinddir(DIR *dirp)
|
||||
void rbfs_rewinddir(DIR *dirp)
|
||||
{
|
||||
struct dirstr_desc * const dir = GET_DIRSTR(READER, dirp);
|
||||
if (!dir)
|
||||
|
|
@ -232,7 +232,7 @@ void rewinddir(DIR *dirp)
|
|||
#endif /* 0 */
|
||||
|
||||
/* make a directory */
|
||||
int mkdir(const char *path)
|
||||
int rbfs_mkdir(const char *path)
|
||||
{
|
||||
DEBUGF("mkdir(path=\"%s\")\n", path);
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* remove a directory */
|
||||
int rmdir(const char *name)
|
||||
int rbfs_rmdir(const char *name)
|
||||
{
|
||||
DEBUGF("rmdir(name=\"%s\")\n", name);
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ int rmdir(const char *name)
|
|||
/** Extended interface **/
|
||||
|
||||
/* return if two directory streams refer to the same directory */
|
||||
int samedir(DIR *dirp1, DIR *dirp2)
|
||||
int rbfs_samedir(DIR *dirp1, DIR *dirp2)
|
||||
{
|
||||
struct dirstr_desc * const dir1 = GET_DIRSTR(WRITER, dirp1);
|
||||
if (!dir1)
|
||||
|
|
@ -312,7 +312,7 @@ int samedir(DIR *dirp1, DIR *dirp2)
|
|||
}
|
||||
|
||||
/* test directory existence (returns 'false' if a file) */
|
||||
bool dir_exists(const char *dirname)
|
||||
bool rbfs_dir_exists(const char *dirname)
|
||||
{
|
||||
file_internal_lock_WRITER();
|
||||
bool rc = test_stream_exists_internal(dirname, FF_DIR) > 0;
|
||||
|
|
@ -321,7 +321,7 @@ bool dir_exists(const char *dirname)
|
|||
}
|
||||
|
||||
/* get the portable info from the native entry */
|
||||
struct dirinfo dir_get_info(DIR *dirp, struct dirent *entry)
|
||||
struct dirinfo rbfs_dir_get_info(DIR *dirp, struct dirent *entry)
|
||||
{
|
||||
int rc;
|
||||
if (!dirp || !entry)
|
||||
|
|
@ -344,7 +344,7 @@ file_error:
|
|||
return (struct dirinfo){ .attribute = 0 };
|
||||
}
|
||||
|
||||
const char* root_realpath(void)
|
||||
const char* rbfs_root_realpath(void)
|
||||
{
|
||||
/* Native only, for APP and SIM see respective filesystem-.c files */
|
||||
return root_get_realpath(); /* rb_namespace.c */
|
||||
|
|
|
|||
|
|
@ -3060,7 +3060,7 @@ int INIT_ATTR dircache_load(void)
|
|||
if (maindata.dircache.size !=
|
||||
maindata.dircache.sizeentries + maindata.dircache.sizenames ||
|
||||
ALIGN_DOWN(maindata.dircache.size, ENTRYSIZE) != maindata.dircache.size ||
|
||||
filesize(fd) - sizeof (maindata) != maindata.dircache.size)
|
||||
ffilesize(fd) - sizeof (maindata) != maindata.dircache.size)
|
||||
{
|
||||
logf("dircache: file header error");
|
||||
goto error_nolock;
|
||||
|
|
|
|||
|
|
@ -507,7 +507,7 @@ static int open_internal_inner1(const char *path, int oflag,
|
|||
|
||||
file_error:
|
||||
if (fildes >= 0)
|
||||
close(fildes);
|
||||
rbfs_close(fildes);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -817,21 +817,21 @@ void force_close_writer_internal(struct filestr_base *stream)
|
|||
/** POSIX **/
|
||||
|
||||
/* open a file */
|
||||
int open(const char *path, int oflag)
|
||||
int rbfs_open(const char *path, int oflag)
|
||||
{
|
||||
DEBUGF("open(path=\"%s\",oflag=%X)\n", path, (unsigned)oflag);
|
||||
return open_internal_locked(path, oflag, FF_ANYTYPE);
|
||||
}
|
||||
|
||||
/* create a new file or rewrite an existing one */
|
||||
int creat(const char *path)
|
||||
int rbfs_creat(const char *path)
|
||||
{
|
||||
DEBUGF("creat(path=\"%s\")\n", path);
|
||||
return open_internal_locked(path, O_WRONLY|O_CREAT|O_TRUNC, FF_ANYTYPE);
|
||||
}
|
||||
|
||||
/* close a file descriptor */
|
||||
int close(int fildes)
|
||||
int rbfs_close(int fildes)
|
||||
{
|
||||
DEBUGF("close(fd=%d)\n", fildes);
|
||||
|
||||
|
|
@ -857,7 +857,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* truncate a file to a specified length */
|
||||
int ftruncate(int fildes, off_t length)
|
||||
int rbfs_ftruncate(int fildes, off_t length)
|
||||
{
|
||||
DEBUGF("ftruncate(fd=%d,len=%ld)\n", fildes, (long)length);
|
||||
|
||||
|
|
@ -889,7 +889,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* synchronize changes to a file */
|
||||
int fsync(int fildes)
|
||||
int rbfs_fsync(int fildes)
|
||||
{
|
||||
DEBUGF("fsync(fd=%d)\n", fildes);
|
||||
|
||||
|
|
@ -915,7 +915,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* move the read/write file offset */
|
||||
off_t lseek(int fildes, off_t offset, int whence)
|
||||
off_t rbfs_lseek(int fildes, off_t offset, int whence)
|
||||
{
|
||||
#ifndef LOGF_ENABLE /* wipes out log before you can save it */
|
||||
DEBUGF("lseek(fd=%d,ofs=%ld,wh=%d)\n", fildes, (long)offset, whence);
|
||||
|
|
@ -934,7 +934,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* read from a file */
|
||||
ssize_t read(int fildes, void *buf, size_t nbyte)
|
||||
ssize_t rbfs_read(int fildes, void *buf, size_t nbyte)
|
||||
{
|
||||
struct filestr_desc * const file = GET_FILESTR(READER, fildes);
|
||||
if (!file)
|
||||
|
|
@ -960,7 +960,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* write on a file */
|
||||
ssize_t write(int fildes, const void *buf, size_t nbyte)
|
||||
ssize_t rbfs_write(int fildes, const void *buf, size_t nbyte)
|
||||
{
|
||||
struct filestr_desc * const file = GET_FILESTR(READER, fildes);
|
||||
if (!file)
|
||||
|
|
@ -986,7 +986,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* remove a file */
|
||||
int remove(const char *path)
|
||||
int rbfs_remove(const char *path)
|
||||
{
|
||||
DEBUGF("remove(path=\"%s\")\n", path);
|
||||
|
||||
|
|
@ -997,7 +997,7 @@ int remove(const char *path)
|
|||
}
|
||||
|
||||
/* rename a file */
|
||||
int rename(const char *old, const char *new)
|
||||
int rbfs_rename(const char *old, const char *new)
|
||||
{
|
||||
DEBUGF("rename(old=\"%s\",new=\"%s\")\n", old, new);
|
||||
|
||||
|
|
@ -1144,7 +1144,7 @@ file_error:
|
|||
|
||||
/** Extensions **/
|
||||
|
||||
int modtime(const char *path, time_t modtime)
|
||||
int rbfs_modtime(const char *path, time_t modtime)
|
||||
{
|
||||
DEBUGF("modtime(path=\"%s\",modtime=%d)\n", path, (int) modtime);
|
||||
|
||||
|
|
@ -1181,7 +1181,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* get the binary size of a file (in bytes) */
|
||||
off_t filesize(int fildes)
|
||||
off_t rbfs_ffilesize(int fildes)
|
||||
{
|
||||
struct filestr_desc * const file = GET_FILESTR(READER, fildes);
|
||||
if (!file)
|
||||
|
|
@ -1200,7 +1200,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* test if two file descriptors refer to the same file */
|
||||
int fsamefile(int fildes1, int fildes2)
|
||||
int rbfs_fsamefile(int fildes1, int fildes2)
|
||||
{
|
||||
struct filestr_desc * const file1 = GET_FILESTR(WRITER, fildes1);
|
||||
if (!file1)
|
||||
|
|
@ -1217,7 +1217,7 @@ int fsamefile(int fildes1, int fildes2)
|
|||
}
|
||||
|
||||
/* tell the relationship of path1 to path2 */
|
||||
int relate(const char *path1, const char *path2)
|
||||
int rbfs_relate(const char *path1, const char *path2)
|
||||
{
|
||||
/* this is basically what rename() does but reduced to the relationship
|
||||
determination */
|
||||
|
|
@ -1277,7 +1277,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* test file or directory existence */
|
||||
bool file_exists(const char *path)
|
||||
bool rbfs_file_exists(const char *path)
|
||||
{
|
||||
file_internal_lock_WRITER();
|
||||
bool rc = test_stream_exists_internal(path, FF_ANYTYPE) > 0;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static int load_firmware_filename(unsigned char* buf,
|
|||
if (fd < 0)
|
||||
return EFILE_NOT_FOUND;
|
||||
|
||||
len = filesize(fd) - 8;
|
||||
len = ffilesize(fd) - 8;
|
||||
|
||||
if (len > buffer_size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ static int alloc_and_load_cp_table(int cp, void *buf)
|
|||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
off_t size = filesize(fd);
|
||||
off_t size = ffilesize(fd);
|
||||
|
||||
if (size > 0 && size <= MAX_CP_TABLE_SIZE*2 &&
|
||||
!(size % (off_t)sizeof (uint16_t))) {
|
||||
|
|
|
|||
|
|
@ -524,7 +524,7 @@ static off_t zip_file_seek(struct zip* zh, off_t offset, int whence) {
|
|||
static off_t zip_file_size(struct zip* zh) {
|
||||
struct zip_file* z = (struct zip_file*) zh;
|
||||
|
||||
return filesize(z->file);
|
||||
return ffilesize(z->file);
|
||||
}
|
||||
|
||||
static void zip_file_close(struct zip* zh) {
|
||||
|
|
@ -721,7 +721,7 @@ struct zip* zip_open(const char* name, bool try_mem) {
|
|||
if ((file = open(name, O_RDONLY)) < 0)
|
||||
goto bail;
|
||||
|
||||
if (try_mem && (mem_handle = zip_core_alloc(mem_size = filesize(file))) >= 0) {
|
||||
if (try_mem && (mem_handle = zip_core_alloc(mem_size = ffilesize(file))) >= 0) {
|
||||
if ((zip_handle = zip_core_alloc(sizeof(struct zip_mem))) < 0)
|
||||
goto bail;
|
||||
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ int font_load_ex( const char *path, size_t buf_size, int glyphs )
|
|||
#endif
|
||||
|
||||
/* load font struct f with file header */
|
||||
int file_size = filesize( fd );
|
||||
int file_size = ffilesize( fd );
|
||||
struct font header;
|
||||
struct font f;
|
||||
|
||||
|
|
@ -1021,7 +1021,7 @@ static NO_INLINE void glyph_cache_load(const char *font_path, struct font *pf)
|
|||
if (hdr != FC_HEADER_VAL)
|
||||
goto latin;
|
||||
/* only read what fits */
|
||||
glyph_file_size = filesize( fd );
|
||||
glyph_file_size = ffilesize( fd );
|
||||
if (glyph_file_size < sizeof(uint32_t))
|
||||
goto latin;
|
||||
glyph_file_size -= sizeof(uint32_t);
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@
|
|||
#ifndef dir_exists
|
||||
#define dir_exists FS_PREFIX(dir_exists)
|
||||
#endif
|
||||
#ifndef dir_get_info
|
||||
#define dir_get_info FS_PREFIX(dir_get_info)
|
||||
#endif
|
||||
#ifndef root_realpath
|
||||
#define root_realpath FS_PREFIX(root_realpath)
|
||||
#endif
|
||||
|
|
@ -85,12 +88,4 @@ struct dirinfo
|
|||
time_t mtime; /* local file time */
|
||||
};
|
||||
|
||||
#ifndef DIRFUNCTIONS_DECLARED
|
||||
/* TIP: set errno to zero before calling to see if anything failed */
|
||||
struct dirinfo dir_get_info(DIR *dirp, struct DIRENT *entry);
|
||||
const char* root_realpath(void);
|
||||
#endif /* !DIRFUNCTIONS_DECLARED */
|
||||
|
||||
|
||||
|
||||
#endif /* _DIR_H_ */
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ static inline void volume_onmount_internal(IF_MV_NONVOID(int volume))
|
|||
|
||||
if (rtlen <= 0 || rtlen >= (int) sizeof(rtpath))
|
||||
rtlen = 0; /* path too long or sprintf error */
|
||||
else if (file_exists(rtpath))
|
||||
else if (rbfs_file_exists(rtpath))
|
||||
{
|
||||
rtlen = get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "");
|
||||
while (rtlen > 0 && rtpath[--rtlen] == PATH_SEPCH)
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ int fdprintf(int fildes, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
|
|||
#ifndef modtime
|
||||
#define modtime FS_PREFIX(modtime)
|
||||
#endif
|
||||
#ifndef filesize
|
||||
#define filesize FS_PREFIX(filesize)
|
||||
#ifndef ffilesize
|
||||
#define ffilesize FS_PREFIX(ffilesize)
|
||||
#endif
|
||||
#ifndef fsamefile
|
||||
#define fsamefile FS_PREFIX(fsamefile)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#define DIRFUNCTIONS_DEFINED
|
||||
#endif /* PLUGIN || CODEC */
|
||||
|
||||
#define FS_PREFIX(_x_) _x_
|
||||
#define FS_PREFIX(_x_) rbfs_ ## _x_
|
||||
#endif /* _FILESYSTEM_NATIVE_H_ */
|
||||
|
||||
#ifdef _FILE_H_
|
||||
|
|
@ -44,26 +44,26 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
int open(const char *name, int oflag);
|
||||
int creat(const char *name);
|
||||
int close(int fildes);
|
||||
int ftruncate(int fildes, off_t length);
|
||||
int fsync(int fildes);
|
||||
off_t lseek(int fildes, off_t offset, int whence);
|
||||
ssize_t read(int fildes, void *buf, size_t nbyte);
|
||||
ssize_t write(int fildes, const void *buf, size_t nbyte);
|
||||
int remove(const char *path);
|
||||
int rename(const char *old, const char *new);
|
||||
int modtime(const char *path, time_t modtime);
|
||||
off_t filesize(int fildes);
|
||||
int fsamefile(int fildes1, int fildes2);
|
||||
int relate(const char *path1, const char *path2);
|
||||
bool file_exists(const char *path);
|
||||
int rbfs_open(const char *name, int oflag);
|
||||
int rbfs_creat(const char *name);
|
||||
int rbfs_close(int fildes);
|
||||
int rbfs_ftruncate(int fildes, off_t length);
|
||||
int rbfs_fsync(int fildes);
|
||||
off_t rbfs_lseek(int fildes, off_t offset, int whence);
|
||||
ssize_t rbfs_read(int fildes, void *buf, size_t nbyte);
|
||||
ssize_t rbfs_write(int fildes, const void *buf, size_t nbyte);
|
||||
int rbfs_remove(const char *path);
|
||||
int rbfs_rename(const char *old, const char *new);
|
||||
int rbfs_modtime(const char *path, time_t modtime);
|
||||
off_t rbfs_ffilesize(int fildes);
|
||||
int rbfs_fsamefile(int fildes1, int fildes2);
|
||||
int rbfs_relate(const char *path1, const char *path2);
|
||||
bool rbfs_file_exists(const char *path);
|
||||
#endif /* !FILEFUNCTIONS_DECLARED */
|
||||
|
||||
#if !defined(RB_FILESYSTEM_OS) && !defined (FILEFUNCTIONS_DEFINED)
|
||||
#define open(path, oflag, ...) open(path, oflag)
|
||||
#define creat(path, mode) creat(path)
|
||||
#define rbfs_open(path, oflag, ...) rbfs_open(path, oflag)
|
||||
#define rbfs_creat(path, mode) rbfs_creat(path)
|
||||
#endif /* FILEFUNCTIONS_DEFINED */
|
||||
|
||||
#endif /* _FILESYSTEM_NATIVE__FILE_H_ */
|
||||
|
|
@ -93,16 +93,19 @@ typedef struct {} DIR;
|
|||
#define DIRFUNCTIONS_DEFINED
|
||||
#endif
|
||||
|
||||
DIR * opendir(const char *dirname);
|
||||
struct dirent * readdir(DIR *dirp);
|
||||
int readdir_r(DIR *dirp, struct dirent *entry,
|
||||
struct dirent **result);
|
||||
void rewinddir(DIR *dirp);
|
||||
int closedir(DIR *dirp);
|
||||
int mkdir(const char *path);
|
||||
int rmdir(const char *path);
|
||||
int samedir(DIR *dirp1, DIR *dirp2);
|
||||
bool dir_exists(const char *dirname);
|
||||
DIR * rbfs_opendir(const char *dirname);
|
||||
struct dirent * rbfs_readdir(DIR *dirp);
|
||||
int rbfs_readdir_r(DIR *dirp, struct dirent *entry,
|
||||
struct dirent **result);
|
||||
void rbfs_rewinddir(DIR *dirp);
|
||||
int rbfs_closedir(DIR *dirp);
|
||||
int rbfs_mkdir(const char *path);
|
||||
int rbfs_rmdir(const char *path);
|
||||
int rbfs_samedir(DIR *dirp1, DIR *dirp2);
|
||||
bool rbfs_dir_exists(const char *dirname);
|
||||
|
||||
struct dirinfo rbfs_dir_get_info(DIR *dirp, struct DIRENT *entry);
|
||||
const char * rbfs_root_realpath(void);
|
||||
#endif /* !DIRFUNCTIONS_DECLARED */
|
||||
|
||||
#endif /* _FILESYSTEM_NATIVE__DIR_H_ */
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ void * lc_open(const char *filename, unsigned char *buf, size_t buf_size)
|
|||
/* hdr.end_addr points to the end of the bss section,
|
||||
* but there might be idata/icode behind that so the bytes to copy
|
||||
* can be larger */
|
||||
copy_size = MAX(filesize(fd), hdr.end_addr - hdr.load_addr);
|
||||
copy_size = MAX(ffilesize(fd), hdr.end_addr - hdr.load_addr);
|
||||
|
||||
if (hdr.load_addr < buf || (hdr.load_addr+copy_size) > buf_end)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ bool app_dir_exists(const char *dirname)
|
|||
return true;
|
||||
}
|
||||
|
||||
struct dirinfo dir_get_info(DIR *dirp, struct dirent *entry)
|
||||
struct dirinfo app_dir_get_info(DIR *dirp, struct dirent *entry)
|
||||
{
|
||||
struct __dir *this = (struct __dir *)dirp;
|
||||
struct dirinfo ret = { .attribute = 0,
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ ssize_t app_write(int fildes, const void *buf, size_t nbyte);
|
|||
int app_remove(const char *path);
|
||||
int app_rename(const char *old, const char *new);
|
||||
#define app_modtime os_modtime
|
||||
#define app_filesize os_filesize
|
||||
#define app_ffilesize os_ffilesize
|
||||
#define app_fsamefile os_fsamefile
|
||||
int app_relate(const char *path1, const char *path2);
|
||||
bool app_file_exists(const char *path);
|
||||
|
|
@ -115,6 +115,8 @@ int app_mkdir(const char *path);
|
|||
int app_rmdir(const char *path);
|
||||
int app_samedir(DIR *dirp1, DIR *dirp2);
|
||||
bool app_dir_exists(const char *dirname);
|
||||
struct dirinfo app_dir_get_info(DIR *dirp, struct dirent *entry);
|
||||
const char * app_root_realpath(void);
|
||||
#endif /* DIRFUNCTIONS_DECLARED */
|
||||
|
||||
#endif /* _FILESYSTEM_APP__DIR_H_ */
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ ssize_t console_write(int fildes, const void *buf, size_t nbyte);
|
|||
int console_remove(const char *path);
|
||||
int console_rename(const char *old, const char *new);
|
||||
int console_modtime(const char *path, time_t modtime);
|
||||
off_t console_filesize(int fildes);
|
||||
off_t console_ffilesize(int fildes);
|
||||
int console_fsamefile(int fildes1, int fildes2);
|
||||
int console_relate(const char *path1, const char *path2);
|
||||
bool console_file_exists(const char *path);
|
||||
|
|
@ -109,6 +109,9 @@ int console_mkdir(const char *path);
|
|||
int console_rmdir(const char *path);
|
||||
int console_samedir(DIR *dirp1, DIR *dirp2);
|
||||
bool console_dir_exists(const char *dirname);
|
||||
|
||||
struct dirinfo console_dir_get_info(DIR *dirp, struct dirent *entry);
|
||||
const char* console_root_realpath(void);
|
||||
#endif /* !DIRFUNCTIONS_DECLARED */
|
||||
|
||||
#endif /* _FILESYSTEM_CONSOLE__DIR_H_ */
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void * os_lc_open(const char *ospath);
|
|||
|
||||
#ifndef OSFUNCTIONS_DECLARED
|
||||
int os_modtime(const char *path, time_t modtime);
|
||||
off_t os_filesize(int osfd);
|
||||
off_t os_ffilesize(int osfd);
|
||||
int os_fsamefile(int osfd1, int osfd2);
|
||||
int os_relate(const char *path1, const char *path2);
|
||||
bool os_file_exists(const char *ospath);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ int os_modtime(const char *path, time_t modtime)
|
|||
return utime(path, ×);
|
||||
}
|
||||
|
||||
off_t os_filesize(int osfd)
|
||||
off_t os_ffilesize(int osfd)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,12 +49,12 @@ size_t strlcpy_utf16utf8(char *buffer, const unsigned short *utf16,
|
|||
|
||||
#ifndef OSFUNCTIONS_DECLARED
|
||||
/* Wrap for off_t <=> long conversions */
|
||||
static inline off_t os_filesize_(int osfd)
|
||||
static inline off_t os_ffilesize_(int osfd)
|
||||
{ return _filelength(osfd); }
|
||||
static inline int os_ftruncate_(int osfd, off_t length)
|
||||
{ return _chsize(osfd, length); }
|
||||
|
||||
#define os_filesize os_filesize_
|
||||
#define os_ffilesize os_ffilesize_
|
||||
#define os_ftruncate os_ftruncate_
|
||||
#define os_fsync _commit
|
||||
#define os_fstat _fstat
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ file_error:
|
|||
}
|
||||
|
||||
/* get the portable info from the native entry */
|
||||
struct dirinfo dir_get_info(DIR *dirp, struct dirent *entry)
|
||||
struct dirinfo console_dir_get_info(DIR *dirp, struct dirent *entry)
|
||||
{
|
||||
int rc;
|
||||
if (!dirp || !entry)
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ file_error:
|
|||
/** Extensions **/
|
||||
|
||||
/* get the binary size of a file (in bytes) */
|
||||
off_t console_filesize(int fildes)
|
||||
off_t console_ffilesize(int fildes)
|
||||
{
|
||||
struct filestr_desc * const file = GET_FILESTR(READER, fildes);
|
||||
if (!file)
|
||||
|
|
@ -381,4 +381,4 @@ bool console_file_exists(const char *path)
|
|||
bool rc = test_stream_exists_internal(path) > 0;
|
||||
file_internal_unlock_WRITER();
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#include "inttypes.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
int filesize(int fd)
|
||||
int ffilesize(int fd)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt);
|
|||
|
||||
#ifdef TEST
|
||||
|
||||
int filesize(int fd);
|
||||
int ffilesize(int fd);
|
||||
void advance_buffer(uint8_t **buf, int val);
|
||||
|
||||
/* Get a (sub_packet_h*frames_per_packet) number of audio frames from a file descriptor */
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ bool get_a52_metadata(int fd, struct mp3entry *id3)
|
|||
|
||||
id3->bitrate = a52_bitrates[i >> 1];
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
switch (buf[4] & 0xc0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ bool get_aac_metadata(int fd, struct mp3entry *entry)
|
|||
entry->id3v1len = 0;
|
||||
entry->id3v2len = getid3v2len(fd);
|
||||
entry->first_frame_offset = entry->id3v2len;
|
||||
entry->filesize = filesize(fd) - entry->first_frame_offset;
|
||||
entry->filesize = ffilesize(fd) - entry->first_frame_offset;
|
||||
entry->needs_upsampling_correction = false;
|
||||
|
||||
if (entry->id3v2len)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ bool get_adx_metadata(int fd, struct mp3entry* id3)
|
|||
id3->bitrate = id3->frequency * channels * 18 * 8 / 32 / 1000;
|
||||
id3->length = get_long_be(&buf[12]) / id3->frequency * 1000;
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
/* get loop info */
|
||||
if (!memcmp(buf+0x10,"\x01\xF4\x03",3)) {
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ bool get_aiff_metadata(int fd, struct mp3entry* id3)
|
|||
}
|
||||
|
||||
id3->vbr = false; /* AIFF files are CBR */
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len)
|
|||
bool get_asap_metadata(int fd, struct mp3entry* id3)
|
||||
{
|
||||
|
||||
int filelength = filesize(fd);
|
||||
int filelength = ffilesize(fd);
|
||||
|
||||
if(parse_sap_header(fd, id3, filelength) == false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -647,7 +647,7 @@ bool get_asf_metadata(int fd, struct mp3entry* id3)
|
|||
header.
|
||||
*/
|
||||
id3->first_frame_offset = lseek(fd, 0, SEEK_CUR) + 26;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
/* We copy the wfx struct to the MP3 TOC field in the id3 struct so
|
||||
the codec doesn't need to parse the header object again */
|
||||
memcpy(id3->toc, &wfx, sizeof(wfx));
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ bool get_au_metadata(int fd, struct mp3entry* id3)
|
|||
int offset;
|
||||
|
||||
id3->vbr = false; /* All Sun audio files are CBR */
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->length = 0;
|
||||
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ bool get_ay_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
id3->bitrate = 706;
|
||||
id3->frequency = 44100;
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ bool get_flac_metadata(int fd, struct mp3entry* id3)
|
|||
}
|
||||
|
||||
id3->vbr = true; /* All FLAC files are VBR */
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->frequency = (buf[10] << 12) | (buf[11] << 4)
|
||||
| ((buf[12] & 0xf0) >> 4);
|
||||
rc = true; /* Got vital metadata */
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ bool get_gbs_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
/* we only render 16 bits, 44.1KHz, Stereo */
|
||||
id3->bitrate = 706;
|
||||
id3->frequency = 44100;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ bool get_hes_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
/* we only render 16 bits, 44.1KHz, Stereo */
|
||||
id3->bitrate = 706;
|
||||
id3->frequency = 44100;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ bool get_kss_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
/* we only render 16 bits, 44.1KHz, Stereo */
|
||||
id3->bitrate = 706;
|
||||
id3->frequency = 44100;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ static bool get_shn_metadata(int fd, struct mp3entry *id3)
|
|||
{
|
||||
/* TODO: read the id3v2 header if it exists */
|
||||
id3->vbr = true;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
return skip_id3v2(fd, id3);
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ static bool get_other_asap_metadata(int fd, struct mp3entry *id3)
|
|||
id3->bitrate = 706;
|
||||
id3->frequency = 44100;
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->genre_string = id3_get_num_genre(36); /* GAME */
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,11 +91,11 @@ bool get_mod_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
|
||||
id3->title = id3->id3v2buf; /* Point title to previous read ID3 buffer. */
|
||||
id3->bitrate = filesize(fd)/1024; /* size in kb */
|
||||
id3->frequency = 44100;
|
||||
id3->length = 120*1000;
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->bitrate = id3->filesize / 1024; /* size in kb */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ bool get_monkeys_metadata(int fd, struct mp3entry* id3)
|
|||
}
|
||||
|
||||
id3->vbr = true; /* All APE files are VBR */
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
totalsamples = finalframeblocks;
|
||||
if (totalframes > 1)
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ static int getsonglength(int fd, struct mp3entry *entry)
|
|||
bool get_mp3_metadata(int fd, struct mp3entry *entry)
|
||||
{
|
||||
entry->title = NULL;
|
||||
entry->filesize = filesize(fd);
|
||||
entry->filesize = ffilesize(fd);
|
||||
entry->id3v1len = getid3v1len(fd);
|
||||
entry->id3v2len = getid3v2len(fd);
|
||||
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ int get_mp3file_info(int fd, struct mp3info *info)
|
|||
if(result)
|
||||
return result;
|
||||
|
||||
info->byte_count = filesize(fd) - getid3v1len(fd) - offset - bytecount;
|
||||
info->byte_count = ffilesize(fd) - getid3v1len(fd) - offset - bytecount;
|
||||
}
|
||||
|
||||
return bytecount;
|
||||
|
|
|
|||
|
|
@ -823,7 +823,7 @@ bool get_mp4_metadata(int fd, struct mp3entry* id3)
|
|||
id3->filesize = 0;
|
||||
errno = 0;
|
||||
|
||||
if (read_mp4_container(fd, id3, filesize(fd)) && (errno == 0)
|
||||
if (read_mp4_container(fd, id3, ffilesize(fd)) && (errno == 0)
|
||||
&& (id3->samples > 0) && (id3->frequency > 0)
|
||||
&& (id3->filesize > 0))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ bool get_musepack_metadata(int fd, struct mp3entry *id3)
|
|||
return false;
|
||||
}
|
||||
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->bitrate = id3->filesize * 8 / id3->length;
|
||||
|
||||
read_ape_tags(fd, id3);
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ bool get_nsf_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
/* we only render 16 bits, 44.1KHz, Mono */
|
||||
id3->bitrate = 706;
|
||||
id3->frequency = 44100;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ bool get_ogg_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
}
|
||||
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
/* We need to ensure the serial number from this page is the same as the
|
||||
* one from the last page (since we only support a single bitstream).
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ bool get_oma_metadata(int fd, struct mp3entry* id3)
|
|||
|
||||
/* Currently, there's no means of knowing the duration *
|
||||
* directly from the the file so we calculate it. */
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->length = ((id3->filesize - id3->first_frame_offset) * 8) / id3->bitrate;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ static inline int rm_parse_header(int fd, RMContext *rmctx, struct mp3entry *id3
|
|||
rmctx->data_offset = skipped + 8;
|
||||
rmctx->bit_rate = rmctx->block_align * rmctx->sample_rate / 192;
|
||||
if (rmctx->block_align)
|
||||
rmctx->nb_packets = (filesize(fd) - rmctx->data_offset) / rmctx->block_align;
|
||||
rmctx->nb_packets = (ffilesize(fd) - rmctx->data_offset) / rmctx->block_align;
|
||||
if (rmctx->sample_rate)
|
||||
rmctx->duration = (uint32_t)(256LL * 6 * 1000 * rmctx->nb_packets / rmctx->sample_rate);
|
||||
rmctx->flags |= RM_RAW_DATASTREAM;
|
||||
|
|
@ -504,6 +504,6 @@ bool get_rm_metadata(int fd, struct mp3entry* id3)
|
|||
id3->bitrate = (rmctx->bit_rate + 500) / 1000;
|
||||
id3->frequency = rmctx->sample_rate;
|
||||
id3->length = rmctx->duration;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ bool get_sgc_metadata(int fd, struct mp3entry* id3)
|
|||
return false;
|
||||
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
/* we only render 16 bits, 44.1KHz, Stereo */
|
||||
id3->bitrate = 706;
|
||||
id3->frequency = 44100;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ bool get_sid_metadata(int fd, struct mp3entry* id3)
|
|||
*/
|
||||
id3->length = (buf[0xf]-1)*1000;
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ bool get_smaf_metadata(int fd, struct mp3entry* id3)
|
|||
id3->composer = NULL;
|
||||
|
||||
id3->vbr = false; /* All SMAF files are CBR */
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
/* check File Chunk and Contents Info Chunk */
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ bool get_spc_metadata(int fd, struct mp3entry* id3)
|
|||
id3->frequency = 32000;
|
||||
id3->length = length+fade;
|
||||
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->genre_string = id3_get_num_genre(36);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
static void read_id3_tags(int fd, struct mp3entry* id3)
|
||||
{
|
||||
id3->title = NULL;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->id3v2len = getid3v2len(fd);
|
||||
id3->vbr = false; /* All TTA files are CBR */
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ bool get_vgm_metadata(int fd, struct mp3entry* id3)
|
|||
}
|
||||
|
||||
id3->vbr = false;
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
id3->bitrate = 1411;
|
||||
id3->frequency = 44100;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ bool get_vox_metadata(int fd, struct mp3entry* id3)
|
|||
id3->frequency = 8000;
|
||||
id3->bitrate = 8000 * 4 / 1000;
|
||||
id3->vbr = false; /* All VOX files are CBR */
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->length = id3->filesize >> 2;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ bool get_vtx_metadata(int fd, struct mp3entry* id3)
|
|||
if (lseek(fd, 0, SEEK_SET) < 0)
|
||||
goto exit_bad;
|
||||
|
||||
if (filesize(fd) < 20)
|
||||
if (ffilesize(fd) < 20)
|
||||
goto exit_bad;
|
||||
|
||||
uint hdr = Reader_ReadWord(fd);
|
||||
|
|
@ -142,7 +142,7 @@ bool get_vtx_metadata(int fd, struct mp3entry* id3)
|
|||
id3->bitrate = 706;
|
||||
id3->frequency = 44100; // XXX allow this to be configured?
|
||||
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
id3->length = info.frames * 1000 / info.playerfreq;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ static bool read_header(int fd, struct mp3entry* id3, const unsigned char *chunk
|
|||
memset(&fmt, 0, sizeof(struct wave_fmt));
|
||||
|
||||
id3->vbr = false; /* All Wave/Wave64 files are CBR */
|
||||
id3->filesize = filesize(fd);
|
||||
id3->filesize = ffilesize(fd);
|
||||
|
||||
/* get RIFF chunk header */
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ bool get_wavpack_metadata(int fd, struct mp3entry* id3)
|
|||
}
|
||||
|
||||
id3->vbr = true; /* All WavPack files are VBR */
|
||||
id3->filesize = filesize (fd);
|
||||
id3->filesize = ffilesize (fd);
|
||||
|
||||
/* check up to 16 headers before we give up finding one with audio */
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue