wok-6.x annotate libdvdread/stuff/DVDFileStat.patch @ rev 18928

Add webdiapo
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Feb 25 16:42:59 2016 +0100 (2016-02-25)
parents
children
rev   line source
slaxemulator@10162 1 diff -pruN libdvdread-4.1.3/src/dvd_reader.c libdvdread-4.1.3.new/src/dvd_reader.c
slaxemulator@10162 2 --- libdvdread-4.1.3/src/dvd_reader.c 2008-09-06 23:55:51.000000000 +0200
slaxemulator@10162 3 +++ libdvdread-4.1.3.new/src/dvd_reader.c 2009-02-28 01:36:20.000000000 +0100
slaxemulator@10162 4 @@ -889,6 +889,187 @@ void DVDCloseFile( dvd_file_t *dvd_file
slaxemulator@10162 5 }
slaxemulator@10162 6 }
slaxemulator@10162 7
slaxemulator@10162 8 +static int DVDFileStatVOBUDF(dvd_reader_t *dvd, int title,
slaxemulator@10162 9 + int menu, dvd_stat_t *statbuf)
slaxemulator@10162 10 +{
slaxemulator@10162 11 + char filename[ MAX_UDF_FILE_NAME_LEN ];
slaxemulator@10162 12 + uint32_t size;
slaxemulator@10162 13 + off_t tot_size;
slaxemulator@10162 14 + off_t parts_size[9];
slaxemulator@10162 15 + int nr_parts = 0;
slaxemulator@10162 16 + int n;
slaxemulator@10162 17 +
slaxemulator@10162 18 + if( title == 0 ) {
slaxemulator@10162 19 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
slaxemulator@10162 20 + } else {
slaxemulator@10162 21 + sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
slaxemulator@10162 22 + }
slaxemulator@10162 23 + if(!UDFFindFile( dvd, filename, &size )) {
slaxemulator@10162 24 + return -1;
slaxemulator@10162 25 + }
slaxemulator@10162 26 + tot_size = size;
slaxemulator@10162 27 + nr_parts = 1;
slaxemulator@10162 28 + parts_size[0] = size;
slaxemulator@10162 29 +
slaxemulator@10162 30 + if( !menu ) {
slaxemulator@10162 31 + int cur;
slaxemulator@10162 32 +
slaxemulator@10162 33 + for( cur = 2; cur < 10; cur++ ) {
slaxemulator@10162 34 + sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur );
slaxemulator@10162 35 + if( !UDFFindFile( dvd, filename, &size ) ) {
slaxemulator@10162 36 + break;
slaxemulator@10162 37 + }
slaxemulator@10162 38 + parts_size[nr_parts] = size;
slaxemulator@10162 39 + tot_size += size;
slaxemulator@10162 40 + nr_parts++;
slaxemulator@10162 41 + }
slaxemulator@10162 42 + }
slaxemulator@10162 43 +
slaxemulator@10162 44 + statbuf->size = tot_size;
slaxemulator@10162 45 + statbuf->nr_parts = nr_parts;
slaxemulator@10162 46 + for(n = 0; n < nr_parts; n++) {
slaxemulator@10162 47 + statbuf->parts_size[n] = parts_size[n];
slaxemulator@10162 48 + }
slaxemulator@10162 49 + return 0;
slaxemulator@10162 50 +}
slaxemulator@10162 51 +
slaxemulator@10162 52 +
slaxemulator@10162 53 +static int DVDFileStatVOBPath( dvd_reader_t *dvd, int title,
slaxemulator@10162 54 + int menu, dvd_stat_t *statbuf )
slaxemulator@10162 55 +{
slaxemulator@10162 56 + char filename[ MAX_UDF_FILE_NAME_LEN ];
slaxemulator@10162 57 + char full_path[ PATH_MAX + 1 ];
slaxemulator@10162 58 + struct stat fileinfo;
slaxemulator@10162 59 + off_t tot_size;
slaxemulator@10162 60 + off_t parts_size[9];
slaxemulator@10162 61 + int nr_parts = 0;
slaxemulator@10162 62 + int n;
slaxemulator@10162 63 +
slaxemulator@10162 64 +
slaxemulator@10162 65 +
slaxemulator@10162 66 + if( title == 0 ) {
slaxemulator@10162 67 + sprintf( filename, "VIDEO_TS.VOB" );
slaxemulator@10162 68 + } else {
slaxemulator@10162 69 + sprintf( filename, "VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
slaxemulator@10162 70 + }
slaxemulator@10162 71 + if( !findDVDFile( dvd, filename, full_path ) ) {
slaxemulator@10162 72 + return -1;
slaxemulator@10162 73 + }
slaxemulator@10162 74 +
slaxemulator@10162 75 + if( stat( full_path, &fileinfo ) < 0 ) {
slaxemulator@10162 76 + fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
slaxemulator@10162 77 + return -1;
slaxemulator@10162 78 + }
slaxemulator@10162 79 +
slaxemulator@10162 80 +
slaxemulator@10162 81 + tot_size = fileinfo.st_size;
slaxemulator@10162 82 + nr_parts = 1;
slaxemulator@10162 83 + parts_size[0] = fileinfo.st_size;
slaxemulator@10162 84 +
slaxemulator@10162 85 + if( !menu ) {
slaxemulator@10162 86 + int cur;
slaxemulator@10162 87 +
slaxemulator@10162 88 + for( cur = 2; cur < 10; cur++ ) {
slaxemulator@10162 89 +
slaxemulator@10162 90 + sprintf( filename, "VTS_%02d_%d.VOB", title, cur );
slaxemulator@10162 91 + if( !findDVDFile( dvd, filename, full_path ) ) {
slaxemulator@10162 92 + break;
slaxemulator@10162 93 + }
slaxemulator@10162 94 +
slaxemulator@10162 95 + if( stat( full_path, &fileinfo ) < 0 ) {
slaxemulator@10162 96 + fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
slaxemulator@10162 97 + break;
slaxemulator@10162 98 + }
slaxemulator@10162 99 +
slaxemulator@10162 100 + parts_size[nr_parts] = fileinfo.st_size;
slaxemulator@10162 101 + tot_size += parts_size[nr_parts];
slaxemulator@10162 102 + nr_parts++;
slaxemulator@10162 103 + }
slaxemulator@10162 104 + }
slaxemulator@10162 105 +
slaxemulator@10162 106 + statbuf->size = tot_size;
slaxemulator@10162 107 + statbuf->nr_parts = nr_parts;
slaxemulator@10162 108 + for(n = 0; n < nr_parts; n++) {
slaxemulator@10162 109 + statbuf->parts_size[n] = parts_size[n];
slaxemulator@10162 110 + }
slaxemulator@10162 111 + return 0;
slaxemulator@10162 112 +}
slaxemulator@10162 113 +
slaxemulator@10162 114 +
slaxemulator@10162 115 +int DVDFileStat(dvd_reader_t *dvd, int titlenum,
slaxemulator@10162 116 + dvd_read_domain_t domain, dvd_stat_t *statbuf)
slaxemulator@10162 117 +{
slaxemulator@10162 118 + char filename[ MAX_UDF_FILE_NAME_LEN ];
slaxemulator@10162 119 + char full_path[ PATH_MAX + 1 ];
slaxemulator@10162 120 + struct stat fileinfo;
slaxemulator@10162 121 + uint32_t size;
slaxemulator@10162 122 +
slaxemulator@10162 123 + /* Check arguments. */
slaxemulator@10162 124 + if( dvd == NULL || titlenum < 0 ) {
slaxemulator@10162 125 + errno = EINVAL;
slaxemulator@10162 126 + return -1;
slaxemulator@10162 127 + }
slaxemulator@10162 128 +
slaxemulator@10162 129 + switch( domain ) {
slaxemulator@10162 130 + case DVD_READ_INFO_FILE:
slaxemulator@10162 131 + if( titlenum == 0 ) {
slaxemulator@10162 132 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" );
slaxemulator@10162 133 + } else {
slaxemulator@10162 134 + sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum );
slaxemulator@10162 135 + }
slaxemulator@10162 136 + break;
slaxemulator@10162 137 + case DVD_READ_INFO_BACKUP_FILE:
slaxemulator@10162 138 + if( titlenum == 0 ) {
slaxemulator@10162 139 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" );
slaxemulator@10162 140 + } else {
slaxemulator@10162 141 + sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum );
slaxemulator@10162 142 + }
slaxemulator@10162 143 + break;
slaxemulator@10162 144 + case DVD_READ_MENU_VOBS:
slaxemulator@10162 145 + if( dvd->isImageFile ) {
slaxemulator@10162 146 + return DVDFileStatVOBUDF( dvd, titlenum, 1, statbuf );
slaxemulator@10162 147 + } else {
slaxemulator@10162 148 + return DVDFileStatVOBPath( dvd, titlenum, 1, statbuf );
slaxemulator@10162 149 + }
slaxemulator@10162 150 + break;
slaxemulator@10162 151 + case DVD_READ_TITLE_VOBS:
slaxemulator@10162 152 + if( titlenum == 0 ) {
slaxemulator@10162 153 + return -1;
slaxemulator@10162 154 + }
slaxemulator@10162 155 + if( dvd->isImageFile ) {
slaxemulator@10162 156 + return DVDFileStatVOBUDF( dvd, titlenum, 0, statbuf );
slaxemulator@10162 157 + } else {
slaxemulator@10162 158 + return DVDFileStatVOBPath( dvd, titlenum, 0, statbuf );
slaxemulator@10162 159 + }
slaxemulator@10162 160 + break;
slaxemulator@10162 161 + default:
slaxemulator@10162 162 + fprintf( stderr, "libdvdread: Invalid domain for file stat.\n" );
slaxemulator@10162 163 + errno = EINVAL;
slaxemulator@10162 164 + return -1;
slaxemulator@10162 165 + }
slaxemulator@10162 166 +
slaxemulator@10162 167 + if( dvd->isImageFile ) {
slaxemulator@10162 168 + if( UDFFindFile( dvd, filename, &size ) ) {
slaxemulator@10162 169 + statbuf->size = size;
slaxemulator@10162 170 + statbuf->nr_parts = 1;
slaxemulator@10162 171 + statbuf->parts_size[0] = size;
slaxemulator@10162 172 + return 0;
slaxemulator@10162 173 + }
slaxemulator@10162 174 + } else {
slaxemulator@10162 175 + if( findDVDFile( dvd, filename, full_path ) ) {
slaxemulator@10162 176 + if( stat( full_path, &fileinfo ) < 0 ) {
slaxemulator@10162 177 + fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
slaxemulator@10162 178 + } else {
slaxemulator@10162 179 + statbuf->size = fileinfo.st_size;
slaxemulator@10162 180 + statbuf->nr_parts = 1;
slaxemulator@10162 181 + statbuf->parts_size[0] = statbuf->size;
slaxemulator@10162 182 + return 0;
slaxemulator@10162 183 + }
slaxemulator@10162 184 + }
slaxemulator@10162 185 + }
slaxemulator@10162 186 + return -1;
slaxemulator@10162 187 +}
slaxemulator@10162 188 +
slaxemulator@10162 189 /* Internal, but used from dvd_udf.c */
slaxemulator@10162 190 int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number,
slaxemulator@10162 191 size_t block_count, unsigned char *data,
slaxemulator@10162 192 diff -pruN libdvdread-4.1.3/src/dvd_reader.h libdvdread-4.1.3.new/src/dvd_reader.h
slaxemulator@10162 193 --- libdvdread-4.1.3/src/dvd_reader.h 2008-09-06 23:55:51.000000000 +0200
slaxemulator@10162 194 +++ libdvdread-4.1.3.new/src/dvd_reader.h 2009-02-28 01:36:49.000000000 +0100
slaxemulator@10162 195 @@ -115,6 +115,42 @@ typedef enum {
slaxemulator@10162 196 } dvd_read_domain_t;
slaxemulator@10162 197
slaxemulator@10162 198 /**
slaxemulator@10162 199 + *
slaxemulator@10162 200 + */
slaxemulator@10162 201 +typedef struct {
slaxemulator@10162 202 + off_t size; /**< Total size of file in bytes */
slaxemulator@10162 203 + int nr_parts; /**< Number of file parts */
slaxemulator@10162 204 + off_t parts_size[9]; /**< Size of each part in bytes */
slaxemulator@10162 205 +} dvd_stat_t;
slaxemulator@10162 206 +
slaxemulator@10162 207 +/**
slaxemulator@10162 208 + * Stats a file on the DVD given the title number and domain.
slaxemulator@10162 209 + * The information about the file is stored in a dvd_stat_t
slaxemulator@10162 210 + * which contains information about the size of the file and
slaxemulator@10162 211 + * the number of parts in case of a multipart file and the respective
slaxemulator@10162 212 + * sizes of the parts.
slaxemulator@10162 213 + * A multipart file is for instance VTS_02_1.VOB, VTS_02_2.VOB, VTS_02_3.VOB
slaxemulator@10162 214 + * The size of VTS_02_1.VOB will be stored in stat->parts_size[0],
slaxemulator@10162 215 + * VTS_02_2.VOB in stat->parts_size[1], ...
slaxemulator@10162 216 + * The total size (sum of all parts) is stored in stat->size and
slaxemulator@10162 217 + * stat->nr_parts will hold the number of parts.
slaxemulator@10162 218 + * Only DVD_READ_TITLE_VOBS (VTS_??_[1-9].VOB) can be multipart files.
slaxemulator@10162 219 + *
slaxemulator@10162 220 + * This function is only of use if you want to get the size of each file
slaxemulator@10162 221 + * in the filesystem. These sizes are not needed to use any other
slaxemulator@10162 222 + * functions in libdvdread.
slaxemulator@10162 223 + *
slaxemulator@10162 224 + * @param dvd A dvd read handle.
slaxemulator@10162 225 + * @param titlenum Which Video Title Set should be used, VIDEO_TS is 0.
slaxemulator@10162 226 + * @param domain Which domain.
slaxemulator@10162 227 + * @param stat Pointer to where the result is stored.
slaxemulator@10162 228 + * @return If successful 0, otherwise -1.
slaxemulator@10162 229 + *
slaxemulator@10162 230 + * int DVDFileStat(dvd, titlenum, domain, stat);
slaxemulator@10162 231 + */
slaxemulator@10162 232 +int DVDFileStat(dvd_reader_t *, int, dvd_read_domain_t, dvd_stat_t *);
slaxemulator@10162 233 +
slaxemulator@10162 234 +/**
slaxemulator@10162 235 * Opens a file on the DVD given the title number and domain.
slaxemulator@10162 236 *
slaxemulator@10162 237 * If the title number is 0, the video manager information is opened