Manual: update copyright year. We are still working on this.
[kugel-rb.git] / firmware / include / file.h
blob48354505f59d44b0d0d7f189f9070ebdfdab0469
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)
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 filesize(x) sim_filesize(x)
51 # define fsync(x) sim_fsync(x)
52 # define ftruncate(x,y) sim_ftruncate(x,y)
53 # define lseek(x,y,z) sim_lseek(x,y,z)
54 # define read(x,y,z) sim_read(x,y,z)
55 # define write(x,y,z) sim_write(x,y,z)
56 # define close(x) sim_close(x)
57 # endif
58 #elif defined(SIMULATOR)
59 # define open(x, ...) sim_open(x, __VA_ARGS__)
60 # define creat(x,m) sim_creat(x,m)
61 # define remove(x) sim_remove(x)
62 # define rename(x,y) sim_rename(x,y)
63 # define filesize(x) sim_filesize(x)
64 # define fsync(x) sim_fsync(x)
65 # define ftruncate(x,y) sim_ftruncate(x,y)
66 # define lseek(x,y,z) sim_lseek(x,y,z)
67 # define read(x,y,z) sim_read(x,y,z)
68 # define write(x,y,z) sim_write(x,y,z)
69 # define close(x) sim_close(x)
70 extern int sim_open(const char *name, int o, ...);
71 extern int sim_creat(const char *name, mode_t mode);
72 #endif
74 typedef int (*open_func)(const char* pathname, int flags, ...);
75 typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
76 typedef int (*creat_func)(const char *pathname, mode_t mode);
77 typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
78 typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
79 int(*_compar)(const void *, const void *));
81 extern int file_open(const char* pathname, int flags);
82 extern int close(int fd);
83 extern int fsync(int fd);
84 extern ssize_t read(int fd, void *buf, size_t count);
85 extern off_t lseek(int fildes, off_t offset, int whence);
86 extern int file_creat(const char *pathname);
87 #if (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(__PCTOOL__)
88 /* posix compatibility function */
89 static inline int creat(const char *pathname, mode_t mode)
91 (void)mode;
92 return file_creat(pathname);
94 #if !defined(CODEC) && !defined(PLUGIN)
95 #define open(x, y, ...) file_open(x,y)
96 #endif
97 #endif
98 extern ssize_t write(int fd, const void *buf, size_t count);
99 extern int remove(const char* pathname);
100 extern int rename(const char* path, const char* newname);
101 extern int ftruncate(int fd, off_t length);
102 extern off_t filesize(int fd);
103 extern int release_files(int volume);
104 int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
105 #endif /* !CODEC && !PLUGIN */
106 #endif