* contains the basic udf handling functions
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: dvd_udf.c,v 1.7 2001/05/31 01:37:08 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 <string.h>
+#include <fcntl.h>
#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
#elif defined( _MSC_VER ) && defined( _WIN32 )
-#include <io.h>
+# include <io.h>
#endif
-#include <string.h>
#ifdef STRNCASECMP_IN_STRINGS_H
# include <strings.h>
#endif
-#include <fcntl.h>
#include "common.h"
#include "intf_msg.h"
*****************************************************************************/
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
}