Lines Matching refs:fs

241     ASSERT_NO_ERROR(fs::make_absolute(temp_store));  in TEST()
257 sys::fs::make_absolute("/root", Relative); in TEST()
264 sys::fs::make_absolute("//root", Relative); in TEST()
670 fs::createUniqueDirectory("file-system-test", TestDirectory)); in SetUp()
681 void TearDown() override { ASSERT_NO_ERROR(fs::remove(TestDirectory.str())); } in TearDown()
689 fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); in TEST_F()
692 fs::UniqueID F1, F2; in TEST_F()
693 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath), F1)); in TEST_F()
694 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath), F2)); in TEST_F()
701 fs::createTemporaryFile("prefix", "temp", FileDescriptor2, TempPath2)); in TEST_F()
703 fs::UniqueID D; in TEST_F()
704 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath2), D)); in TEST_F()
708 ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); in TEST_F()
712 ASSERT_NO_ERROR(fs::create_link(Twine(TempPath), Twine(TempPath2))); in TEST_F()
713 fs::UniqueID D2; in TEST_F()
714 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath2), D2)); in TEST_F()
721 fs::createUniqueDirectory("dir1", Dir1)); in TEST_F()
722 ASSERT_NO_ERROR(fs::getUniqueID(Dir1.c_str(), F1)); in TEST_F()
723 ASSERT_NO_ERROR(fs::getUniqueID(Dir1.c_str(), F2)); in TEST_F()
728 fs::createUniqueDirectory("dir2", Dir2)); in TEST_F()
729 ASSERT_NO_ERROR(fs::getUniqueID(Dir2.c_str(), F2)); in TEST_F()
731 ASSERT_NO_ERROR(fs::remove(Dir1)); in TEST_F()
732 ASSERT_NO_ERROR(fs::remove(Dir2)); in TEST_F()
733 ASSERT_NO_ERROR(fs::remove(TempPath2)); in TEST_F()
734 ASSERT_NO_ERROR(fs::remove(TempPath)); in TEST_F()
739 fs::create_directories(Twine(TestDirectory) + "/test1/test2/test3")); in TEST_F()
740 ASSERT_TRUE(fs::exists(Twine(TestDirectory) + "/test1/test2/test3")); in TEST_F()
751 ASSERT_NO_ERROR(fs::real_path(TestDirectory, RealBase)); in TEST_F()
755 ASSERT_NO_ERROR(fs::real_path( in TEST_F()
767 ASSERT_NO_ERROR(fs::real_path(HomeDir, Expected)); in TEST_F()
769 ASSERT_NO_ERROR(fs::real_path("~", Actual, true)); in TEST_F()
771 ASSERT_NO_ERROR(fs::real_path("~/", Actual, true)); in TEST_F()
775 ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + "/test1")); in TEST_F()
786 fs::expand_tilde(HomeDir, Expected); in TEST_F()
788 fs::expand_tilde("~", Actual); in TEST_F()
793 fs::expand_tilde("~\\foo", Actual); in TEST_F()
796 fs::expand_tilde("~/foo", Actual); in TEST_F()
808 fs::create_directories(Twine(TestDirectory) + "/noreadperm")); in TEST_F()
809 ASSERT_TRUE(fs::exists(Twine(TestDirectory) + "/noreadperm")); in TEST_F()
811 fs::setPermissions(Twine(TestDirectory) + "/noreadperm", fs::no_perms); in TEST_F()
812 fs::setPermissions(Twine(TestDirectory) + "/noreadperm", fs::all_exe); in TEST_F()
814 ASSERT_NO_ERROR(fs::real_path(Twine(TestDirectory) + "/noreadperm", Expanded, in TEST_F()
817 ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + "/noreadperm")); in TEST_F()
824 auto TempFileOrError = fs::TempFile::create(TestDirectory + "/test-%%%%"); in TEST_F()
826 fs::TempFile File = std::move(*TempFileOrError); in TEST_F()
830 ASSERT_TRUE(fs::exists(TestDirectory + "/keep")); in TEST_F()
831 ASSERT_NO_ERROR(fs::remove(TestDirectory + "/keep")); in TEST_F()
836 auto TempFileOrError = fs::TempFile::create(TestDirectory + "/test-%%%%"); in TEST_F()
838 fs::TempFile File = std::move(*TempFileOrError); in TEST_F()
842 ASSERT_FALSE(fs::exists(TestDirectory + "/keep")); in TEST_F()
850 fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); in TEST_F()
853 ASSERT_TRUE(sys::fs::exists(Twine(TempPath))); in TEST_F()
858 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD2, TempPath2)); in TEST_F()
862 fs::file_status A, B; in TEST_F()
863 ASSERT_NO_ERROR(fs::status(Twine(TempPath), A)); in TEST_F()
864 ASSERT_NO_ERROR(fs::status(Twine(TempPath2), B)); in TEST_F()
865 EXPECT_FALSE(fs::equivalent(A, B)); in TEST_F()
870 ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); in TEST_F()
871 ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); in TEST_F()
872 ASSERT_EQ(fs::remove(Twine(TempPath2), false), in TEST_F()
875 std::error_code EC = fs::status(TempPath2.c_str(), B); in TEST_F()
877 EXPECT_EQ(B.type(), fs::file_type::file_not_found); in TEST_F()
880 ASSERT_EQ(fs::access(Twine(TempPath2), sys::fs::AccessMode::Exist), in TEST_F()
884 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "", TempPath3)); in TEST_F()
889 ASSERT_NO_ERROR(fs::create_link(Twine(TempPath), Twine(TempPath2))); in TEST_F()
891 ASSERT_NO_ERROR(fs::equivalent(Twine(TempPath), Twine(TempPath2), equal)); in TEST_F()
893 ASSERT_NO_ERROR(fs::status(Twine(TempPath), A)); in TEST_F()
894 ASSERT_NO_ERROR(fs::status(Twine(TempPath2), B)); in TEST_F()
895 EXPECT_TRUE(fs::equivalent(A, B)); in TEST_F()
899 ASSERT_NO_ERROR(fs::remove(Twine(TempPath))); in TEST_F()
902 ASSERT_NO_ERROR(fs::remove(Twine(TempPath2))); in TEST_F()
905 ASSERT_EQ(fs::access(Twine(TempPath), sys::fs::AccessMode::Exist), in TEST_F()
916 EXPECT_EQ(fs::createUniqueFile(Path270, FileDescriptor, TempPath), in TEST_F()
924 ASSERT_NO_ERROR(fs::createTemporaryFile(Path216, "", TempPath)); in TEST_F()
925 ASSERT_NO_ERROR(fs::remove(Twine(TempPath))); in TEST_F()
932 fs::createUniqueDirectory("CreateUniqueFileTest", TestDirectory)); in TEST_F()
937 std::vector<fs::TempFile> TempFiles; in TEST_F()
940 Expected<fs::TempFile> T = fs::TempFile::create(Model); in TEST_F()
964 for (fs::TempFile &T : TempFiles) in TEST_F()
969 ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "foo")); in TEST_F()
970 ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "foo")); in TEST_F()
971 ASSERT_EQ(fs::create_directory(Twine(TestDirectory) + "foo", false), in TEST_F()
973 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "foo")); in TEST_F()
979 fs::file_status Status; in TEST_F()
981 fs::create_directory(Twine(TestDirectory) + "baz500", false, in TEST_F()
982 fs::perms::owner_read | fs::perms::owner_exe)); in TEST_F()
983 ASSERT_NO_ERROR(fs::status(Twine(TestDirectory) + "baz500", Status)); in TEST_F()
984 ASSERT_EQ(Status.permissions() & fs::perms::all_all, in TEST_F()
985 fs::perms::owner_read | fs::perms::owner_exe); in TEST_F()
986 ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "baz777", false, in TEST_F()
987 fs::perms::all_all)); in TEST_F()
988 ASSERT_NO_ERROR(fs::status(Twine(TestDirectory) + "baz777", Status)); in TEST_F()
989 ASSERT_EQ(Status.permissions() & fs::perms::all_all, fs::perms::all_all); in TEST_F()
1008 ASSERT_NO_ERROR(fs::create_directories(Twine(LongDir))); in TEST_F()
1009 ASSERT_NO_ERROR(fs::create_directories(Twine(LongDir))); in TEST_F()
1010 ASSERT_EQ(fs::create_directories(Twine(LongDir), false), in TEST_F()
1015 ASSERT_NO_ERROR(fs::remove(ThisDir)); in TEST_F()
1029 ASSERT_NO_ERROR(fs::create_directories(Twine(LongPathWithUnixSeparators))); in TEST_F()
1031 ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + in TEST_F()
1045 ASSERT_NO_ERROR(fs::create_directory(Twine(LongDir))); in TEST_F()
1049 ASSERT_NO_ERROR(fs::create_directory("b")); in TEST_F()
1050 ASSERT_EQ(fs::create_directory(Twine(LongDir), false), errc::file_exists); in TEST_F()
1052 ASSERT_NO_ERROR(fs::remove("b")); in TEST_F()
1053 ASSERT_NO_ERROR(fs::remove( in TEST_F()
1061 for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec)) in TEST_F()
1066 fs::create_directories(Twine(TestDirectory) + "/recursive/a0/aa1")); in TEST_F()
1068 fs::create_directories(Twine(TestDirectory) + "/recursive/a0/ab1")); in TEST_F()
1069 ASSERT_NO_ERROR(fs::create_directories(Twine(TestDirectory) + in TEST_F()
1072 fs::create_directories(Twine(TestDirectory) + "/recursive/z0/za1")); in TEST_F()
1074 fs::create_directories(Twine(TestDirectory) + "/recursive/pop/p1")); in TEST_F()
1077 for (fs::recursive_directory_iterator i(Twine(TestDirectory) in TEST_F()
1116 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0/aa1")); in TEST_F()
1117 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0/ab1")); in TEST_F()
1118 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0")); in TEST_F()
1120 fs::remove(Twine(TestDirectory) + "/recursive/dontlookhere/da1")); in TEST_F()
1121 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/dontlookhere")); in TEST_F()
1122 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/pop/p1")); in TEST_F()
1123 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/pop")); in TEST_F()
1124 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/z0/za1")); in TEST_F()
1125 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/z0")); in TEST_F()
1126 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive")); in TEST_F()
1130 fs::create_directories(Twine(TestDirectory) + "/reclevel/a/b/c")); in TEST_F()
1131 fs::recursive_directory_iterator I(Twine(TestDirectory) + "/reclevel", ec), E; in TEST_F()
1137 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/reclevel/a/b/c")); in TEST_F()
1138 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/reclevel/a/b")); in TEST_F()
1139 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/reclevel/a")); in TEST_F()
1140 ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/reclevel")); in TEST_F()
1144 ASSERT_EQ(fs::access(TestDirectory, sys::fs::AccessMode::Execute), in TEST_F()
1151 ASSERT_NO_ERROR(fs::create_directories(Twine(TestDirectory) + "/symlink")); in TEST_F()
1153 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/a")); in TEST_F()
1155 fs::create_directories(Twine(TestDirectory) + "/symlink/b/bb")); in TEST_F()
1157 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/b/ba")); in TEST_F()
1159 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/b/bc")); in TEST_F()
1161 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/c")); in TEST_F()
1163 fs::create_directories(Twine(TestDirectory) + "/symlink/d/dd/ddd")); in TEST_F()
1164 ASSERT_NO_ERROR(fs::create_link(Twine(TestDirectory) + "/symlink/d/dd", in TEST_F()
1167 fs::create_link("no_such_file", Twine(TestDirectory) + "/symlink/e")); in TEST_F()
1177 for (fs::directory_iterator i(Twine(TestDirectory) + "/symlink", ec), e; in TEST_F()
1194 for (fs::recursive_directory_iterator i( in TEST_F()
1212 for (fs::recursive_directory_iterator i( in TEST_F()
1231 ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + "/symlink")); in TEST_F()
1248 ASSERT_NO_ERROR(fs::create_directories(Twine(RootDir) + "/a")); in TEST_F()
1249 ASSERT_NO_ERROR(fs::create_directories(Twine(RootDir) + "/b")); in TEST_F()
1253 for (fs::directory_iterator I(Twine(RootDir), EC), E; I != E; in TEST_F()
1262 ASSERT_NO_ERROR(fs::remove(Twine(RootDir) + "/a")); in TEST_F()
1263 ASSERT_NO_ERROR(fs::remove(Twine(RootDir) + "/b")); in TEST_F()
1264 ASSERT_NO_ERROR(fs::remove(Twine(RootDir))); in TEST_F()
1272 ASSERT_NO_ERROR(fs::createUniqueDirectory("fs_remove", BaseDir)); in TEST_F()
1274 ASSERT_NO_ERROR(fs::create_directories(Twine(BaseDir) + "/foo/bar/baz")); in TEST_F()
1275 ASSERT_NO_ERROR(fs::create_directories(Twine(BaseDir) + "/foo/bar/buzz")); in TEST_F()
1276 ASSERT_NO_ERROR(fs::createUniqueFile( in TEST_F()
1278 ASSERT_NO_ERROR(fs::createUniqueFile( in TEST_F()
1280 ASSERT_NO_ERROR(fs::createUniqueFile( in TEST_F()
1282 ASSERT_NO_ERROR(fs::createUniqueFile( in TEST_F()
1288 EXPECT_TRUE(fs::exists(Twine(BaseDir) + "/foo/bar/baz")); in TEST_F()
1289 EXPECT_TRUE(fs::exists(Twine(BaseDir) + "/foo/bar/buzz")); in TEST_F()
1290 EXPECT_TRUE(fs::exists(Paths[0])); in TEST_F()
1291 EXPECT_TRUE(fs::exists(Paths[1])); in TEST_F()
1292 EXPECT_TRUE(fs::exists(Paths[2])); in TEST_F()
1293 EXPECT_TRUE(fs::exists(Paths[3])); in TEST_F()
1295 ASSERT_NO_ERROR(fs::remove_directories("D:/footest")); in TEST_F()
1297 ASSERT_NO_ERROR(fs::remove_directories(BaseDir)); in TEST_F()
1298 ASSERT_FALSE(fs::exists(BaseDir)); in TEST_F()
1308 raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF); in TEST_F()
1319 raw_fd_ostream File(FilePathname, EC, sys::fs::OF_None); in TEST_F()
1328 ASSERT_NO_ERROR(fs::remove(Twine(FilePathname))); in TEST_F()
1335 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
1336 ASSERT_NO_ERROR(fs::resize_file(FD, 123)); in TEST_F()
1337 fs::file_status Status; in TEST_F()
1338 ASSERT_NO_ERROR(fs::status(FD, Status)); in TEST_F()
1341 ASSERT_NO_ERROR(fs::remove(TempPath)); in TEST_F()
1348 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
1349 ASSERT_NO_ERROR(fs::resize_file_before_mapping_readwrite(FD, 123)); in TEST_F()
1355 fs::mapped_file_region mfr(fs::convertFDToNativeFile(FD), in TEST_F()
1356 fs::mapped_file_region::readwrite, 123, 0, EC); in TEST_F()
1362 fs::file_status Status; in TEST_F()
1363 ASSERT_NO_ERROR(fs::status(FD, Status)); in TEST_F()
1366 ASSERT_NO_ERROR(fs::remove(TempPath)); in TEST_F()
1372 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
1376 auto Hash = fs::md5_contents(FD); in TEST_F()
1388 fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); in TEST_F()
1391 fs::resize_file_before_mapping_readwrite(FileDescriptor, Size)); in TEST_F()
1396 fs::mapped_file_region MaybeMFR; in TEST_F()
1399 fs::mapped_file_region mfr(fs::convertFDToNativeFile(FileDescriptor), in TEST_F()
1400 fs::mapped_file_region::readwrite, Size, 0, EC); in TEST_F()
1427 EC = fs::openFileForRead(Twine(TempPath), FD); in TEST_F()
1429 fs::mapped_file_region mfr(fs::convertFDToNativeFile(FD), in TEST_F()
1430 fs::mapped_file_region::readonly, Size, 0, EC); in TEST_F()
1437 fs::mapped_file_region m(fs::convertFDToNativeFile(FD), in TEST_F()
1438 fs::mapped_file_region::readonly, Size, 0, EC); in TEST_F()
1442 ASSERT_NO_ERROR(fs::remove(TempPath)); in TEST_F()
1674 fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); in TEST_F()
1678 ASSERT_TRUE(sys::fs::exists(Twine(TempPath))); in TEST_F()
1683 ASSERT_NO_ERROR(fs::openFileForRead(Twine(TempPath), FileDescriptor2, in TEST_F()
1684 fs::OF_None, &ResultPath)) in TEST_F()
1690 fs::UniqueID D1, D2; in TEST_F()
1691 ASSERT_NO_ERROR(fs::getUniqueID(Twine(TempPath), D1)); in TEST_F()
1692 ASSERT_NO_ERROR(fs::getUniqueID(Twine(ResultPath), D2)); in TEST_F()
1706 ASSERT_NO_ERROR(sys::fs::openFileForWrite(Twine(TempPath), FileDescriptor, in TEST_F()
1707 fs::CD_OpenExisting)); in TEST_F()
1709 ASSERT_NO_ERROR(fs::setLastAccessAndModificationTime(FileDescriptor, Epoch)); in TEST_F()
1713 ASSERT_NO_ERROR(fs::openFileForRead(Twine(TempPath), FileDescriptor, in TEST_F()
1714 fs::OF_UpdateAtime, &ResultPath)); in TEST_F()
1716 sys::fs::file_status Status; in TEST_F()
1717 ASSERT_NO_ERROR(sys::fs::status(FileDescriptor, Status)); in TEST_F()
1730 fs::CreationDisposition Disp, StringRef Data) { in createFileWithData()
1732 ASSERT_EQ(ShouldExistBefore, fs::exists(Path)); in createFileWithData()
1733 ASSERT_NO_ERROR(fs::openFileForWrite(Path, FD, Disp)); in createFileWithData()
1735 ASSERT_TRUE(fs::exists(Path)); in createFileWithData()
1752 ASSERT_FALSE(fs::exists(NonExistantFile)); in TEST_F()
1753 ASSERT_NO_ERROR(fs::openFileForWrite(NonExistantFile, FD, fs::CD_CreateNew)); in TEST_F()
1754 ASSERT_TRUE(fs::exists(NonExistantFile)); in TEST_F()
1760 sys::fs::file_status Status; in TEST_F()
1761 ASSERT_NO_ERROR(sys::fs::status(FD, Status)); in TEST_F()
1768 ASSERT_ERROR(fs::openFileForWrite(NonExistantFile, FD, fs::CD_CreateNew)); in TEST_F()
1776 ASSERT_FALSE(fs::exists(NonExistantFile)); in TEST_F()
1778 fs::openFileForWrite(NonExistantFile, FD, fs::CD_CreateAlways)); in TEST_F()
1782 ASSERT_TRUE(fs::exists(NonExistantFile)); in TEST_F()
1788 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1797 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1801 fs::openFileForWrite(NonExistantFile, FD, fs::CD_CreateAlways)); in TEST_F()
1803 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1811 ASSERT_FALSE(fs::exists(NonExistantFile)); in TEST_F()
1812 ASSERT_ERROR(fs::openFileForWrite(NonExistantFile, FD, fs::CD_OpenExisting)); in TEST_F()
1813 ASSERT_FALSE(fs::exists(NonExistantFile)); in TEST_F()
1816 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1819 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1824 createFileWithData(NonExistantFile, true, fs::CD_OpenExisting, "Buzz"); in TEST_F()
1830 createFileWithData(NonExistantFile, false, fs::CD_OpenAlways, "Fizz"); in TEST_F()
1833 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1837 createFileWithData(NonExistantFile, true, fs::CD_OpenAlways, "Bu"); in TEST_F()
1842 fs::CreationDisposition Disps[] = {fs::CD_CreateAlways, fs::CD_OpenAlways, in TEST_F()
1843 fs::CD_OpenExisting}; in TEST_F()
1849 for (fs::CreationDisposition Disp : Disps) { in TEST_F()
1853 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1858 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1861 fs::openFileForWrite(NonExistantFile, FD, Disp, fs::OF_Append)); in TEST_F()
1863 ASSERT_NO_ERROR(sys::fs::file_size(NonExistantFile, FileSize)); in TEST_F()
1897 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1901 ASSERT_NO_ERROR(fs::openFileForRead(NonExistantFile, FD)); in TEST_F()
1909 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1914 fs::openFileForWrite(NonExistantFile, FD, fs::CD_OpenExisting)); in TEST_F()
1921 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "Fizz"); in TEST_F()
1925 ASSERT_NO_ERROR(fs::openFileForReadWrite(NonExistantFile, FD, in TEST_F()
1926 fs::CD_OpenExisting, fs::OF_None)); in TEST_F()
1933 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "01234"); in TEST_F()
1937 Expected<fs::file_t> FD = fs::openNativeFileForRead(NonExistantFile); in TEST_F()
1940 auto Close = make_scope_exit([&] { fs::closeFile(*FD); }); in TEST_F()
1941 if (Expected<size_t> BytesRead = fs::readNativeFile( in TEST_F()
1954 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, Content); in TEST_F()
1958 Expected<fs::file_t> FD = fs::openNativeFileForRead(NonExistantFile); in TEST_F()
1961 auto Close = make_scope_exit([&] { fs::closeFile(*FD); }); in TEST_F()
1963 return fs::readNativeFileToEOF(*FD, V, *ChunkSize); in TEST_F()
1964 return fs::readNativeFileToEOF(*FD, V); in TEST_F()
1970 SmallString<fs::DefaultReadChunkSize + Content.size()> StaysSmall; in TEST_F()
1979 ASSERT_EQ(fs::DefaultReadChunkSize + Content.size(), StaysSmall.capacity()); in TEST_F()
2000 createFileWithData(NonExistantFile, false, fs::CD_CreateNew, "01234"); in TEST_F()
2002 Expected<fs::file_t> FD = fs::openNativeFileForRead(NonExistantFile); in TEST_F()
2004 auto Close = make_scope_exit([&] { fs::closeFile(*FD); }); in TEST_F()
2008 if (Expected<size_t> BytesRead = fs::readNativeFileSlice( in TEST_F()
2024 ASSERT_NO_ERROR(fs::is_local(TestDirectory, TestDirectoryIsLocal)); in TEST_F()
2025 EXPECT_EQ(TestDirectoryIsLocal, fs::is_local(TestDirectory)); in TEST_F()
2030 fs::createUniqueFile(Twine(TestDirectory) + "/temp", FD, TempPath)); in TEST_F()
2034 ASSERT_TRUE(sys::fs::exists(Twine(TempPath))); in TEST_F()
2037 ASSERT_NO_ERROR(fs::is_local(FD, TempFileIsLocal)); in TEST_F()
2038 EXPECT_EQ(TempFileIsLocal, fs::is_local(FD)); in TEST_F()
2048 EXPECT_EQ(fs::getUmask(), 0U) << "Should always be 0 on Windows."; in TEST_F()
2051 unsigned CurrentMask = fs::getUmask(); in TEST_F()
2065 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
2067 fs::perms AllRWE = static_cast<fs::perms>(0777); in TEST_F()
2069 ASSERT_NO_ERROR(fs::setPermissions(TempPath, AllRWE)); in TEST_F()
2071 ErrorOr<fs::perms> Perms = fs::getPermissions(TempPath); in TEST_F()
2075 ASSERT_NO_ERROR(fs::setPermissions(TempPath, AllRWE)); in TEST_F()
2077 Perms = fs::getPermissions(TempPath); in TEST_F()
2082 fs::setPermissions(FD, static_cast<fs::perms>(AllRWE & ~fs::getUmask()))); in TEST_F()
2083 Perms = fs::getPermissions(TempPath); in TEST_F()
2085 EXPECT_EQ(Perms.get(), static_cast<fs::perms>(0755)) in TEST_F()
2091 fs::setPermissions(FD, static_cast<fs::perms>(AllRWE & ~fs::getUmask()))); in TEST_F()
2092 Perms = fs::getPermissions(TempPath); in TEST_F()
2094 EXPECT_EQ(Perms.get(), static_cast<fs::perms>(0720)) in TEST_F()
2105 ASSERT_NO_ERROR(fs::current_path(path)); in TEST_F()
2111 ~RestorePath() { fs::set_current_path(path); } in TEST_F()
2114 ASSERT_NO_ERROR(fs::set_current_path(TestDirectory)); in TEST_F()
2116 ASSERT_NO_ERROR(fs::current_path(path)); in TEST_F()
2118 fs::UniqueID D1, D2; in TEST_F()
2119 ASSERT_NO_ERROR(fs::getUniqueID(TestDirectory, D1)); in TEST_F()
2120 ASSERT_NO_ERROR(fs::getUniqueID(path, D2)); in TEST_F()
2127 ASSERT_NO_ERROR(fs::createTemporaryFile("prefix", "temp", FD, TempPath)); in TEST_F()
2131 ASSERT_TRUE(fs::exists(Twine(TempPath))); in TEST_F()
2133 auto CheckPermissions = [&](fs::perms Expected) { in TEST_F()
2134 ErrorOr<fs::perms> Actual = fs::getPermissions(TempPath); in TEST_F()
2139 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_all), NoError); in TEST_F()
2140 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2142 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read | fs::all_exe), NoError); in TEST_F()
2143 EXPECT_TRUE(CheckPermissions(fs::all_read | fs::all_exe)); in TEST_F()
2146 fs::perms ReadOnly = fs::all_read | fs::all_exe; in TEST_F()
2147 EXPECT_EQ(fs::setPermissions(TempPath, fs::no_perms), NoError); in TEST_F()
2150 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_read), NoError); in TEST_F()
2153 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_write), NoError); in TEST_F()
2154 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2156 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_exe), NoError); in TEST_F()
2159 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_all), NoError); in TEST_F()
2160 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2162 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_read), NoError); in TEST_F()
2165 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_write), NoError); in TEST_F()
2166 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2168 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_exe), NoError); in TEST_F()
2171 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_all), NoError); in TEST_F()
2172 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2174 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_read), NoError); in TEST_F()
2177 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_write), NoError); in TEST_F()
2178 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2180 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_exe), NoError); in TEST_F()
2183 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_all), NoError); in TEST_F()
2184 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2186 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read), NoError); in TEST_F()
2189 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_write), NoError); in TEST_F()
2190 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2192 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_exe), NoError); in TEST_F()
2195 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe), NoError); in TEST_F()
2198 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_gid_on_exe), NoError); in TEST_F()
2201 EXPECT_EQ(fs::setPermissions(TempPath, fs::sticky_bit), NoError); in TEST_F()
2204 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe | in TEST_F()
2205 fs::set_gid_on_exe | in TEST_F()
2206 fs::sticky_bit), in TEST_F()
2210 EXPECT_EQ(fs::setPermissions(TempPath, ReadOnly | fs::set_uid_on_exe | in TEST_F()
2211 fs::set_gid_on_exe | in TEST_F()
2212 fs::sticky_bit), in TEST_F()
2216 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_perms), NoError); in TEST_F()
2217 EXPECT_TRUE(CheckPermissions(fs::all_all)); in TEST_F()
2219 EXPECT_EQ(fs::setPermissions(TempPath, fs::no_perms), NoError); in TEST_F()
2220 EXPECT_TRUE(CheckPermissions(fs::no_perms)); in TEST_F()
2222 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_read), NoError); in TEST_F()
2223 EXPECT_TRUE(CheckPermissions(fs::owner_read)); in TEST_F()
2225 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_write), NoError); in TEST_F()
2226 EXPECT_TRUE(CheckPermissions(fs::owner_write)); in TEST_F()
2228 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_exe), NoError); in TEST_F()
2229 EXPECT_TRUE(CheckPermissions(fs::owner_exe)); in TEST_F()
2231 EXPECT_EQ(fs::setPermissions(TempPath, fs::owner_all), NoError); in TEST_F()
2232 EXPECT_TRUE(CheckPermissions(fs::owner_all)); in TEST_F()
2234 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_read), NoError); in TEST_F()
2235 EXPECT_TRUE(CheckPermissions(fs::group_read)); in TEST_F()
2237 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_write), NoError); in TEST_F()
2238 EXPECT_TRUE(CheckPermissions(fs::group_write)); in TEST_F()
2240 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_exe), NoError); in TEST_F()
2241 EXPECT_TRUE(CheckPermissions(fs::group_exe)); in TEST_F()
2243 EXPECT_EQ(fs::setPermissions(TempPath, fs::group_all), NoError); in TEST_F()
2244 EXPECT_TRUE(CheckPermissions(fs::group_all)); in TEST_F()
2246 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_read), NoError); in TEST_F()
2247 EXPECT_TRUE(CheckPermissions(fs::others_read)); in TEST_F()
2249 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_write), NoError); in TEST_F()
2250 EXPECT_TRUE(CheckPermissions(fs::others_write)); in TEST_F()
2252 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_exe), NoError); in TEST_F()
2253 EXPECT_TRUE(CheckPermissions(fs::others_exe)); in TEST_F()
2255 EXPECT_EQ(fs::setPermissions(TempPath, fs::others_all), NoError); in TEST_F()
2256 EXPECT_TRUE(CheckPermissions(fs::others_all)); in TEST_F()
2258 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read), NoError); in TEST_F()
2259 EXPECT_TRUE(CheckPermissions(fs::all_read)); in TEST_F()
2261 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_write), NoError); in TEST_F()
2262 EXPECT_TRUE(CheckPermissions(fs::all_write)); in TEST_F()
2264 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_exe), NoError); in TEST_F()
2265 EXPECT_TRUE(CheckPermissions(fs::all_exe)); in TEST_F()
2267 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe), NoError); in TEST_F()
2268 EXPECT_TRUE(CheckPermissions(fs::set_uid_on_exe)); in TEST_F()
2270 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_gid_on_exe), NoError); in TEST_F()
2271 EXPECT_TRUE(CheckPermissions(fs::set_gid_on_exe)); in TEST_F()
2278 EXPECT_EQ(fs::setPermissions(TempPath, fs::sticky_bit), NoError); in TEST_F()
2279 EXPECT_TRUE(CheckPermissions(fs::sticky_bit)); in TEST_F()
2281 EXPECT_EQ(fs::setPermissions(TempPath, fs::set_uid_on_exe | in TEST_F()
2282 fs::set_gid_on_exe | in TEST_F()
2283 fs::sticky_bit), in TEST_F()
2285 EXPECT_TRUE(CheckPermissions(fs::set_uid_on_exe | fs::set_gid_on_exe | in TEST_F()
2286 fs::sticky_bit)); in TEST_F()
2288 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read | fs::set_uid_on_exe | in TEST_F()
2289 fs::set_gid_on_exe | in TEST_F()
2290 fs::sticky_bit), in TEST_F()
2292 EXPECT_TRUE(CheckPermissions(fs::all_read | fs::set_uid_on_exe | in TEST_F()
2293 fs::set_gid_on_exe | fs::sticky_bit)); in TEST_F()
2295 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_perms), NoError); in TEST_F()
2296 EXPECT_TRUE(CheckPermissions(fs::all_perms)); in TEST_F()
2299 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_perms & ~fs::sticky_bit), in TEST_F()
2301 EXPECT_TRUE(CheckPermissions(fs::all_perms & ~fs::sticky_bit)); in TEST_F()
2407 EC = fs::createTemporaryFile("test", "temp", FD, TempPath); in TEST_F()
2412 EC = fs::tryLockFile(FD); in TEST_F()
2414 EC = fs::unlockFile(FD); in TEST_F()
2418 ASSERT_ERROR(fs::tryLockFile(FD)); in TEST_F()
2420 ASSERT_NO_ERROR(fs::tryLockFile(FD)); in TEST_F()
2421 ASSERT_NO_ERROR(fs::unlockFile(FD)); in TEST_F()
2427 ASSERT_NO_ERROR(fs::tryLockFile(FD)); in TEST_F()
2428 ASSERT_NO_ERROR(fs::unlockFile(FD)); in TEST_F()
2431 Expected<fs::FileLocker> L1 = Stream.lock(); in TEST_F()
2434 Expected<fs::FileLocker> L2 = Stream2.tryLockFor(250ms); in TEST_F()
2437 Expected<fs::FileLocker> L3 = Stream.tryLockFor(0ms); in TEST_F()
2441 ASSERT_NO_ERROR(fs::tryLockFile(FD)); in TEST_F()
2442 ASSERT_NO_ERROR(fs::unlockFile(FD)); in TEST_F()
2456 fs::CD_CreateNew, Data.back()); in TEST_F()
2462 ASSERT_FALSE(fs::exists(Destination)); in TEST_F()
2463 fs::copy_file(Sources[0], Destination); in TEST_F()
2467 fs::copy_file(Sources[1], Destination); in TEST_F()
2477 ASSERT_NO_ERROR(fs::create_link(path::filename(Sources[2]), Symlink)); in TEST_F()
2482 fs::UniqueID SymlinkID; in TEST_F()
2483 fs::UniqueID Data2ID; in TEST_F()
2484 ASSERT_NO_ERROR(fs::getUniqueID(Symlink, SymlinkID)); in TEST_F()
2485 ASSERT_NO_ERROR(fs::getUniqueID(Sources[2], Data2ID)); in TEST_F()
2489 fs::copy_file(Symlink, Destination); in TEST_F()
2495 ASSERT_NO_ERROR(fs::is_symlink_file(Destination, IsDestinationSymlink)); in TEST_F()
2497 fs::UniqueID DestinationID; in TEST_F()
2498 ASSERT_NO_ERROR(fs::getUniqueID(Destination, DestinationID)); in TEST_F()