Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
f978b748
Commit
f978b748
authored
Aug 30, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compat: Move `mkstemp` to the POSIX compat layer
parent
3ef7d063
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
11 deletions
+22
-11
src/fileops.c
+3
-11
src/unix/posix.h
+1
-0
src/win32/posix.c
+17
-0
src/win32/posix.h
+1
-0
No files found.
src/fileops.c
View file @
f978b748
...
...
@@ -55,18 +55,10 @@ int git_futils_mktmp(char *path_out, const char *filename)
strcpy
(
path_out
,
filename
);
strcat
(
path_out
,
"_git2_XXXXXX"
);
#if defined(_MSC_VER)
/* FIXME: there may be race conditions when multi-threading
* with the library */
if
(
_mktemp_s
(
path_out
,
GIT_PATH_MAX
)
!=
0
)
return
git__throw
(
GIT_EOSERR
,
"Failed to make temporary file %s"
,
path_out
);
if
((
fd
=
p_mkstemp
(
path_out
))
<
0
)
return
git__throw
(
GIT_EOSERR
,
"Failed to create temporary file %s"
,
path_out
);
fd
=
p_creat
(
path_out
,
0744
);
#else
fd
=
mkstemp
(
path_out
);
#endif
return
fd
>=
0
?
fd
:
git__throw
(
GIT_EOSERR
,
"Failed to create temporary file %s"
,
path_out
);
return
fd
;
}
int
git_futils_creat_withpath
(
const
char
*
path
,
int
mode
)
...
...
src/unix/posix.h
View file @
f978b748
...
...
@@ -13,5 +13,6 @@
#define p_fnmatch(p, s, f) fnmatch(p, s, f)
#define p_vsnprintf(b, c, f, a) vsnprintf(b, c, f, a)
#define p_snprintf(b, c, f, ...) snprintf(b, c, f, __VA_ARGS__)
#define p_mkstemp(p) mkstemp(p)
#endif
src/win32/posix.c
View file @
f978b748
#include "posix.h"
#include "path.h"
#include <errno.h>
#include <io.h>
int
p_unlink
(
const
char
*
path
)
{
...
...
@@ -230,3 +231,19 @@ int p_snprintf(char *buffer, size_t count, const char *format, ...)
return
r
;
}
int
p_mkstemp
(
char
*
tmp_path
)
{
int
r
;
#if defined(_MSC_VER)
r
=
_mktemp_s
(
tmp_path
,
GIT_PATH_MAX
);
#else
r
=
_mktemp
(
tmp_path
);
#endif
if
(
r
!=
0
)
return
GIT_EOSERR
;
return
p_creat
(
tmp_path
,
0744
);
}
src/win32/posix.h
View file @
f978b748
...
...
@@ -25,5 +25,6 @@ extern int p_hide_directory__w32(const char *path);
extern
char
*
p_realpath
(
const
char
*
orig_path
,
char
*
buffer
);
extern
int
p_vsnprintf
(
char
*
buffer
,
size_t
count
,
const
char
*
format
,
va_list
argptr
);
extern
int
p_snprintf
(
char
*
buffer
,
size_t
count
,
const
char
*
format
,
...)
GIT_FORMAT_PRINTF
(
3
,
4
);
extern
int
p_mkstemp
(
char
*
tmp_path
);
#endif
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