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
Nils Gladitz
CMake
Commits
7f890539
Commit
7f890539
authored
Apr 15, 2021
by
Brad King
💬
Browse files
cmSystemTools: Return KWSys Status from CreateLink and CreateSymlink
parent
27b5dc35
Changes
3
Hide whitespace changes
Inline
Side-by-side
Source/cmFileCommand.cxx
View file @
7f890539
...
...
@@ -2949,9 +2949,11 @@ bool HandleCreateLinkCommand(std::vector<std::string> const& args,
// Check if the command requires a symbolic link.
if
(
arguments
.
Symbolic
)
{
completed
=
cmSystemTools
::
CreateSymlink
(
fileName
,
newFileName
,
&
result
);
completed
=
static_cast
<
bool
>
(
cmSystemTools
::
CreateSymlink
(
fileName
,
newFileName
,
&
result
));
}
else
{
completed
=
cmSystemTools
::
CreateLink
(
fileName
,
newFileName
,
&
result
);
completed
=
static_cast
<
bool
>
(
cmSystemTools
::
CreateLink
(
fileName
,
newFileName
,
&
result
));
}
// Check if copy-on-error is enabled in the arguments.
...
...
Source/cmSystemTools.cxx
View file @
7f890539
...
...
@@ -3158,9 +3158,9 @@ std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes)
return
out
;
}
bool
cmSystemTools
::
CreateSymlink
(
const
std
::
string
&
origName
,
const
std
::
string
&
newName
,
std
::
string
*
errorMessage
)
cmsys
::
Status
cmSystemTools
::
CreateSymlink
(
std
::
string
const
&
origName
,
std
::
string
const
&
newName
,
std
::
string
*
errorMessage
)
{
uv_fs_t
req
;
int
flags
=
0
;
...
...
@@ -3171,7 +3171,9 @@ bool cmSystemTools::CreateSymlink(const std::string& origName,
#endif
int
err
=
uv_fs_symlink
(
nullptr
,
&
req
,
origName
.
c_str
(),
newName
.
c_str
(),
flags
,
nullptr
);
cmsys
::
Status
status
;
if
(
err
)
{
status
=
cmsys
::
Status
::
POSIX
(
-
err
);
std
::
string
e
=
"failed to create symbolic link '"
+
newName
+
"': "
+
uv_strerror
(
err
);
if
(
errorMessage
)
{
...
...
@@ -3179,20 +3181,20 @@ bool cmSystemTools::CreateSymlink(const std::string& origName,
}
else
{
cmSystemTools
::
Error
(
e
);
}
return
false
;
}
return
true
;
return
status
;
}
bool
cmSystemTools
::
CreateLink
(
const
std
::
string
&
origName
,
const
std
::
string
&
newName
,
std
::
string
*
errorMessage
)
cmsys
::
Status
cmSystemTools
::
CreateLink
(
std
::
string
const
&
origName
,
std
::
string
const
&
newName
,
std
::
string
*
errorMessage
)
{
uv_fs_t
req
;
int
err
=
uv_fs_link
(
nullptr
,
&
req
,
origName
.
c_str
(),
newName
.
c_str
(),
nullptr
);
cmsys
::
Status
status
;
if
(
err
)
{
status
=
cmsys
::
Status
::
POSIX
(
-
err
);
std
::
string
e
=
"failed to create link '"
+
newName
+
"': "
+
uv_strerror
(
err
);
if
(
errorMessage
)
{
...
...
@@ -3200,10 +3202,8 @@ bool cmSystemTools::CreateLink(const std::string& origName,
}
else
{
cmSystemTools
::
Error
(
e
);
}
return
false
;
}
return
true
;
return
status
;
}
cm
::
string_view
cmSystemTools
::
GetSystemName
()
...
...
Source/cmSystemTools.h
View file @
7f890539
...
...
@@ -489,15 +489,15 @@ public:
/** Create a symbolic link if the platform supports it. Returns whether
creation succeeded. */
static
bool
CreateSymlink
(
const
std
::
string
&
origName
,
const
std
::
string
&
newName
,
std
::
string
*
errorMessage
=
nullptr
);
static
cmsys
::
Status
CreateSymlink
(
std
::
string
const
&
origName
,
std
::
string
const
&
newName
,
std
::
string
*
errorMessage
=
nullptr
);
/** Create a hard link if the platform supports it. Returns whether
creation succeeded. */
static
bool
CreateLink
(
const
std
::
string
&
origName
,
const
std
::
string
&
newName
,
std
::
string
*
errorMessage
=
nullptr
);
static
cmsys
::
Status
CreateLink
(
std
::
string
const
&
origName
,
std
::
string
const
&
newName
,
std
::
string
*
errorMessage
=
nullptr
);
/** Get the system name. */
static
cm
::
string_view
GetSystemName
();
...
...
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