Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
79139b20
Commit
79139b20
authored
Sep 29, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block: add block_FilePath() to load a file into a block_t
parent
5344b8e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
include/vlc_block.h
include/vlc_block.h
+1
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/misc/block.c
src/misc/block.c
+24
-5
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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