#include <vlc_access.h>
#include <vlc_input.h>
#include <vlc_charset.h>
-#include <vlc_interface.h>
+#include <vlc_dialog.h>
#include <assert.h>
set_capability ("access", 52)
add_shortcut ("file")
set_callbacks (Open, Close)
+#ifdef __APPLE__
+ add_bool ("file-mmap", true, NULL,
+ FILE_MMAP_TEXT, FILE_MMAP_LONGTEXT, true)
+#else
add_bool ("file-mmap", false, NULL,
- FILE_MMAP_TEXT, FILE_MMAP_LONGTEXT, true);
+ FILE_MMAP_TEXT, FILE_MMAP_LONGTEXT, true)
+#endif
vlc_module_end ()
static block_t *Block (access_t *);
else
{
msg_Dbg (p_access, "opening file %s", path);
- fd = utf8_open (path, O_RDONLY | O_NOCTTY, 0666);
+ fd = utf8_open (path, O_RDONLY | O_NOCTTY);
}
if (fd == -1)
msg_Warn (p_access, "cannot open %s: %m", path);
goto error;
}
- fcntl (fd, F_SETFD, fcntl (fd, F_GETFD) | FD_CLOEXEC);
/* mmap() is only safe for regular and block special files.
* For other types, it may be some idiosyncrasic interface (e.g. packet
if (!S_ISREG (st.st_mode) && !S_ISBLK (st.st_mode))
{
- msg_Dbg (p_access, "skipping non regular file %s", path);
+ msg_Dbg (p_access, "skipping non-regular file %s", path);
goto error;
}
const uintptr_t page_mask = p_sys->page_size - 1;
/* Start the mapping on a page boundary: */
- off_t outer_offset = p_access->info.i_pos & ~page_mask;
+ off_t outer_offset = p_access->info.i_pos & ~(off_t)page_mask;
/* Skip useless bytes at the beginning of the first page: */
size_t inner_offset = p_access->info.i_pos & page_mask;
/* Map no more bytes than remain: */
if (addr == MAP_FAILED)
{
msg_Err (p_access, "memory mapping failed (%m)");
- intf_UserFatal (p_access, false, _("File reading failed"),
+ dialog_Fatal (p_access, _("File reading failed"), "%s",
_("VLC could not read the file."));
goto fatal;
}
static int Control (access_t *p_access, int query, va_list args)
{
- access_sys_t *p_sys = p_access->p_sys;
-
switch (query)
{
case ACCESS_CAN_SEEK:
case ACCESS_CAN_FASTSEEK:
case ACCESS_CAN_PAUSE:
case ACCESS_CAN_CONTROL_PACE:
- *((bool *)va_arg (args, bool *)) = true;
- return VLC_SUCCESS;
-
- case ACCESS_GET_MTU:
- *((int *)va_arg (args, int *)) = p_sys->mtu;
+ *va_arg(args, bool *) = true;
return VLC_SUCCESS;
case ACCESS_GET_PTS_DELAY:
{
int delay_ms = var_CreateGetInteger (p_access, "file-caching");
- *((int64_t *)va_arg (args, int64_t *)) = delay_ms * INT64_C (1000);
+ *va_arg(args, int64_t *) = delay_ms * INT64_C (1000);
return VLC_SUCCESS;
}