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