Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
79139b20
Commit
79139b20
authored
Sep 29, 2012
by
Rémi Denis-Courmont
Browse files
block: add block_FilePath() to load a file into a block_t
parent
5344b8e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/vlc_block.h
View file @
79139b20
...
...
@@ -166,6 +166,7 @@ static inline void block_Release( block_t *p_block )
VLC_API
block_t
*
block_heap_Alloc
(
void
*
,
size_t
)
VLC_USED
VLC_MALLOC
;
VLC_API
block_t
*
block_mmap_Alloc
(
void
*
addr
,
size_t
length
)
VLC_USED
VLC_MALLOC
;
VLC_API
block_t
*
block_File
(
int
fd
)
VLC_USED
VLC_MALLOC
;
VLC_API
block_t
*
block_FilePath
(
const
char
*
)
VLC_USED
VLC_MALLOC
;
static
inline
void
block_Cleanup
(
void
*
block
)
{
...
...
src/libvlccore.sym
View file @
79139b20
...
...
@@ -26,6 +26,7 @@ block_FifoPut
block_FifoRelease
block_FifoShow
block_File
block_FilePath
block_heap_Alloc
block_Init
block_mmap_Alloc
...
...
src/misc/block.c
View file @
79139b20
...
...
@@ -34,10 +34,11 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include
<fcntl.h>
#include
<vlc_common.h>
#include
<vlc_block.h>
#include
<vlc_fs.h>
/* For 64-bits lseek() definition */
#include
<vlc_fs.h>
/**
* @section Block handling functions.
...
...
@@ -358,10 +359,13 @@ ssize_t pread (int fd, void *buf, size_t count, off_t offset)
#endif
/**
* Loads a file into a block of memory. If possible a private file mapping is
* created. Otherwise, the file is read normally. On 32-bits platforms, this
* function will not work for very large files, due to memory space
* constraints. Cancellation point.
* Loads a file into a block of memory through a file descriptor.
* If possible a private file mapping is created. Otherwise, the file is read
* normally. This function is a cancellation point.
*
* @note On 32-bits platforms,
* this function will not work for very large files,
* due to memory space constraints.
*
* @param fd file descriptor to load from
* @return a new block with the file content at p_buffer, and file length at
...
...
@@ -433,6 +437,21 @@ block_t *block_File (int fd)
return
block
;
}
/**
* Loads a file into a block of memory from the file path.
* See also block_File().
*/
block_t
*
block_FilePath
(
const
char
*
path
)
{
int
fd
=
vlc_open
(
path
,
O_RDONLY
);
if
(
fd
==
-
1
)
return
NULL
;
block_t
*
block
=
block_File
(
fd
);
close
(
fd
);
return
block
;
}
/**
* @section Thread-safe block queue functions
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment