Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 295986 | Differences between
and this patch

Collapse All | Expand All

(-)libdvdread-4.1.3_p1168.orig/src/dvdread/dvd_reader.h (+36 lines)
Lines 117-122 typedef enum { Link Here
117
} dvd_read_domain_t;
117
} dvd_read_domain_t;
118
118
119
/**
119
/**
120
 *
121
 */
122
typedef struct {
123
  off_t size;          /**< Total size of file in bytes */
124
  int nr_parts;        /**< Number of file parts */
125
  off_t parts_size[9]; /**< Size of each part in bytes */
126
} dvd_stat_t;
127
128
/**
129
 * Stats a file on the DVD given the title number and domain.
130
 * The information about the file is stored in a dvd_stat_t
131
 * which contains information about the size of the file and
132
 * the number of parts in case of a multipart file and the respective
133
 * sizes of the parts.
134
 * A multipart file is for instance VTS_02_1.VOB, VTS_02_2.VOB, VTS_02_3.VOB
135
 * The size of VTS_02_1.VOB will be stored in stat->parts_size[0],
136
 * VTS_02_2.VOB in stat->parts_size[1], ...
137
 * The total size (sum of all parts) is stored in stat->size and
138
 * stat->nr_parts will hold the number of parts.
139
 * Only DVD_READ_TITLE_VOBS (VTS_??_[1-9].VOB) can be multipart files.
140
 * 
141
 * This function is only of use if you want to get the size of each file
142
 * in the filesystem. These sizes are not needed to use any other
143
 * functions in libdvdread. 
144
 *
145
 * @param dvd  A dvd read handle.
146
 * @param titlenum Which Video Title Set should be used, VIDEO_TS is 0.
147
 * @param domain Which domain. 
148
 * @param stat Pointer to where the result is stored.
149
 * @return If successful 0, otherwise -1.
150
 *
151
 * int DVDFileStat(dvd, titlenum, domain, stat);
152
 */
153
int DVDFileStat(dvd_reader_t *, int, dvd_read_domain_t, dvd_stat_t *);
154
  
155
/**
120
 * Opens a file on the DVD given the title number and domain.
156
 * Opens a file on the DVD given the title number and domain.
121
 *
157
 *
122
 * If the title number is 0, the video manager information is opened
158
 * If the title number is 0, the video manager information is opened
(-)libdvdread-4.1.3_p1168.orig/src/dvd_reader.c (+181 lines)
Lines 889-894 void DVDCloseFile( dvd_file_t *dvd_file Link Here
889
  }
889
  }
890
}
890
}
891
891
892
static int DVDFileStatVOBUDF(dvd_reader_t *dvd, int title, 
893
                             int menu, dvd_stat_t *statbuf)
894
{
895
  char filename[ MAX_UDF_FILE_NAME_LEN ];
896
  uint32_t size;
897
  off_t tot_size;
898
  off_t parts_size[9];
899
  int nr_parts = 0;
900
  int n;
901
 
902
  if( title == 0 ) {
903
    sprintf( filename, "/VIDEO_TS/VIDEO_TS.VOB" );
904
  } else {
905
    sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
906
  }
907
  if(!UDFFindFile( dvd, filename, &size )) {
908
    return -1;
909
  }
910
  tot_size = size;
911
  nr_parts = 1;
912
  parts_size[0] = size;
913
914
  if( !menu ) {
915
    int cur;
916
917
    for( cur = 2; cur < 10; cur++ ) {
918
      sprintf( filename, "/VIDEO_TS/VTS_%02d_%d.VOB", title, cur );
919
      if( !UDFFindFile( dvd, filename, &size ) ) {
920
        break;
921
      }
922
      parts_size[nr_parts] = size;
923
      tot_size += size;
924
      nr_parts++;
925
    }
926
  }
927
  
928
  statbuf->size = tot_size;
929
  statbuf->nr_parts = nr_parts;
930
  for(n = 0; n < nr_parts; n++) {
931
    statbuf->parts_size[n] = parts_size[n];
932
  }
933
  return 0;
934
}
935
936
937
static int DVDFileStatVOBPath( dvd_reader_t *dvd, int title,
938
                                       int menu, dvd_stat_t *statbuf )
939
{
940
  char filename[ MAX_UDF_FILE_NAME_LEN ];
941
  char full_path[ PATH_MAX + 1 ];
942
  struct stat fileinfo;
943
  off_t tot_size;
944
  off_t parts_size[9];
945
  int nr_parts = 0;
946
  int n;
947
948
 
949
    
950
  if( title == 0 ) {
951
    sprintf( filename, "VIDEO_TS.VOB" );
952
  } else {
953
    sprintf( filename, "VTS_%02d_%d.VOB", title, menu ? 0 : 1 );
954
  }
955
  if( !findDVDFile( dvd, filename, full_path ) ) {
956
    return -1;
957
  }
958
  
959
  if( stat( full_path, &fileinfo ) < 0 ) {
960
    fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
961
    return -1;
962
  }
963
  
964
965
  tot_size = fileinfo.st_size;
966
  nr_parts = 1;
967
  parts_size[0] = fileinfo.st_size;
968
969
  if( !menu ) {
970
    int cur;
971
    
972
    for( cur = 2; cur < 10; cur++ ) {
973
974
      sprintf( filename, "VTS_%02d_%d.VOB", title, cur );
975
      if( !findDVDFile( dvd, filename, full_path ) ) {
976
        break;
977
      }
978
979
      if( stat( full_path, &fileinfo ) < 0 ) {
980
        fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
981
        break;
982
      }
983
      
984
      parts_size[nr_parts] = fileinfo.st_size;
985
      tot_size += parts_size[nr_parts];
986
      nr_parts++;
987
    }
988
  }
989
990
  statbuf->size = tot_size;
991
  statbuf->nr_parts = nr_parts;
992
  for(n = 0; n < nr_parts; n++) {
993
    statbuf->parts_size[n] = parts_size[n];
994
  }
995
  return 0;
996
}
997
998
999
int DVDFileStat(dvd_reader_t *dvd, int titlenum, 
1000
                dvd_read_domain_t domain, dvd_stat_t *statbuf)
1001
{
1002
  char filename[ MAX_UDF_FILE_NAME_LEN ];
1003
  char full_path[ PATH_MAX + 1 ];
1004
  struct stat fileinfo;
1005
  uint32_t size;
1006
1007
  /* Check arguments. */
1008
  if( dvd == NULL || titlenum < 0 ) {
1009
    errno = EINVAL;
1010
    return -1;
1011
  }
1012
1013
  switch( domain ) {
1014
  case DVD_READ_INFO_FILE:
1015
    if( titlenum == 0 ) {
1016
      sprintf( filename, "/VIDEO_TS/VIDEO_TS.IFO" );
1017
    } else {
1018
      sprintf( filename, "/VIDEO_TS/VTS_%02i_0.IFO", titlenum );
1019
    }
1020
    break;
1021
  case DVD_READ_INFO_BACKUP_FILE:
1022
    if( titlenum == 0 ) {
1023
      sprintf( filename, "/VIDEO_TS/VIDEO_TS.BUP" );
1024
    } else {
1025
      sprintf( filename, "/VIDEO_TS/VTS_%02i_0.BUP", titlenum );
1026
    }
1027
    break;
1028
  case DVD_READ_MENU_VOBS:
1029
    if( dvd->isImageFile ) {
1030
      return DVDFileStatVOBUDF( dvd, titlenum, 1, statbuf );
1031
    } else {
1032
      return DVDFileStatVOBPath( dvd, titlenum, 1, statbuf );
1033
    }
1034
    break;
1035
  case DVD_READ_TITLE_VOBS:
1036
    if( titlenum == 0 ) {
1037
      return -1;
1038
    }
1039
    if( dvd->isImageFile ) {
1040
      return DVDFileStatVOBUDF( dvd, titlenum, 0, statbuf );
1041
    } else {
1042
      return DVDFileStatVOBPath( dvd, titlenum, 0, statbuf );
1043
    }
1044
    break;
1045
  default:
1046
    fprintf( stderr, "libdvdread: Invalid domain for file stat.\n" );
1047
    errno = EINVAL;
1048
    return -1;
1049
  }
1050
  
1051
  if( dvd->isImageFile ) {
1052
    if( UDFFindFile( dvd, filename, &size ) ) {
1053
      statbuf->size = size;
1054
      statbuf->nr_parts = 1;
1055
      statbuf->parts_size[0] = size;
1056
      return 0;
1057
    }
1058
  } else {
1059
    if( findDVDFile( dvd, filename, full_path ) )  {
1060
      if( stat( full_path, &fileinfo ) < 0 ) {
1061
        fprintf( stderr, "libdvdread: Can't stat() %s.\n", filename );
1062
      } else {
1063
        statbuf->size = fileinfo.st_size;
1064
        statbuf->nr_parts = 1;
1065
        statbuf->parts_size[0] = statbuf->size;
1066
        return 0;
1067
      }
1068
    }
1069
  }
1070
  return -1;
1071
}
1072
892
/* Internal, but used from dvd_udf.c */
1073
/* Internal, but used from dvd_udf.c */
893
int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number,
1074
int UDFReadBlocksRaw( dvd_reader_t *device, uint32_t lb_number,
894
                      size_t block_count, unsigned char *data,
1075
                      size_t block_count, unsigned char *data,

Return to bug 295986