[Lldb-commits] [PATCH] D54135: Add convenience method in FileSystem to check if a path/filespec is a directory.
This revision was automatically updated to reflect the committed changes. Closed by commit rL346375: [FileSystem] Add convenience method to check for directories. (authored by JDevlieghere, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D54135?vs=172703=173075#toc Repository: rL LLVM https://reviews.llvm.org/D54135 Files: lldb/trunk/include/lldb/Host/FileSystem.h lldb/trunk/source/API/SBPlatform.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Host/common/FileSystem.cpp lldb/trunk/source/Host/common/Symbols.cpp lldb/trunk/source/Host/macosx/Symbols.cpp lldb/trunk/source/Host/macosx/objcxx/Host.mm lldb/trunk/source/Host/macosx/objcxx/HostInfoMacOSX.mm lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangHost.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp lldb/trunk/source/Target/TargetList.cpp Index: lldb/trunk/source/Host/macosx/objcxx/Host.mm === --- lldb/trunk/source/Host/macosx/objcxx/Host.mm +++ lldb/trunk/source/Host/macosx/objcxx/Host.mm @@ -101,7 +101,7 @@ bool Host::GetBundleDirectory(const FileSpec , FileSpec _directory) { #if defined(__APPLE__) - if (llvm::sys::fs::is_directory(file.GetPath())) { + if (FileSystem::Instance().IsDirectory(file)) { char path[PATH_MAX]; if (file.GetPath(path, sizeof(path))) { CFCBundle bundle(path); @@ -118,7 +118,7 @@ bool Host::ResolveExecutableInBundle(FileSpec ) { #if defined(__APPLE__) - if (llvm::sys::fs::is_directory(file.GetPath())) { + if (FileSystem::Instance().IsDirectory(file)) { char path[PATH_MAX]; if (file.GetPath(path, sizeof(path))) { CFCBundle bundle(path); Index: lldb/trunk/source/Host/macosx/objcxx/HostInfoMacOSX.mm === --- lldb/trunk/source/Host/macosx/objcxx/HostInfoMacOSX.mm +++ lldb/trunk/source/Host/macosx/objcxx/HostInfoMacOSX.mm @@ -141,7 +141,7 @@ raw_path.append("/../bin"); FileSpec support_dir_spec(raw_path); FileSystem::Instance().Resolve(support_dir_spec); -if (!llvm::sys::fs::is_directory(support_dir_spec.GetPath())) { +if (!FileSystem::Instance().IsDirectory(support_dir_spec)) { Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); if (log) log->Printf("HostInfoMacOSX::%s(): failed to find support directory", Index: lldb/trunk/source/Host/macosx/Symbols.cpp === --- lldb/trunk/source/Host/macosx/Symbols.cpp +++ lldb/trunk/source/Host/macosx/Symbols.cpp @@ -109,7 +109,7 @@ if (path[0] == '~') FileSystem::Instance().Resolve(dsym_filespec); -if (llvm::sys::fs::is_directory(dsym_filespec.GetPath())) { +if (FileSystem::Instance().IsDirectory(dsym_filespec)) { dsym_filespec = Symbols::FindSymbolFileInBundle(dsym_filespec, uuid, arch); ++items_found; Index: lldb/trunk/source/Host/common/Symbols.cpp === --- lldb/trunk/source/Host/common/Symbols.cpp +++ lldb/trunk/source/Host/common/Symbols.cpp @@ -311,7 +311,7 @@ for (size_t idx = 0; idx < num_directories; ++idx) { FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx); FileSystem::Instance().Resolve(dirspec); - if (!llvm::sys::fs::is_directory(dirspec.GetPath())) + if (!FileSystem::Instance().IsDirectory(dirspec)) continue; std::vector files; Index: lldb/trunk/source/Host/common/FileSystem.cpp === --- lldb/trunk/source/Host/common/FileSystem.cpp +++ lldb/trunk/source/Host/common/FileSystem.cpp @@ -124,6 +124,17 @@ return Readable(file_spec.GetPath()); } +bool FileSystem::IsDirectory(const Twine ) const { + ErrorOr status = m_fs->status(path); + if (!status) +return false; + return status->isDirectory(); +} + +bool FileSystem::IsDirectory(const FileSpec _spec) const { + return IsDirectory(file_spec.GetPath()); +} + void FileSystem::EnumerateDirectory(Twine path, bool find_directories, bool find_files, bool find_other, EnumerateDirectoryCallbackType callback, Index: lldb/trunk/source/API/SBPlatform.cpp === ---
[Lldb-commits] [PATCH] D54135: Add convenience method in FileSystem to check if a path/filespec is a directory.
JDevlieghere added a comment. In https://reviews.llvm.org/D54135#1288254, @krytarowski wrote: > Why? We already put a lot of effort into reusing code from LLVM. This is still using code from LLVM, the `FileSystem` class is just an abstraction in between: 1. It uses LLVM's virtual file system. The VFS is stateful and the FileSystem class maintains this state. If you don't specify a virtual file system it uses the "real" file system (the default). 2. It has convenience methods for FileSpecs, so that you don't have to convert them at every call site. These functions used to be methods in the FileSpec class, something we wanted to get rid of for a while because conceptually the latter is just a "smart path". I started doing all this work to support reproducers in LLDB. We'll need a bunch of files that won't live at their original location and the VFS makes it possible to deal with that transparently. Repository: rLLDB LLDB https://reviews.llvm.org/D54135 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54135: Add convenience method in FileSystem to check if a path/filespec is a directory.
krytarowski added a comment. Why? We already put a lot of effort into reusing code from LLVM. Repository: rLLDB LLDB https://reviews.llvm.org/D54135 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D54135: Add convenience method in FileSystem to check if a path/filespec is a directory.
JDevlieghere created this revision. JDevlieghere added reviewers: labath, davide. JDevlieghere added a project: LLDB. Herald added subscribers: teemperor, emaste. Replace calls to LLVM's is_directory with calls to LLDB's FileSytem class. For this I introduced a new convenience method that, like the other methods, takes either a path or filespec. Repository: rLLDB LLDB https://reviews.llvm.org/D54135 Files: include/lldb/Host/FileSystem.h source/API/SBPlatform.cpp source/Core/Module.cpp source/Core/ModuleList.cpp source/Host/common/FileSystem.cpp source/Host/common/Symbols.cpp source/Host/macosx/Symbols.cpp source/Host/macosx/objcxx/Host.mm source/Host/macosx/objcxx/HostInfoMacOSX.mm source/Plugins/ExpressionParser/Clang/ClangHost.cpp source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp source/Plugins/Process/Darwin/NativeProcessDarwin.cpp source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp source/Plugins/Process/Windows/Common/ProcessWindows.cpp source/Target/TargetList.cpp Index: source/Target/TargetList.cpp === --- source/Target/TargetList.cpp +++ source/Target/TargetList.cpp @@ -364,7 +364,7 @@ char resolved_bundle_exe_path[PATH_MAX]; resolved_bundle_exe_path[0] = '\0'; if (file) { -if (llvm::sys::fs::is_directory(file.GetPath())) +if (FileSystem::Instance().IsDirectory(file)) user_exe_path_is_bundle = true; if (file.IsRelative() && !user_exe_path.empty()) { Index: source/Plugins/Process/Windows/Common/ProcessWindows.cpp === --- source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -254,7 +254,7 @@ namespace fs = llvm::sys::fs; if (working_dir) { FileSystem::Instance().Resolve(working_dir); -if (!fs::is_directory(working_dir.GetPath())) { +if (!FileSystem::Instance().IsDirectory(working_dir)) { result.SetErrorStringWithFormat("No such file or directory: %s", working_dir.GetCString()); return result; Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp === --- source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -374,10 +374,9 @@ assert(m_monitor == NULL); FileSpec working_dir = launch_info.GetWorkingDirectory(); - namespace fs = llvm::sys::fs; if (working_dir) { FileSystem::Instance().Resolve(working_dir); -if (!fs::is_directory(working_dir.GetPath())) { +if (!FileSystem::Instance().IsDirectory(working_dir.GetPath())) { error.SetErrorStringWithFormat("No such file or directory: %s", working_dir.GetCString()); return error; Index: source/Plugins/Process/Darwin/NativeProcessDarwin.cpp === --- source/Plugins/Process/Darwin/NativeProcessDarwin.cpp +++ source/Plugins/Process/Darwin/NativeProcessDarwin.cpp @@ -65,7 +65,7 @@ FileSpec working_dir(launch_info.GetWorkingDirectory()); if (working_dir) { FileInstance::Instance().Resolve(working_dir); -if (!llvm::sys::fs::is_directory(working_dir.GetPath())) { +if (!FileSystem::Instance().IsDirectory(working_dir)) { error.SetErrorStringWithFormat("No such file or directory: %s", working_dir.GetCString()); return error; Index: source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp === --- source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -379,7 +379,7 @@ // Add simple directory /Applications/Xcode.app/Contents/Developer/../Symbols FileSpec possible_dir(developer_dir + "/../Symbols"); FileSystem::Instance().Resolve(possible_dir); - if (llvm::sys::fs::is_directory(possible_dir.GetPath())) + if (FileSystem::Instance().IsDirectory(possible_dir)) m_search_directories.push_back(possible_dir); // Add simple directory of the current working directory @@ -396,7 +396,7 @@ for (uint32_t i = 0; i < user_dirs_count; i++) { FileSpec dir = user_dirs.GetFileSpecAtIndex(i); FileSystem::Instance().Resolve(dir); -if (llvm::sys::fs::is_directory(dir.GetPath())) { +if (FileSystem::Instance().IsDirectory(dir)) { m_search_directories.push_back(dir); } } @@ -413,7 +413,7 @@ for (int i = 0; subdirs[i] != nullptr; i++) { FileSpec testdir(dir + subdirs[i]); FileSystem::Instance().Resolve(testdir); -if (llvm::sys::fs::is_directory(testdir.GetPath())) +if (FileSystem::Instance().IsDirectory(testdir))