Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
fdc844ec
Commit
fdc844ec
authored
Dec 28, 2005
by
Andy Cedilnik
Browse files
ENH: Add method to create tar
parent
ba63b6f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Source/cmSystemTools.cxx
View file @
fdc844ec
...
...
@@ -1358,3 +1358,59 @@ bool cmSystemTools::IsPathToFramework(const char* path)
}
return
false
;
}
#include <libtar/libtar.h>
#include <memory> // auto_ptr
bool
cmSystemTools
::
CreateTar
(
const
char
*
outFileName
,
const
std
::
vector
<
cmStdString
>&
files
)
{
TAR
*
t
;
char
buf
[
TAR_MAXPATHLEN
];
char
pathname
[
TAR_MAXPATHLEN
];
// Ok, this libtar is not const safe. for now use auto_ptr hack
char
*
realName
=
new
char
[
strlen
(
outFileName
)
+
1
];
std
::
auto_ptr
<
char
>
realNamePtr
(
realName
);
strcpy
(
realName
,
outFileName
);
if
(
tar_open
(
&
t
,
realName
,
NULL
,
O_WRONLY
|
O_CREAT
,
0644
,
TAR_VERBOSE
|
0
)
==
-
1
)
{
fprintf
(
stderr
,
"tar_open(): %s
\n
"
,
strerror
(
errno
));
return
-
1
;
}
std
::
vector
<
cmStdString
>::
const_iterator
it
;
for
(
it
=
files
.
begin
();
it
!=
files
.
end
();
++
it
)
{
strncpy
(
pathname
,
it
->
c_str
(),
sizeof
(
pathname
));
pathname
[
sizeof
(
pathname
)
-
1
]
=
0
;
strncpy
(
buf
,
pathname
,
sizeof
(
buf
));
buf
[
sizeof
(
buf
)
-
1
]
=
0
;
if
(
tar_append_tree
(
t
,
buf
,
pathname
)
!=
0
)
{
fprintf
(
stderr
,
"tar_append_tree(
\"
%s
\"
,
\"
%s
\"
): %s
\n
"
,
buf
,
pathname
,
strerror
(
errno
));
tar_close
(
t
);
return
-
1
;
}
}
if
(
tar_append_eof
(
t
)
!=
0
)
{
fprintf
(
stderr
,
"tar_append_eof(): %s
\n
"
,
strerror
(
errno
));
tar_close
(
t
);
return
-
1
;
}
if
(
tar_close
(
t
)
!=
0
)
{
fprintf
(
stderr
,
"tar_close(): %s
\n
"
,
strerror
(
errno
));
return
-
1
;
}
std
::
cout
<<
"CreateTar: "
<<
outFileName
<<
std
::
endl
;
return
false
;
}
Source/cmSystemTools.h
View file @
fdc844ec
...
...
@@ -297,6 +297,8 @@ public:
of the form var=value */
static
bool
PutEnv
(
const
char
*
value
);
/** Create tar */
static
bool
CreateTar
(
const
char
*
outFileName
,
const
std
::
vector
<
cmStdString
>&
files
);
private:
static
bool
s_ForceUnixPaths
;
static
bool
s_RunCommandHideConsole
;
...
...
Write
Preview
Supports
Markdown
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