mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Ensure that native path separators are always used in symlink targets on Windows
This commit is contained in:
parent
a67828b9ba
commit
226f040e25
@ -53,13 +53,17 @@ void solidity::test::createFileWithContent(boost::filesystem::path const& _path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool solidity::test::createSymlinkIfSupportedByFilesystem(
|
bool solidity::test::createSymlinkIfSupportedByFilesystem(
|
||||||
boost::filesystem::path const& _targetPath,
|
boost::filesystem::path _targetPath,
|
||||||
boost::filesystem::path const& _linkName,
|
boost::filesystem::path const& _linkName,
|
||||||
bool _directorySymlink
|
bool _directorySymlink
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
boost::system::error_code symlinkCreationError;
|
boost::system::error_code symlinkCreationError;
|
||||||
|
|
||||||
|
// NOTE: On Windows / works as a separator in a symlink target only if the target is absolute.
|
||||||
|
// Convert path separators to native ones to avoid this problem.
|
||||||
|
_targetPath.make_preferred();
|
||||||
|
|
||||||
if (_directorySymlink)
|
if (_directorySymlink)
|
||||||
boost::filesystem::create_directory_symlink(_targetPath, _linkName, symlinkCreationError);
|
boost::filesystem::create_directory_symlink(_targetPath, _linkName, symlinkCreationError);
|
||||||
else
|
else
|
||||||
|
@ -46,7 +46,7 @@ void createFileWithContent(boost::filesystem::path const& _path, std::string con
|
|||||||
/// support symlinks.
|
/// support symlinks.
|
||||||
/// Throws an exception of the operation fails for a different reason.
|
/// Throws an exception of the operation fails for a different reason.
|
||||||
bool createSymlinkIfSupportedByFilesystem(
|
bool createSymlinkIfSupportedByFilesystem(
|
||||||
boost::filesystem::path const& _targetPath,
|
boost::filesystem::path _targetPath,
|
||||||
boost::filesystem::path const& _linkName,
|
boost::filesystem::path const& _linkName,
|
||||||
bool _directorySymlink
|
bool _directorySymlink
|
||||||
);
|
);
|
||||||
|
@ -786,12 +786,7 @@ BOOST_AUTO_TEST_CASE(cli_paths_to_source_unit_names_symlinks)
|
|||||||
TemporaryWorkingDirectory tempWorkDir(tempDir.path() / "r");
|
TemporaryWorkingDirectory tempWorkDir(tempDir.path() / "r");
|
||||||
|
|
||||||
if (
|
if (
|
||||||
#if !defined(_WIN32)
|
|
||||||
!createSymlinkIfSupportedByFilesystem("../x/y", tempDir.path() / "r/sym", true) ||
|
!createSymlinkIfSupportedByFilesystem("../x/y", tempDir.path() / "r/sym", true) ||
|
||||||
#else
|
|
||||||
// NOTE: On Windows / works as a separator in a symlink target only if the target is absolute
|
|
||||||
!createSymlinkIfSupportedByFilesystem("..\\x\\y", tempDir.path() / "r/sym", true) ||
|
|
||||||
#endif
|
|
||||||
!createSymlinkIfSupportedByFilesystem("contract.sol", tempDir.path() / "x/y/z/contract_symlink.sol", false)
|
!createSymlinkIfSupportedByFilesystem("contract.sol", tempDir.path() / "x/y/z/contract_symlink.sol", false)
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user