summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-12 15:07:11 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-12 15:07:11 +0000
commitb703be2544d4bab1d7c86b463eb1518e5e811948 (patch)
tree5ee79a035b2772a4c95eb780acd501b5246a5e79 /llvm
parente3e790a46ecf71521b3115dcfc4c3c0c09e25990 (diff)
downloadbcm5719-llvm-b703be2544d4bab1d7c86b463eb1518e5e811948.tar.gz
bcm5719-llvm-b703be2544d4bab1d7c86b463eb1518e5e811948.zip
Remove Path::getMagicNumber.
llvm-svn: 183839
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Support/PathV1.h8
-rw-r--r--llvm/lib/Support/Unix/Path.inc14
-rw-r--r--llvm/lib/Support/Windows/Path.inc25
3 files changed, 0 insertions, 47 deletions
diff --git a/llvm/include/llvm/Support/PathV1.h b/llvm/include/llvm/Support/PathV1.h
index ceb6e29faf0..916edaadf75 100644
--- a/llvm/include/llvm/Support/PathV1.h
+++ b/llvm/include/llvm/Support/PathV1.h
@@ -219,14 +219,6 @@ namespace sys {
/// @name Disk Accessors
/// @{
public:
- /// This function retrieves the first \p len bytes of the file associated
- /// with \p this. These bytes are returned as the "magic number" in the
- /// \p Magic parameter.
- /// @returns true if the Path is a file and the magic number is retrieved,
- /// false otherwise.
- /// @brief Get the file's magic number.
- bool getMagicNumber(std::string& Magic, unsigned len) const;
-
/// This function determines if the path name in the object references an
/// archive file by looking at its magic number.
/// @returns true if the file starts with the magic number for an archive
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index ecdc2abe3a8..57f02be1094 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -303,20 +303,6 @@ Path Path::GetMainExecutable(const char *argv0, void *MainAddr) {
return Path();
}
-bool Path::getMagicNumber(std::string &Magic, unsigned len) const {
- assert(len < 1024 && "Request for magic string too long");
- char Buf[1025];
- int fd = ::open(path.c_str(), O_RDONLY);
- if (fd < 0)
- return false;
- ssize_t bytes_read = ::read(fd, Buf, len);
- ::close(fd);
- if (ssize_t(len) != bytes_read)
- return false;
- Magic.assign(Buf, len);
- return true;
-}
-
bool
Path::exists() const {
return 0 == access(path.c_str(), F_OK );
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 165c18f0a53..4a6e56350b4 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -590,31 +590,6 @@ Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
}
}
-bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
- assert(len < 1024 && "Request for magic string too long");
- char* buf = reinterpret_cast<char*>(alloca(len));
-
- HANDLE h = CreateFile(path.c_str(),
- GENERIC_READ,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
- if (h == INVALID_HANDLE_VALUE)
- return false;
-
- DWORD nRead = 0;
- BOOL ret = ReadFile(h, buf, len, &nRead, NULL);
- CloseHandle(h);
-
- if (!ret || nRead != len)
- return false;
-
- Magic = std::string(buf, len);
- return true;
-}
-
bool
Path::renamePathOnDisk(const Path& newName, std::string* ErrMsg) {
if (!MoveFileEx(path.c_str(), newName.c_str(), MOVEFILE_REPLACE_EXISTING))
OpenPOWER on IntegriCloud