@@ -308,7 +308,8 @@ TEST(TestFilesystemHelper, filesystem_manipulation)
308
308
EXPECT_TRUE (rcpputils::fs::remove (dir));
309
309
EXPECT_FALSE (rcpputils::fs::exists (file));
310
310
EXPECT_FALSE (rcpputils::fs::exists (dir));
311
- auto temp_dir = rcpputils::fs::temp_directory_path ();
311
+ auto temp_dir_std = std::filesystem::temp_directory_path ();
312
+ rcpputils::fs::path temp_dir = rcpputils::fs::path (temp_dir_std.generic_string ());
312
313
temp_dir = temp_dir / " rcpputils" / " test_folder" ;
313
314
EXPECT_FALSE (rcpputils::fs::exists (temp_dir));
314
315
EXPECT_TRUE (rcpputils::fs::create_directories (temp_dir));
@@ -446,13 +447,14 @@ TEST(TestFilesystemHelper, stream_operator)
446
447
ASSERT_EQ (s.str (), " barfoo" );
447
448
}
448
449
449
- TEST (TestFilesystemHelper, create_temp_directory )
450
+ TEST (TestFilesystemHelper, create_temporary_directory )
450
451
{
451
452
// basic usage
452
453
{
453
454
const std::string basename = " test_base_name" ;
454
455
455
- const auto tmpdir1 = rcpputils::fs::create_temp_directory (basename);
456
+ const auto tmpdir1_std = rcpputils::fs::create_temporary_directory (basename);
457
+ rcpputils::fs::path tmpdir1 (tmpdir1_std.generic_string ());
456
458
EXPECT_TRUE (tmpdir1.exists ());
457
459
EXPECT_TRUE (tmpdir1.is_directory ());
458
460
@@ -464,7 +466,8 @@ TEST(TestFilesystemHelper, create_temp_directory)
464
466
EXPECT_TRUE (rcpputils::fs::exists (tmp_file));
465
467
EXPECT_TRUE (rcpputils::fs::is_regular_file (tmp_file));
466
468
467
- const auto tmpdir2 = rcpputils::fs::create_temp_directory (basename);
469
+ const auto tmpdir2_std = rcpputils::fs::create_temporary_directory (basename);
470
+ rcpputils::fs::path tmpdir2 (tmpdir2_std.generic_string ());
468
471
EXPECT_TRUE (tmpdir2.exists ());
469
472
EXPECT_TRUE (tmpdir2.is_directory ());
470
473
@@ -477,16 +480,21 @@ TEST(TestFilesystemHelper, create_temp_directory)
477
480
// bad names
478
481
{
479
482
if (is_win32) {
480
- EXPECT_THROW (rcpputils::fs::create_temp_directory (" illegalchar?" ), std::system_error);
483
+ EXPECT_THROW (rcpputils::fs::create_temporary_directory (" illegalchar?" ), std::system_error);
484
+ EXPECT_THROW (rcpputils::fs::create_temporary_directory (" base\\ name" ), std::invalid_argument);
481
485
} else {
482
- EXPECT_THROW (rcpputils::fs::create_temp_directory (" base/name" ), std::system_error );
486
+ EXPECT_THROW (rcpputils::fs::create_temporary_directory (" base/name" ), std::invalid_argument );
483
487
}
484
488
}
485
489
486
490
// newly created paths
487
491
{
488
492
const auto new_relative = rcpputils::fs::current_path () / " child1" / " child2" ;
489
- const auto tmpdir = rcpputils::fs::create_temp_directory (" base_name" , new_relative);
493
+ const auto tmpdir_std = rcpputils::fs::create_temporary_directory (
494
+ " base_name" ,
495
+ std::filesystem::path (new_relative.string ()));
496
+ rcpputils::fs::path tmpdir (tmpdir_std.generic_string ());
497
+
490
498
EXPECT_TRUE (tmpdir.exists ());
491
499
EXPECT_TRUE (tmpdir.is_directory ());
492
500
EXPECT_TRUE (rcpputils::fs::remove_all (tmpdir));
@@ -495,15 +503,14 @@ TEST(TestFilesystemHelper, create_temp_directory)
495
503
// edge case inputs
496
504
{
497
505
// Provided no base name we should still get a path with the 6 unique template chars
498
- const auto tmpdir_emptybase = rcpputils::fs::create_temp_directory (" " );
506
+ const auto tmpdir_emptybase = rcpputils::fs::create_temporary_directory (" " );
499
507
EXPECT_EQ (tmpdir_emptybase.filename ().string ().size (), 6u );
500
508
501
- // Empty path doesn't exist and cannot be created
502
- EXPECT_THROW (rcpputils::fs::create_temp_directory (" basename" , path ()), std::system_error);
503
-
504
509
// With the template string XXXXXX already in the name, it will still be there, the unique
505
510
// portion is appended to the end.
506
- const auto tmpdir_template_in_name = rcpputils::fs::create_temp_directory (" base_XXXXXX" );
511
+ const auto tmpdir_template_in_name_std =
512
+ rcpputils::fs::create_temporary_directory (" base_XXXXXX" );
513
+ rcpputils::fs::path tmpdir_template_in_name (tmpdir_template_in_name_std.generic_string ());
507
514
EXPECT_TRUE (tmpdir_template_in_name.exists ());
508
515
EXPECT_TRUE (tmpdir_template_in_name.is_directory ());
509
516
// On Linux, it will not replace the base_name Xs, only the final 6 that the function appends.
0 commit comments