comparison dvdread/dvd_reader.c @ 366:5b8539cacebf src

workaround wrong filesize indicated in the UDF; patch by unknown author posted by Alexander Roalter it
author nicodvb
date Tue, 27 May 2008 21:53:10 +0000
parents eea1e72ea1dd
children
comparison
equal deleted inserted replaced
365:b19a644148a9 366:5b8539cacebf
1040 } 1040 }
1041 dvd_file->seek_pos = (uint32_t) offset; 1041 dvd_file->seek_pos = (uint32_t) offset;
1042 return offset; 1042 return offset;
1043 } 1043 }
1044 1044
1045 int DVDFileSeekForce(dvd_file_t *dvd_file, int offset, int force_size)
1046 {
1047 /* Check arguments. */
1048 if( dvd_file == NULL || offset <= 0 )
1049 return -1;
1050
1051 if( dvd_file->dvd->isImageFile ) {
1052 if( force_size < 0 )
1053 force_size = (offset - 1) / DVD_VIDEO_LB_LEN + 1;
1054 if( dvd_file->filesize < force_size ) {
1055 dvd_file->filesize = force_size;
1056 fprintf(stderr, "libdvdread: Ignored size of file indicated in UDF.\n");
1057 }
1058 }
1059
1060 if( offset > dvd_file->filesize * DVD_VIDEO_LB_LEN )
1061 return -1;
1062
1063 dvd_file->seek_pos = (uint32_t) offset;
1064 return offset;
1065 }
1066
1045 ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size ) 1067 ssize_t DVDReadBytes( dvd_file_t *dvd_file, void *data, size_t byte_size )
1046 { 1068 {
1047 unsigned char *secbuf_base, *secbuf; 1069 unsigned char *secbuf_base, *secbuf;
1048 unsigned int numsec, seek_sector, seek_byte; 1070 unsigned int numsec, seek_sector, seek_byte;
1049 int ret; 1071 int ret;
1080 } 1102 }
1081 1103
1082 memcpy( data, &(secbuf[ seek_byte ]), byte_size ); 1104 memcpy( data, &(secbuf[ seek_byte ]), byte_size );
1083 free( secbuf_base ); 1105 free( secbuf_base );
1084 1106
1085 dvd_file->seek_pos += byte_size; 1107 DVDFileSeekForce(dvd_file, dvd_file->seek_pos + byte_size, -1);
1086 return byte_size; 1108 return byte_size;
1087 } 1109 }
1088 1110
1089 ssize_t DVDFileSize( dvd_file_t *dvd_file ) 1111 ssize_t DVDFileSize( dvd_file_t *dvd_file )
1090 { 1112 {