updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / libdvdread-dvdfilestat / dvd_reader.c.patch
blob60b2c817c9594edf7fe0085d7c66bf7a2e7a0cbd
1 *** dvd_reader.c 2008-09-06 16:55:51.000000000 -0500
2 --- dvd_reader.c 2009-09-09 11:48:38.708607415 -0500
3 ***************
4 *** 889,894 ****
5 --- 889,1077 ----
9 + static int DVDFileStatVOBUDF(dvd_reader_t *dvd, int title,
10 + int menu, dvd_stat_t *statbuf)
11 + {
12 + char filename[ MAX_UDF_FILE_NAME_LEN ];
13 + uint32_t size;
14 + off_t tot_size;
15 + off_t parts_size[9];
16 + int nr_parts = 0;
17 + int n;
19 + if( title == 0 ) {
20 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
21 + } else {
22 + sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
23 + }
24 + if(!UDFFindFile( dvd, filename, &size )) {
25 + return -1;
26 + }
27 + tot_size = size;
28 + nr_parts = 1;
29 + parts_size[0] = size;
31 + if( !menu ) {
32 + int cur;
34 + for( cur = 2; cur < 10; cur++ ) {
35 + sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur );
36 + if( !UDFFindFile( dvd, filename, &size ) ) {
37 + break;
38 + }
39 + parts_size[nr_parts] = size;
40 + tot_size += size;
41 + nr_parts++;
42 + }
43 + }
45 + statbuf->size = tot_size;
46 + statbuf->nr_parts = nr_parts;
47 + for(n = 0; n < nr_parts; n++) {
48 + statbuf->parts_size[n] = parts_size[n];
49 + }
50 + return 0;
51 + }
54 + static int DVDFileStatVOBPath( dvd_reader_t *dvd, int title,
55 + int menu, dvd_stat_t *statbuf )
56 + {
57 + char filename[ MAX_UDF_FILE_NAME_LEN ];
58 + char full_path[ PATH_MAX + 1 ];
59 + struct stat fileinfo;
60 + off_t tot_size;
61 + off_t parts_size[9];
62 + int nr_parts = 0;
63 + int n;
67 + if( title == 0 ) {
68 + sprintf( filename, "VIDEO_TS.VOB" );
69 + } else {
70 + sprintf( filename, "VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
71 + }
72 + if( !findDVDFile( dvd, filename, full_path ) ) {
73 + return -1;
74 + }
76 + if( stat( full_path, &fileinfo ) < 0 ) {
77 + fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
78 + return -1;
79 + }
82 + tot_size = fileinfo.st_size;
83 + nr_parts = 1;
84 + parts_size[0] = fileinfo.st_size;
86 + if( !menu ) {
87 + int cur;
89 + for( cur = 2; cur < 10; cur++ ) {
91 + sprintf( filename, "VTS_%02d_%d.VOB", title, cur );
92 + if( !findDVDFile( dvd, filename, full_path ) ) {
93 + break;
94 + }
96 + if( stat( full_path, &fileinfo ) < 0 ) {
97 + fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
98 + break;
99 + }
101 + parts_size[nr_parts] = fileinfo.st_size;
102 + tot_size += parts_size[nr_parts];
103 + nr_parts++;
107 + statbuf->size = tot_size;
108 + statbuf->nr_parts = nr_parts;
109 + for(n = 0; n < nr_parts; n++) {
110 + statbuf->parts_size[n] = parts_size[n];
112 + return 0;
116 + int DVDFileStat(dvd_reader_t *dvd, int titlenum,
117 + dvd_read_domain_t domain, dvd_stat_t *statbuf)
119 + char filename[ MAX_UDF_FILE_NAME_LEN ];
120 + char full_path[ PATH_MAX + 1 ];
121 + struct stat fileinfo;
122 + uint32_t size;
124 + /* Check arguments. */
125 + if( dvd == NULL || titlenum < 0 ) {
126 + errno = EINVAL;
127 + return -1;
130 + switch( domain ) {
131 + case DVD_READ_INFO_FILE:
132 + if( titlenum == 0 ) {
133 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" );
134 + } else {
135 + sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum );
137 + break;
138 + case DVD_READ_INFO_BACKUP_FILE:
139 + if( titlenum == 0 ) {
140 + sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" );
141 + } else {
142 + sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum );
144 + break;
145 + case DVD_READ_MENU_VOBS:
146 + if( dvd->isImageFile ) {
147 + return DVDFileStatVOBUDF( dvd, titlenum, 1, statbuf );
148 + } else {
149 + return DVDFileStatVOBPath( dvd, titlenum, 1, statbuf );
151 + break;
152 + case DVD_READ_TITLE_VOBS:
153 + if( titlenum == 0 ) {
154 + return -1;
156 + if( dvd->isImageFile ) {
157 + return DVDFileStatVOBUDF( dvd, titlenum, 0, statbuf );
158 + } else {
159 + return DVDFileStatVOBPath( dvd, titlenum, 0, statbuf );
161 + break;
162 + default:
163 + fprintf( stderr, "libdvdread: Invalid domain for file stat.\n" );
164 + errno = EINVAL;
165 + return -1;
168 + if( dvd->isImageFile ) {
169 + if( UDFFindFile( dvd, filename, &size ) ) {
170 + statbuf->size = size;
171 + statbuf->nr_parts = 1;
172 + statbuf->parts_size[0] = size;
173 + return 0;
175 + } else {
176 + if( findDVDFile( dvd, filename, full_path ) ) {
177 + if( stat( full_path, &fileinfo ) < 0 ) {
178 + fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
179 + } else {
180 + statbuf->size = fileinfo.st_size;
181 + statbuf->nr_parts = 1;
182 + statbuf->parts_size[0] = statbuf->size;
183 + return 0;
187 + return -1;
192 /* Internal, but used from dvd_udf.c */
193 int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number,
194 size_t block_count, unsigned char *data,