Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
gflags
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
gflags
Commits
a0dca4df
Commit
a0dca4df
authored
Mar 17, 2014
by
Andreas Schuh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create temporary directory for unit tests in specified --test_tmpdir if possible.
parent
eeb4db32
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
4 deletions
+17
-4
util.h
src/util.h
+17
-4
No files found.
src/util.h
View file @
a0dca4df
...
@@ -237,23 +237,36 @@ class Test {};
...
@@ -237,23 +237,36 @@ class Test {};
#if defined(__MINGW32__)
#if defined(__MINGW32__)
#include <io.h>
#include <io.h>
inline
void
MakeTmpdir
(
std
::
string
*
path
)
{
inline
void
MakeTmpdir
(
std
::
string
*
path
)
{
if
(
!
path
->
empty
())
{
path
->
append
(
"/gflags_unittest_testdir"
);
int
err
=
mkdir
(
path
->
c_str
());
if
(
err
==
0
||
errno
==
EEXIST
)
return
;
}
// I had trouble creating a directory in /tmp from mingw
// I had trouble creating a directory in /tmp from mingw
*
path
=
"./gflags_unittest
_testdir
"
;
*
path
=
"./gflags_unittest"
;
mkdir
(
path
->
c_str
());
// mingw has a weird one-arg mkdir
mkdir
(
path
->
c_str
());
}
}
#elif defined(_MSC_VER)
#elif defined(_MSC_VER)
#include <direct.h>
#include <direct.h>
inline
void
MakeTmpdir
(
std
::
string
*
path
)
{
inline
void
MakeTmpdir
(
std
::
string
*
path
)
{
if
(
!
path
->
empty
())
{
int
err
=
_mkdir
(
path
->
c_str
());
if
(
err
==
0
||
errno
==
EEXIST
)
return
;
}
char
tmppath_buffer
[
1024
];
char
tmppath_buffer
[
1024
];
int
tmppath_len
=
GetTempPathA
(
sizeof
(
tmppath_buffer
),
tmppath_buffer
);
int
tmppath_len
=
GetTempPathA
(
sizeof
(
tmppath_buffer
),
tmppath_buffer
);
assert
(
tmppath_len
>
0
&&
tmppath_len
<
sizeof
(
tmppath_buffer
));
assert
(
tmppath_len
>
0
&&
tmppath_len
<
sizeof
(
tmppath_buffer
));
assert
(
tmppath_buffer
[
tmppath_len
-
1
]
==
'\\'
);
// API guarantees it
assert
(
tmppath_buffer
[
tmppath_len
-
1
]
==
'\\'
);
// API guarantees it
*
path
=
std
::
string
(
tmppath_buffer
)
+
"gflags_unittest
_testdir
"
;
*
path
=
std
::
string
(
tmppath_buffer
)
+
"gflags_unittest"
;
_mkdir
(
path
->
c_str
());
_mkdir
(
path
->
c_str
());
}
}
#else
#else
inline
void
MakeTmpdir
(
std
::
string
*
path
)
{
inline
void
MakeTmpdir
(
std
::
string
*
path
)
{
mkdir
(
path
->
c_str
(),
0755
);
if
(
!
path
->
empty
())
{
int
err
=
mkdir
(
path
->
c_str
(),
0755
);
if
(
err
==
0
||
errno
==
EEXIST
)
return
;
}
mkdir
(
"/tmp/gflags_unittest"
,
0755
);
}
}
#endif
#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