martinzink commented on code in PR #1424:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1424#discussion_r1044587720
##########
libminifi/test/unit/FileStreamTests.cpp:
##########
@@ -301,32 +267,25 @@ TEST_CASE("Existing file read/write test") {
stream.seek(0);
}
-#if !defined(WIN32) || defined(USE_BOOST)
-// This could be simplified with C++17 std::filesystem
TEST_CASE("Opening file without permission creates error logs") {
TestController test_controller;
auto dir = test_controller.createTempDirectory();
- std::string path_to_permissionless_file(utils::file::concat_path(dir,
"permissionless_file.txt"));
+ auto path_to_permissionless_file = dir / "permissionless_file.txt";
{
std::ofstream outfile(path_to_permissionless_file);
outfile << "this file has been just created" << std::endl;
outfile.close();
-#ifndef WIN32
utils::file::FileUtils::set_permissions(path_to_permissionless_file, 0);
-#else
- boost::filesystem::permissions(path_to_permissionless_file,
boost::filesystem::no_perms);
-#endif
}
- minifi::io::FileStream stream(path_to_permissionless_file, 0, false);
+ minifi::io::FileStream stream(path_to_permissionless_file, 0, true);
Review Comment:
It never worked on windows (with boost enabled), this is due to the fact
that the test and (iirc filesystem::permissions aswell) only sets the old
windows permissions (which doesnt have the concept of an unreadable file) so
setting a file to permission 0000 only sets the read-only flag on windows.
So for the FileStream to fail due to permission issues we must try to write
to it on windows.
Maybe we could test the newer ACL permission model on windows aswell, but to
be honest I am not sure if that worth the effort.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]