Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
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 )
...
@@ -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_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_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_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
)
static
inline
void
block_Cleanup
(
void
*
block
)
{
{
...
...
src/libvlccore.sym
View file @
79139b20
...
@@ -26,6 +26,7 @@ block_FifoPut
...
@@ -26,6 +26,7 @@ block_FifoPut
block_FifoRelease
block_FifoRelease
block_FifoShow
block_FifoShow
block_File
block_File
block_FilePath
block_heap_Alloc
block_heap_Alloc
block_Init
block_Init
block_mmap_Alloc
block_mmap_Alloc
...
...
src/misc/block.c
View file @
79139b20
...
@@ -34,10 +34,11 @@
...
@@ -34,10 +34,11 @@
#ifdef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
# include <unistd.h>
#endif
#endif
#include <fcntl.h>
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_block.h>
#include <vlc_block.h>
#include <vlc_fs.h>
/* For 64-bits lseek() definition */
#include <vlc_fs.h>
/**
/**
* @section Block handling functions.
* @section Block handling functions.
...
@@ -358,10 +359,13 @@ ssize_t pread (int fd, void *buf, size_t count, off_t offset)
...
@@ -358,10 +359,13 @@ ssize_t pread (int fd, void *buf, size_t count, off_t offset)
#endif
#endif
/**
/**
* Loads a file into a block of memory. If possible a private file mapping is
* Loads a file into a block of memory through a file descriptor.
* created. Otherwise, the file is read normally. On 32-bits platforms, this
* If possible a private file mapping is created. Otherwise, the file is read
* function will not work for very large files, due to memory space
* normally. This function is a cancellation point.
* constraints. 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
* @param fd file descriptor to load from
* @return a new block with the file content at p_buffer, and file length at
* @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)
...
@@ -433,6 +437,21 @@ block_t *block_File (int fd)
return
block
;
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
* @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