Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
1fafc38e
Commit
1fafc38e
authored
Aug 28, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #122 from miloyip/issue114tmpnam
Replace tmpname() by mkstemp() on non-MSVC compilers
parents
e27f7e71
6f4c83ad
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
8 deletions
+12
-8
encodedstreamtest.cpp
test/unittest/encodedstreamtest.cpp
+2
-5
filestreamtest.cpp
test/unittest/filestreamtest.cpp
+1
-2
unittest.h
test/unittest/unittest.h
+9
-1
No files found.
test/unittest/encodedstreamtest.cpp
View file @
1fafc38e
...
...
@@ -158,9 +158,7 @@ protected:
// Test FileWriteStream
{
char
filename
[
L_tmpnam
];
TempFilename
(
filename
);
FILE
*
fp
=
fopen
(
filename
,
"wb"
);
FILE
*
fp
=
TempFile
(
filename
);
char
buffer
[
16
];
FileWriteStream
os
(
fp
,
buffer
,
sizeof
(
buffer
));
EncodedOutputStream
<
FileEncoding
,
FileWriteStream
>
eos
(
os
,
putBOM
);
...
...
@@ -193,9 +191,8 @@ protected:
// Test FileWriteStream
{
char
filename
[
L_tmpnam
];
TempFilenam
e
(
filename
);
FILE
*
fp
=
TempFil
e
(
filename
);
FILE
*
fp
=
fopen
(
filename
,
"wb"
);
char
buffer
[
16
];
FileWriteStream
os
(
fp
,
buffer
,
sizeof
(
buffer
));
AutoUTFOutputStream
<
unsigned
,
FileWriteStream
>
eos
(
os
,
type
,
putBOM
);
...
...
test/unittest/filestreamtest.cpp
View file @
1fafc38e
...
...
@@ -98,9 +98,8 @@ TEST_F(FileStreamTest, FileReadStream) {
TEST_F
(
FileStreamTest
,
FileWriteStream
)
{
char
filename
[
L_tmpnam
];
TempFilenam
e
(
filename
);
FILE
*
fp
=
TempFil
e
(
filename
);
FILE
*
fp
=
fopen
(
filename
,
"wb"
);
char
buffer
[
65536
];
FileWriteStream
os
(
fp
,
buffer
,
sizeof
(
buffer
));
for
(
size_t
i
=
0
;
i
<
length_
;
i
++
)
...
...
test/unittest/unittest.h
View file @
1fafc38e
...
...
@@ -67,13 +67,21 @@ inline Ch* StrDup(const Ch* str) {
return
buffer
;
}
inline
void
TempFilename
(
char
*
filename
)
{
inline
FILE
*
TempFile
(
char
*
filename
)
{
#if _MSC_VER
filename
=
tmpnam
(
filename
);
// For Visual Studio, tmpnam() adds a backslash in front. Remove it.
if
(
filename
[
0
]
==
'\\'
)
for
(
int
i
=
0
;
filename
[
i
]
!=
'\0'
;
i
++
)
filename
[
i
]
=
filename
[
i
+
1
];
return
fopen
(
filename
,
"wb"
);
#else
strcpy
(
filename
,
"/tmp/fileXXXXXX"
);
int
fd
=
mkstemp
(
filename
);
return
fdopen
(
fd
,
"w"
);
#endif
}
// Use exception for catching assert
...
...
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