Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lyndon Brown
VLC
Commits
14ee4059
Commit
14ee4059
authored
4 years ago
by
Lyndon Brown
Browse files
Options
Downloads
Patches
Plain Diff
core: add vlc_MakeTmpFile() helper
to avoid messy and duplicated code creating temporary files.
parent
c31315c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/vlc_fs.h
+15
-0
15 additions, 0 deletions
include/vlc_fs.h
src/libvlccore.sym
+1
-0
1 addition, 0 deletions
src/libvlccore.sym
src/text/filesystem.c
+19
-0
19 additions, 0 deletions
src/text/filesystem.c
with
35 additions
and
0 deletions
include/vlc_fs.h
+
15
−
0
View file @
14ee4059
...
...
@@ -99,6 +99,21 @@ VLC_API int vlc_openat(int fd, const char *filename, int flags, ...) VLC_USED;
VLC_API
int
vlc_mkstemp
(
char
*
);
/**
* Temporary file creation helper
*
* Creates a unique temporary file, using config_GetTempPath() to determine the
* directory in which to create it, and using vlc_mkstemp() for the creation.
*
* Note, the returned `path` pointer must be free'd with free(), except when
* the returned file descriptor is -1 indicating error, where is it undefined.
*
* @param path [OUT] full path of the created file.
* @param filetemplate filename template, which must end with a sequence of 'XXXXXX'.
* @return file descriptor, or -1 on error.
*/
VLC_API
int
vlc_MakeTmpFile
(
char
**
path
,
const
char
*
filetemplate
)
VLC_USED
;
/**
* Duplicates a file descriptor. The new file descriptor has the close-on-exec
* descriptor flag preset.
...
...
This diff is collapsed.
Click to expand it.
src/libvlccore.sym
+
1
−
0
View file @
14ee4059
...
...
@@ -432,6 +432,7 @@ vlc_loaddir
vlc_lstat
vlc_mkdir
vlc_mkstemp
vlc_MakeTmpFile
vlc_open
vlc_openat
vlc_memfd
...
...
This diff is collapsed.
Click to expand it.
src/text/filesystem.c
+
19
−
0
View file @
14ee4059
...
...
@@ -30,6 +30,7 @@
#include
<vlc_common.h>
#include
<vlc_fs.h>
#include
<vlc_configuration.h>
#include
<vlc_sort.h>
#include
<assert.h>
...
...
@@ -242,3 +243,21 @@ VLC_WEAK int vlc_mkstemp(char *template)
errno
=
EEXIST
;
return
-
1
;
}
int
vlc_MakeTmpFile
(
char
**
path
,
const
char
*
filetemplate
)
{
char
*
tmpdir
=
config_GetTempPath
();
if
(
tmpdir
==
NULL
)
return
-
1
;
if
(
asprintf
(
path
,
"%s"
DIR_SEP
"%s"
,
tmpdir
,
filetemplate
)
<
0
)
{
free
(
tmpdir
);
return
-
1
;
}
free
(
tmpdir
);
int
fd
=
vlc_mkstemp
(
*
path
);
if
(
fd
==
-
1
)
free
(
*
path
);
return
fd
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment