1e5dd7070Spatrick //===- DirectoryScanner.h - Utility functions for DirectoryWatcher --------===// 2e5dd7070Spatrick // 3e5dd7070Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4e5dd7070Spatrick // See https://llvm.org/LICENSE.txt for license information. 5e5dd7070Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e5dd7070Spatrick // 7e5dd7070Spatrick //===----------------------------------------------------------------------===// 8e5dd7070Spatrick 9e5dd7070Spatrick #include "clang/DirectoryWatcher/DirectoryWatcher.h" 10e5dd7070Spatrick #include "llvm/Support/FileSystem.h" 11*12c85518Srobert #include <optional> 12e5dd7070Spatrick #include <string> 13e5dd7070Spatrick #include <vector> 14e5dd7070Spatrick 15e5dd7070Spatrick namespace clang { 16e5dd7070Spatrick 17e5dd7070Spatrick /// Gets names (filenames) of items in directory at \p Path. 18e5dd7070Spatrick /// \returns empty vector if \p Path is not a directory, doesn't exist or can't 19e5dd7070Spatrick /// be read from. 20e5dd7070Spatrick std::vector<std::string> scanDirectory(llvm::StringRef Path); 21e5dd7070Spatrick 22e5dd7070Spatrick /// Create event with EventKind::Added for every element in \p Scan. 23e5dd7070Spatrick std::vector<DirectoryWatcher::Event> 24e5dd7070Spatrick getAsFileEvents(const std::vector<std::string> &Scan); 25e5dd7070Spatrick 26e5dd7070Spatrick /// Gets status of file (or directory) at \p Path. 27*12c85518Srobert /// \returns std::nullopt if \p Path doesn't exist or can't get the status. 28*12c85518Srobert std::optional<llvm::sys::fs::file_status> getFileStatus(llvm::StringRef Path); 29e5dd7070Spatrick 30e5dd7070Spatrick } // namespace clang 31