Add BlockFrequency class.
[oota-llvm.git] / include / llvm / Support / FileSystem.h
index 5263d3215328c75833914fa0585d88c3b903624d..4f013f89e86c4db7e7c23665bd28702d80325df5 100644 (file)
@@ -30,6 +30,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/Support/PathV1.h"
 #include "llvm/Support/system_error.h"
 #include <ctime>
 #include <iterator>
@@ -448,19 +449,29 @@ error_code canonicalize(const Twine &path, SmallVectorImpl<char> &result);
 /// @param magic Byte sequence to compare \a path's first len(magic) bytes to.
 /// @results errc::success if result has been successfully set, otherwise a
 ///          platform specific error_code.
-error_code has_magic(const Twine &path, const Twine &magic);
+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.
 /// @param len Number of magic bytes to get.
 /// @param result Set to the first \a len bytes in the file pointed to by
-///               \a path.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
+///               \a path. Or the entire file if file_size(path) < len, in which
+///               case result.size() returns the size of the file.
+/// @results errc::success if result has been successfully set,
+///          errc::value_too_large if len is larger then the file pointed to by
+///          \a path, otherwise a platform specific error_code.
 error_code get_magic(const Twine &path, uint32_t len,
                      SmallVectorImpl<char> &result);
 
+/// @brief Get and identify \a path's type based on its content.
+///
+/// @param path Input path.
+/// @param result Set to the type of file, or LLVMFileType::Unknown_FileType.
+/// @results errc::success if result has been successfully set, otherwise a
+///          platform specific error_code.
+error_code identify_magic(const Twine &path, LLVMFileType &result);
+
 /// @brief Is file bitcode?
 ///
 /// @param path Input path.
@@ -584,7 +595,7 @@ public:
   void replace_filename(const Twine &filename, file_status st = file_status(),
                               file_status symlink_st = file_status());
 
-  StringRef path() const { return Path; }
+  const std::string &path() const { return Path; }
   error_code status(file_status &result) const;
   error_code symlink_status(file_status &result) const;
 
@@ -604,10 +615,10 @@ class directory_iterator {
   directory_entry CurrentEntry;
 
   // Platform implementations implement these functions to handle iteration.
-  friend error_code directory_iterator_construct(directory_iteratorit,
-                                                 const StringRef &path);
-  friend error_code directory_iterator_increment(directory_iteratorit);
-  friend error_code directory_iterator_destruct(directory_iteratorit);
+  friend error_code directory_iterator_construct(directory_iterator &it,
+                                                 StringRef path);
+  friend error_code directory_iterator_increment(directory_iterator &it);
+  friend error_code directory_iterator_destruct(directory_iterator &it);
 
 public:
   explicit directory_iterator(const Twine &path, error_code &ec)