Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
c7a41e0c
Commit
c7a41e0c
authored
Nov 18, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a utf8_mkstemp implementation.
parent
3fd3d4a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
include/vlc_charset.h
include/vlc_charset.h
+2
-0
src/text/filesystem.c
src/text/filesystem.c
+43
-0
No files found.
include/vlc_charset.h
View file @
c7a41e0c
...
...
@@ -60,6 +60,8 @@ VLC_EXPORT( int, utf8_lstat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT
(
int
,
utf8_vfprintf
,
(
FILE
*
stream
,
const
char
*
fmt
,
va_list
ap
)
);
VLC_EXPORT
(
int
,
utf8_fprintf
,
(
FILE
*
,
const
char
*
,
...
)
LIBVLC_FORMAT
(
2
,
3
)
);
VLC_EXPORT
(
int
,
utf8_mkstemp
,
(
char
*
)
);
VLC_EXPORT
(
char
*
,
EnsureUTF8
,
(
char
*
)
);
VLC_EXPORT
(
const
char
*
,
IsUTF8
,
(
const
char
*
)
LIBVLC_USED
);
...
...
src/text/filesystem.c
View file @
c7a41e0c
...
...
@@ -432,3 +432,46 @@ int utf8_unlink( const char *filename )
LocaleFree
(
local_name
);
return
ret
;
}
int
utf8_mkstemp
(
char
*
template
)
{
static
const
char
digits
[]
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
static
const
int
i_digits
=
sizeof
(
digits
)
/
sizeof
(
*
digits
)
-
1
;
/* */
assert
(
template
);
/* Check template validity */
const
size_t
i_length
=
strlen
(
template
);
char
*
psz_rand
=
&
template
[
i_length
-
6
];
if
(
i_length
<
6
||
strcmp
(
psz_rand
,
"XXXXXX"
)
)
{
errno
=
EINVAL
;
return
-
1
;
}
uint64_t
i_rand
=
mdate
();
/* */
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
/* Create a pseudo random file name */
for
(
int
j
=
0
;
j
<
6
;
j
++
)
{
i_rand
=
i_rand
*
UINT64_C
(
1103515245
)
+
12345
;
psz_rand
[
j
]
=
digits
[((
i_rand
>>
16
)
&
0xffff
)
%
i_digits
];
}
/* */
int
fd
=
utf8_open
(
template
,
O_CREAT
|
O_EXCL
|
O_RDWR
,
0600
);
if
(
fd
>=
0
)
return
fd
;
if
(
errno
!=
EEXIST
)
return
-
1
;
}
errno
=
EEXIST
;
return
-
1
;
}
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