[llvm] r210712 - Remove unused has_magic.
Rafael Espindola
rafael.espindola at gmail.com
Wed Jun 11 14:53:22 PDT 2014
Author: rafael
Date: Wed Jun 11 16:53:22 2014
New Revision: 210712
URL: http://llvm.org/viewvc/llvm-project?rev=210712&view=rev
Log:
Remove unused has_magic.
This will allow inlining get_magic, which should in turn fix one of the mingw
build problems after the switch to std::error_code.
Modified:
llvm/trunk/include/llvm/Support/FileSystem.h
llvm/trunk/lib/Support/Path.cpp
llvm/trunk/unittests/Support/FileOutputBufferTest.cpp
llvm/trunk/unittests/Support/Path.cpp
Modified: llvm/trunk/include/llvm/Support/FileSystem.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileSystem.h?rev=210712&r1=210711&r2=210712&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileSystem.h (original)
+++ llvm/trunk/include/llvm/Support/FileSystem.h Wed Jun 11 16:53:22 2014
@@ -603,14 +603,6 @@ error_code openFileForWrite(const Twine
error_code openFileForRead(const Twine &Name, int &ResultFD);
-/// @brief Are \a path's first bytes \a magic?
-///
-/// @param path Input path.
-/// @param magic Byte sequence to compare \a path's first len(magic) bytes to.
-/// @returns errc::success if result has been successfully set, otherwise a
-/// platform specific error_code.
-error_code has_magic(const Twine &path, const Twine &magic, bool &result);
-
/// @brief Get \a path's first \a len bytes.
///
/// @param path Input path.
Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=210712&r1=210711&r2=210712&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Wed Jun 11 16:53:22 2014
@@ -890,24 +890,6 @@ void directory_entry::replace_filename(c
Status = st;
}
-error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
- SmallString<32> MagicStorage;
- StringRef Magic = magic.toStringRef(MagicStorage);
- SmallString<32> Buffer;
-
- if (error_code ec = get_magic(path, Magic.size(), Buffer)) {
- if (ec == std::errc::value_too_large) {
- // Magic.size() > file_size(Path).
- result = false;
- return error_code();
- }
- return ec;
- }
-
- result = Magic == Buffer;
- return error_code();
-}
-
/// @brief Identify the magic in magic.
file_magic identify_magic(StringRef Magic) {
if (Magic.size() < 4)
Modified: llvm/trunk/unittests/Support/FileOutputBufferTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/FileOutputBufferTest.cpp?rev=210712&r1=210711&r2=210712&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/FileOutputBufferTest.cpp (original)
+++ llvm/trunk/unittests/Support/FileOutputBufferTest.cpp Wed Jun 11 16:53:22 2014
@@ -46,11 +46,7 @@ TEST(FileOutputBuffer, Test) {
// Commit buffer.
ASSERT_NO_ERROR(Buffer->commit());
}
- // Verify file exists and starts with special header.
- bool MagicMatches = false;
- ASSERT_NO_ERROR(fs::has_magic(Twine(File1), Twine("AABBCCDDEEFFGGHHIIJJ"),
- MagicMatches));
- EXPECT_TRUE(MagicMatches);
+
// Verify file is correct size.
uint64_t File1Size;
ASSERT_NO_ERROR(fs::file_size(Twine(File1), File1Size));
@@ -86,11 +82,7 @@ TEST(FileOutputBuffer, Test) {
// Commit buffer, but size down to smaller size
ASSERT_NO_ERROR(Buffer->commit(5000));
}
- // Verify file exists and starts with special header.
- bool MagicMatches3 = false;
- ASSERT_NO_ERROR(fs::has_magic(Twine(File3), Twine("AABBCCDDEEFFGGHHIIJJ"),
- MagicMatches3));
- EXPECT_TRUE(MagicMatches3);
+
// Verify file is correct size.
uint64_t File3Size;
ASSERT_NO_ERROR(fs::file_size(Twine(File3), File3Size));
Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=210712&r1=210711&r2=210712&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Wed Jun 11 16:53:22 2014
@@ -539,9 +539,6 @@ TEST_F(FileSystemTest, Magic) {
StringRef magic(i->magic_str, i->magic_str_len);
file << magic;
file.close();
- bool res = false;
- ASSERT_NO_ERROR(fs::has_magic(file_pathname.c_str(), magic, res));
- EXPECT_TRUE(res);
EXPECT_EQ(i->magic, fs::identify_magic(magic));
ASSERT_NO_ERROR(fs::remove(Twine(file_pathname)));
}
More information about the llvm-commits
mailing list