libdvdread 7.1.0
dvd_filesystem.h
1/*
2 * This file is part of libdvdread
3 * Copyright (C) 2026 VideoLAN
4 *
5 * This file is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This file is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see
17 * <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef DVDREAD_FILESYSTEM_H_
21#define DVDREAD_FILESYSTEM_H_
22
23/* glibc only exposes off64_t under the large file interface */
24#ifndef _LARGEFILE64_SOURCE
25#define _LARGEFILE64_SOURCE
26#endif
27
28#include <stdint.h>
29#include <sys/types.h>
30
31#if defined(_MSC_VER)
32#include <basetsd.h>
33#if !defined(ssize_t)
34typedef SSIZE_T ssize_t;
35#endif
36typedef __int64 off64_t;
37#elif defined(__GLIBC__)
38/* sys/types.h may have been included before _LARGEFILE64_SOURCE was defined. */
39typedef __off64_t off64_t;
40#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
41/* off_t is already 64 bit here so off64_t is not provided. */
42typedef off_t off64_t;
43#endif
44
45/* directory entry, only d_name is used by the lib */
46typedef struct
47{
48 char d_name[256];
50
51#define DVD_S_IFMT 0170000 /* These bits determine file type. */
52#define DVD_S_IFCHR 0020000 /* character special */
53#define DVD_S_IFDIR 0040000 /* directory */
54#define DVD_S_IFBLK 0060000 /* block special */
55#define DVD_S_IFREG 0100000 /* regular */
56
57/* size is fixed width so it does not depend on the caller off_t */
58typedef struct
59{
60 uint64_t size;
61 unsigned int st_mode;
62} dvdstat_t;
63
64/*
65 * the struct an application fills in to provide its own filesystem
66 *
67 * dir_open and file_open return a handle the application defines, the lib only
68 * hands it back to the matching read, seek and close calls
69 *
70 * stat returns 0 on success or a negative value on error
71 * dir_read returns 0 on success, a positive value at end of directory, a negative value on error
72 * file_read returns the bytes read, 0 at end of file, a negative value on error
73 * file_seek returns the offset from the start of the file or a negative value on error
74 */
75typedef struct dvd_reader_filesystem_s dvd_reader_filesystem_h;
77{
78 void *internal;
79 void (*close) (dvd_reader_filesystem_h *fs);
80 int (*stat) (dvd_reader_filesystem_h *fs, const char *path, dvdstat_t *statbuf);
81 void *(*dir_open) (dvd_reader_filesystem_h *fs, const char *dirname);
82 int (*dir_read) (void *dir, dvd_dirent_t *entry);
83 void (*dir_close) (void *dir);
84 void *(*file_open) (dvd_reader_filesystem_h *fs, const char *filename);
85 ssize_t (*file_read) (void *file, char *buf, size_t size);
86 off64_t (*file_seek) (void *file, off64_t offset, int whence);
87 int (*file_close)(void *file);
88};
89
90#endif /* DVDREAD_FILESYSTEM_H_ */
Definition dvd_filesystem.h:47
Definition dvd_filesystem.h:77
Definition dvd_filesystem.h:59