[llvm] [readtapi] Add support for stubify-ing directories (PR #76885)

Juergen Ributzka via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 11:32:29 PST 2024


================
@@ -21,14 +21,65 @@
 #define PATH_MAX 1024
 #endif
 
+#define MACCATALYST_PREFIX_PATH "/System/iOSSupport"
+#define DRIVERKIT_PREFIX_PATH "/System/DriverKit"
+
 namespace llvm::MachO {
 
 using PathSeq = std::vector<std::string>;
 
+// Defines simple struct for storing symbolic links.
+struct SymLink {
+  std::string SrcPath;
+  std::string LinkContent;
+
+  SymLink(std::string Path, std::string Link)
+      : SrcPath(std::move(Path)), LinkContent(std::move(Link)) {}
+
+  SymLink(StringRef Path, StringRef Link)
+      : SrcPath(std::string(Path)), LinkContent(std::string(Link)) {}
+};
+
 /// Replace extension considering frameworks.
 ///
 /// \param Path Location of file.
 /// \param Extension File extension to update with.
 void replace_extension(SmallVectorImpl<char> &Path, const Twine &Extension);
+
+/// Determine whether to skip over symlink due to either too many symlink levels
+/// or is cyclic.
+///
+/// \param Path Location to symlink.
+/// \param Result Holds whether to skip over Path.
+std::error_code shouldSkipSymLink(const Twine &Path, bool &Result);
+
+/// Get what the symlink points to.
+/// This is a no-op on windows as it references POSIX level apis.
+///
+/// \param Path The symlink.
+/// \param LinkPath Holds what the symlink points to.
+std::error_code read_link(const Twine &Path, SmallVectorImpl<char> &LinkPath);
----------------
ributzka wrote:

I think this should go into Support/FileSystem.h. There is already an API to create a symlink there.

https://github.com/llvm/llvm-project/pull/76885


More information about the llvm-commits mailing list