xref: /aosp_15_r20/external/mesa3d/src/freedreno/decode/io.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
2*61046927SAndroid Build Coastguard Worker 
3*61046927SAndroid Build Coastguard Worker /*
4*61046927SAndroid Build Coastguard Worker  * Copyright © 2014 Rob Clark <[email protected]>
5*61046927SAndroid Build Coastguard Worker  * SPDX-License-Identifier: MIT
6*61046927SAndroid Build Coastguard Worker  *
7*61046927SAndroid Build Coastguard Worker  * Authors:
8*61046927SAndroid Build Coastguard Worker  *    Rob Clark <[email protected]>
9*61046927SAndroid Build Coastguard Worker  */
10*61046927SAndroid Build Coastguard Worker 
11*61046927SAndroid Build Coastguard Worker #ifndef IO_H_
12*61046927SAndroid Build Coastguard Worker #define IO_H_
13*61046927SAndroid Build Coastguard Worker 
14*61046927SAndroid Build Coastguard Worker /* Simple API to abstract reading from file which might be compressed.
15*61046927SAndroid Build Coastguard Worker  * Maybe someday I'll add writing..
16*61046927SAndroid Build Coastguard Worker  */
17*61046927SAndroid Build Coastguard Worker 
18*61046927SAndroid Build Coastguard Worker struct io;
19*61046927SAndroid Build Coastguard Worker 
20*61046927SAndroid Build Coastguard Worker struct io *io_open(const char *filename);
21*61046927SAndroid Build Coastguard Worker struct io *io_openfd(int fd);
22*61046927SAndroid Build Coastguard Worker void io_close(struct io *io);
23*61046927SAndroid Build Coastguard Worker unsigned io_offset(struct io *io);
24*61046927SAndroid Build Coastguard Worker int io_readn(struct io *io, void *buf, int nbytes);
25*61046927SAndroid Build Coastguard Worker 
26*61046927SAndroid Build Coastguard Worker static inline int
check_extension(const char * path,const char * ext)27*61046927SAndroid Build Coastguard Worker check_extension(const char *path, const char *ext)
28*61046927SAndroid Build Coastguard Worker {
29*61046927SAndroid Build Coastguard Worker    return strcmp(path + strlen(path) - strlen(ext), ext) == 0;
30*61046927SAndroid Build Coastguard Worker }
31*61046927SAndroid Build Coastguard Worker 
32*61046927SAndroid Build Coastguard Worker #endif /* IO_H_ */
33