Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
bdc40b4b
Commit
bdc40b4b
authored
Jan 12, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: Create a temporary directory to store temp files.
parent
52504931
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
13 deletions
+42
-13
tools.h
tools/tools.h
+33
-13
widl.c
tools/widl/widl.c
+3
-0
utils.c
tools/winebuild/utils.c
+2
-0
winegcc.c
tools/winegcc/winegcc.c
+2
-0
wrc.c
tools/wrc/wrc.c
+2
-0
No files found.
tools/tools.h
View file @
bdc40b4b
...
@@ -319,33 +319,53 @@ static inline char *replace_extension( const char *name, const char *old_ext, co
...
@@ -319,33 +319,53 @@ static inline char *replace_extension( const char *name, const char *old_ext, co
return
strmake
(
"%.*s%s"
,
name_len
,
name
,
new_ext
);
return
strmake
(
"%.*s%s"
,
name_len
,
name
,
new_ext
);
}
}
/* temp files management */
static
inline
int
make_temp_file
(
const
char
*
prefix
,
const
char
*
suffix
,
char
**
name
)
extern
const
char
*
temp_dir
;
static
inline
char
*
make_temp_dir
(
void
)
{
{
static
unsigned
int
value
;
unsigned
int
value
=
time
(
NULL
)
+
getpid
();
int
fd
,
count
;
int
count
;
char
*
name
;
const
char
*
tmpdir
=
NULL
;
const
char
*
tmpdir
=
NULL
;
if
(
!
prefix
)
prefix
=
"tmp"
;
if
(
!
suffix
)
suffix
=
""
;
value
+=
time
(
NULL
)
+
getpid
();
for
(
count
=
0
;
count
<
0x8000
;
count
++
)
for
(
count
=
0
;
count
<
0x8000
;
count
++
)
{
{
if
(
tmpdir
)
if
(
tmpdir
)
*
name
=
strmake
(
"%s/%s-%08x%s"
,
tmpdir
,
prefix
,
value
,
suffix
);
name
=
strmake
(
"%s/tmp%08x"
,
tmpdir
,
value
);
else
else
*
name
=
strmake
(
"%s-%08x%s"
,
prefix
,
value
,
suffix
);
name
=
strmake
(
"tmp%08x"
,
value
);
fd
=
open
(
*
name
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
);
if
(
!
mkdir
(
name
,
0700
))
return
name
;
if
(
fd
>=
0
)
return
fd
;
value
+=
7777
;
value
+=
7777
;
if
(
errno
==
EACCES
&&
!
tmpdir
&&
!
strchr
(
prefix
,
'/'
)
)
if
(
errno
==
EACCES
&&
!
tmpdir
)
{
{
if
(
!
(
tmpdir
=
getenv
(
"TMPDIR"
)))
tmpdir
=
"/tmp"
;
if
(
!
(
tmpdir
=
getenv
(
"TMPDIR"
)))
tmpdir
=
"/tmp"
;
}
}
free
(
name
);
}
fprintf
(
stderr
,
"failed to create directory for temp files
\n
"
);
exit
(
1
);
}
static
inline
int
make_temp_file
(
const
char
*
prefix
,
const
char
*
suffix
,
char
**
name
)
{
static
unsigned
int
value
;
int
fd
,
count
;
if
(
!
temp_dir
)
temp_dir
=
make_temp_dir
();
if
(
!
suffix
)
suffix
=
""
;
if
(
!
prefix
)
prefix
=
"tmp"
;
else
prefix
=
get_basename_noext
(
prefix
);
for
(
count
=
0
;
count
<
0x8000
;
count
++
)
{
*
name
=
strmake
(
"%s/%s-%08x%s"
,
temp_dir
,
prefix
,
value
++
,
suffix
);
fd
=
open
(
*
name
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
);
if
(
fd
>=
0
)
return
fd
;
free
(
*
name
);
free
(
*
name
);
}
}
fprintf
(
stderr
,
"failed to create temp file for %s%s
\n
"
,
prefix
,
suffix
);
fprintf
(
stderr
,
"failed to create temp file for %s%s
in %s
\n
"
,
prefix
,
suffix
,
temp_dir
);
exit
(
1
);
exit
(
1
);
}
}
...
...
tools/widl/widl.c
View file @
bdc40b4b
...
@@ -135,6 +135,7 @@ char *regscript_name;
...
@@ -135,6 +135,7 @@ char *regscript_name;
char
*
regscript_token
;
char
*
regscript_token
;
static
char
*
idfile_name
;
static
char
*
idfile_name
;
char
*
temp_name
;
char
*
temp_name
;
const
char
*
temp_dir
=
NULL
;
const
char
*
prefix_client
=
""
;
const
char
*
prefix_client
=
""
;
const
char
*
prefix_server
=
""
;
const
char
*
prefix_server
=
""
;
static
const
char
*
includedir
;
static
const
char
*
includedir
;
...
@@ -931,4 +932,6 @@ static void rm_tempfile(void)
...
@@ -931,4 +932,6 @@ static void rm_tempfile(void)
unlink
(
proxy_name
);
unlink
(
proxy_name
);
if
(
do_typelib
)
if
(
do_typelib
)
unlink
(
typelib_name
);
unlink
(
typelib_name
);
if
(
temp_dir
)
rmdir
(
temp_dir
);
}
}
tools/winebuild/utils.c
View file @
bdc40b4b
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "build.h"
#include "build.h"
const
char
*
temp_dir
=
NULL
;
static
struct
strarray
tmp_files
;
static
struct
strarray
tmp_files
;
static
const
char
*
output_file_source_name
;
static
const
char
*
output_file_source_name
;
...
@@ -37,6 +38,7 @@ void cleanup_tmp_files(void)
...
@@ -37,6 +38,7 @@ void cleanup_tmp_files(void)
{
{
unsigned
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
tmp_files
.
count
;
i
++
)
if
(
tmp_files
.
str
[
i
])
unlink
(
tmp_files
.
str
[
i
]
);
for
(
i
=
0
;
i
<
tmp_files
.
count
;
i
++
)
if
(
tmp_files
.
str
[
i
])
unlink
(
tmp_files
.
str
[
i
]
);
if
(
temp_dir
)
rmdir
(
temp_dir
);
}
}
...
...
tools/winegcc/winegcc.c
View file @
bdc40b4b
...
@@ -147,6 +147,7 @@ static const char *output_file_name;
...
@@ -147,6 +147,7 @@ static const char *output_file_name;
static
const
char
*
output_debug_file
;
static
const
char
*
output_debug_file
;
static
const
char
*
output_implib
;
static
const
char
*
output_implib
;
static
int
keep_generated
=
0
;
static
int
keep_generated
=
0
;
const
char
*
temp_dir
=
NULL
;
static
struct
strarray
tmp_files
;
static
struct
strarray
tmp_files
;
#ifdef HAVE_SIGSET_T
#ifdef HAVE_SIGSET_T
static
sigset_t
signal_mask
;
static
sigset_t
signal_mask
;
...
@@ -222,6 +223,7 @@ static void clean_temp_files(void)
...
@@ -222,6 +223,7 @@ static void clean_temp_files(void)
for
(
i
=
0
;
i
<
tmp_files
.
count
;
i
++
)
for
(
i
=
0
;
i
<
tmp_files
.
count
;
i
++
)
unlink
(
tmp_files
.
str
[
i
]);
unlink
(
tmp_files
.
str
[
i
]);
if
(
temp_dir
)
rmdir
(
temp_dir
);
}
}
/* clean things up when aborting on a signal */
/* clean things up when aborting on a signal */
...
...
tools/wrc/wrc.c
View file @
bdc40b4b
...
@@ -135,6 +135,7 @@ static char *output_name; /* The name given by the -o option */
...
@@ -135,6 +135,7 @@ static char *output_name; /* The name given by the -o option */
const
char
*
input_name
=
NULL
;
/* The name given on the command-line */
const
char
*
input_name
=
NULL
;
/* The name given on the command-line */
static
char
*
temp_name
=
NULL
;
/* Temporary file for preprocess pipe */
static
char
*
temp_name
=
NULL
;
/* Temporary file for preprocess pipe */
static
struct
strarray
input_files
;
static
struct
strarray
input_files
;
const
char
*
temp_dir
=
NULL
;
static
int
stdinc
=
1
;
static
int
stdinc
=
1
;
static
int
po_mode
;
static
int
po_mode
;
...
@@ -519,4 +520,5 @@ static void cleanup_files(void)
...
@@ -519,4 +520,5 @@ static void cleanup_files(void)
{
{
if
(
output_name
)
unlink
(
output_name
);
if
(
output_name
)
unlink
(
output_name
);
if
(
temp_name
)
unlink
(
temp_name
);
if
(
temp_name
)
unlink
(
temp_name
);
if
(
temp_dir
)
rmdir
(
temp_dir
);
}
}
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