]> git.sesse.net Git - vlc/blobdiff - plugins/dvd/dvd_udf.c
* Win2000 DVD input by Jon Lech Johansen <jon-vl@nanocrew.net>.
[vlc] / plugins / dvd / dvd_udf.c
index 50d2ef78e3b9059bd0a1de6c0e4074b1d7da770f..8147aa4f5cdcfa71ef559d7cabb26c88420276d8 100644 (file)
@@ -5,7 +5,7 @@
  * contains the basic udf handling functions
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: dvd_udf.c,v 1.6 2001/04/28 03:36:25 sam Exp $
+ * $Id: dvd_udf.c,v 1.8 2001/05/31 03:12:49 sam Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
 #include "defs.h"
 
 #ifdef HAVE_CSS
-#define MODULE_NAME dvd
+#   define MODULE_NAME dvd
 #else /* HAVE_CSS */
-#define MODULE_NAME dvdnocss
+#   define MODULE_NAME dvdnocss
 #endif /* HAVE_CSS */
+
 #include "modules_inner.h"
 
 #include <stdio.h>
-#include <unistd.h>
 #include <string.h>
+#include <fcntl.h>
+
+#ifdef HAVE_UNISTD_H
+#   include <unistd.h>
+#elif defined( _MSC_VER ) && defined( _WIN32 )
+#   include <io.h>
+#endif
+
 #ifdef STRNCASECMP_IN_STRINGS_H
 #   include <strings.h>
 #endif
-#include <fcntl.h>
 
 #include "common.h"
 #include "intf_msg.h"
@@ -93,18 +100,39 @@ typedef struct ad_s
  *****************************************************************************/
 static int UDFReadLB( int i_fd, off_t i_lba, size_t i_block_count, u8 *pi_data )
 {
+#if !defined( WIN32 )
     if( i_fd < 0 )
+#else
+    DWORD read;
+
+    if( (HANDLE) i_fd == INVALID_HANDLE_VALUE )
+#endif
     {
         return 0;
     }
 
+#if !defined( WIN32 )
     if( lseek( i_fd, i_lba * (off_t) DVD_LB_SIZE, SEEK_SET ) < 0 )
+#else
+    if( SetFilePointer( (HANDLE) i_fd, i_lba * (off_t) DVD_LB_SIZE,
+        NULL, FILE_BEGIN ) == -1 )
+#endif
     {
         intf_ErrMsg( "UDF: Postion not found" );
         return 0;
     }
 
+#if !defined( WIN32 )
     return read( i_fd, pi_data, i_block_count *DVD_LB_SIZE);
+#else
+    if(!ReadFile( (HANDLE) i_fd, pi_data, i_block_count * DVD_LB_SIZE,
+        &read, NULL) || read != i_block_count * DVD_LB_SIZE )
+    {
+        return 0;
+    }
+
+    return read;
+#endif
 }