Prepare new maemo release
[maemo-rb.git] / firmware / include / file.h
blob4ba9c503b4337cc7fbfd3a4e80d6cf95458b4c40
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Björn Stenberg
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef _FILE_H_
23 #define _FILE_H_
25 #include <sys/types.h>
26 #include "config.h"
27 #include "gcc_extensions.h"
28 #include <fcntl.h>
29 #ifdef WIN32
30 /* this has SEEK_SET et al */
31 #include <stdio.h>
32 #endif
35 #undef MAX_PATH /* this avoids problems when building simulator */
36 #define MAX_PATH 260
37 #define MAX_OPEN_FILES 11
39 #if !defined(PLUGIN) && !defined(CODEC)
40 #if defined(APPLICATION) && !defined(__PCTOOL__)
41 # define open(x, ...) app_open(x, __VA_ARGS__)
42 # define creat(x,m) app_creat(x, m)
43 # define remove(x) app_remove(x)
44 # define rename(x,y) app_rename(x,y)
45 extern int app_open(const char *name, int o, ...);
46 extern int app_creat(const char *name, mode_t mode);
47 extern int app_remove(const char* pathname);
48 extern int app_rename(const char* path, const char* newname);
49 # if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
50 # define fsync(x) sim_fsync(x)
51 # define ftruncate(x,y) sim_ftruncate(x,y)
52 # define lseek(x,y,z) sim_lseek(x,y,z)
53 # define read(x,y,z) sim_read(x,y,z)
54 # define write(x,y,z) sim_write(x,y,z)
55 # define close(x) sim_close(x)
56 # endif
57 #elif defined(SIMULATOR) || defined(DBTOOL)
58 # define open(x, ...) sim_open(x, __VA_ARGS__)
59 # define creat(x,m) sim_creat(x,m)
60 # define remove(x) sim_remove(x)
61 # define rename(x,y) sim_rename(x,y)
62 # define fsync(x) sim_fsync(x)
63 # define ftruncate(x,y) sim_ftruncate(x,y)
64 # define lseek(x,y,z) sim_lseek(x,y,z)
65 # define read(x,y,z) sim_read(x,y,z)
66 # define write(x,y,z) sim_write(x,y,z)
67 # define close(x) sim_close(x)
68 extern int sim_open(const char *name, int o, ...);
69 extern int sim_creat(const char *name, mode_t mode);
70 #endif
72 typedef int (*open_func)(const char* pathname, int flags, ...);
73 typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
74 typedef int (*creat_func)(const char *pathname, mode_t mode);
75 typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
76 typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
77 int(*_compar)(const void *, const void *));
79 extern int file_open(const char* pathname, int flags);
80 extern int close(int fd);
81 extern int fsync(int fd);
82 extern ssize_t read(int fd, void *buf, size_t count);
83 extern off_t lseek(int fildes, off_t offset, int whence);
84 extern int file_creat(const char *pathname);
85 #if ((CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(__PCTOOL__)) || \
86 defined(TEST_FAT)
87 #define creat(x, y) file_creat(x)
89 #if !defined(CODEC) && !defined(PLUGIN)
90 #define open(x, y, ...) file_open(x,y)
91 #endif
92 #endif
94 extern ssize_t write(int fd, const void *buf, size_t count);
95 extern int remove(const char* pathname);
96 extern int rename(const char* path, const char* newname);
97 extern int ftruncate(int fd, off_t length);
98 extern off_t filesize(int fd);
99 extern int release_files(int volume);
100 int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
101 #endif /* !CODEC && !PLUGIN */
102 #endif