VTK  9.3.20240420
vtkPSystemTools.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
17#ifndef vtkPSystemTools_h
18#define vtkPSystemTools_h
19
20#include "vtkObject.h"
21#include "vtkParallelCoreModule.h" // For export macro
22#include <string> // for string functions in SystemTools
23
24VTK_ABI_NAMESPACE_BEGIN
25class VTKPARALLELCORE_EXPORT vtkPSystemTools : public vtkObject
26{
27public:
29 vtkTypeMacro(vtkPSystemTools, vtkObject);
30 void PrintSelf(ostream& os, vtkIndent indent) override;
31
38 static void BroadcastString(std::string&, int proc);
39
47 static VTK_FILEPATH std::string CollapseFullPath(VTK_FILEPATH const std::string& in_relative);
48 static VTK_FILEPATH std::string CollapseFullPath(
49 VTK_FILEPATH const std::string& in_relative, VTK_FILEPATH const char* in_base);
50
52
60 static bool FileExists(VTK_FILEPATH const char* filename, bool isFile);
61 static bool FileExists(VTK_FILEPATH const std::string& filename, bool isFile);
62 static bool FileExists(VTK_FILEPATH const char* filename);
63 static bool FileExists(VTK_FILEPATH const std::string& filename);
65
69 static bool FileIsDirectory(VTK_FILEPATH const std::string& name);
70
83 static bool FindProgramPath(const char* argv0, std::string& pathOut, std::string& errorMsg,
84 const char* exeName = nullptr, const char* buildDir = nullptr,
85 const char* installPrefix = nullptr);
86
90 static VTK_FILEPATH std::string GetCurrentWorkingDirectory(bool collapse = true);
91
97 static VTK_FILEPATH std::string GetProgramPath(VTK_FILEPATH const std::string&);
98
99protected:
100 vtkPSystemTools() = default;
101 ~vtkPSystemTools() override = default;
102
103private:
104 vtkPSystemTools(const vtkPSystemTools&) = delete;
105 void operator=(const vtkPSystemTools&) = delete;
106};
107
108VTK_ABI_NAMESPACE_END
109#endif
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
System tools for file system introspection.
static void BroadcastString(std::string &, int proc)
Given a string on process proc, broadcast that string to all of the other processes.
vtkPSystemTools()=default
static bool FileIsDirectory(VTK_FILEPATH const std::string &name)
Return true if the file is a directory.
static bool FileExists(VTK_FILEPATH const std::string &filename)
Return true if a file exists in the current directory.
static VTK_FILEPATH std::string GetProgramPath(VTK_FILEPATH const std::string &)
Given the path to a program executable, get the directory part of the path with the file stripped off...
static vtkPSystemTools * New()
~vtkPSystemTools() override=default
static VTK_FILEPATH std::string CollapseFullPath(VTK_FILEPATH const std::string &in_relative, VTK_FILEPATH const char *in_base)
static bool FileExists(VTK_FILEPATH const char *filename)
Return true if a file exists in the current directory.
static VTK_FILEPATH std::string CollapseFullPath(VTK_FILEPATH const std::string &in_relative)
Given a path to a file or directory, convert it to a full path.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static VTK_FILEPATH std::string GetCurrentWorkingDirectory(bool collapse=true)
Get current working directory CWD.
static bool FileExists(VTK_FILEPATH const std::string &filename, bool isFile)
Return true if a file exists in the current directory.
static bool FindProgramPath(const char *argv0, std::string &pathOut, std::string &errorMsg, const char *exeName=nullptr, const char *buildDir=nullptr, const char *installPrefix=nullptr)
Given argv[0] for a unix program find the full path to a running executable.
static bool FileExists(VTK_FILEPATH const char *filename, bool isFile)
Return true if a file exists in the current directory.
#define VTK_FILEPATH