FEDEM Solver  R8.0
Source code of the dynamics solver
FFaFilePath.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
13 #ifndef FFA_FILE_PATH_H
14 #define FFA_FILE_PATH_H
15 
16 #include <string>
17 #include <vector>
18 
19 
20 namespace FFaFilePath
21 {
22  // In place convertion Win32 <-> Unix
23 
24  size_t checkName (char* thePath, size_t length);
25  std::string& checkName (std::string& thePath);
26  std::string& unixStyle (std::string& thePath);
27  std::string unixStyle (const std::string& thePath);
28 
29  // Some checking
30 
31  bool hasPath (const std::string& fileName);
32  bool isRelativePath (const std::string& pathName);
33  bool isExtension (const std::string& fileName, const std::string& ext);
34 
35  // Basic string operations on paths
36 
37  std::string getPath (const std::string& fullPath, bool keepSlash = true);
38  std::string getFileName (const std::string& fullPath);
39  std::string getExtension (const std::string& fileName);
40  std::string getBaseName (const std::string& fileName, bool removePath = false);
41 
42  std::string appendFileNameToPath (const std::string& path, const std::string& fName);
43  std::string& appendToPath (std::string& path, const std::string& fName);
44  std::string& makeItAbsolute (std::string& fName, const std::string& path);
45  std::string& makeItRelative (std::string& fName, const std::string& path);
46  std::string& setPath (std::string& fName, const std::string& path);
47 
48  char getPathSeparator ();
49 
50  std::string& addExtension (std::string& fileName, const std::string& ext);
51  std::string& addExtension (std::string& fileName, const std::vector<std::string>& exts);
52 
54  std::string getRelativeFilename (const std::string& currentDirectory,
55  const std::string& absoluteFilename);
56 
58  std::string distillName (const std::string& filePath, bool removePath = false);
59 }
60 
61 #endif
Utilities for file path handling.
Definition: FFaFilePath.H:21
std::string & setPath(std::string &fName, const std::string &path)
Replaces the current path in fileName with path.
Definition: FFaFilePath.C:331
std::string getBaseName(const std::string &fileName, bool removePath=false)
Returns the file name without extension.
Definition: FFaFilePath.C:178
std::string getFileName(const std::string &fullPath)
Returns the file name part of fullPath.
Definition: FFaFilePath.C:162
bool isExtension(const std::string &fileName, const std::string &ext)
Checks if ext is the extension of fName.
Definition: FFaFilePath.C:243
std::string getExtension(const std::string &fileName)
Returns the extension of fName.
Definition: FFaFilePath.C:221
std::string & appendToPath(std::string &path, const std::string &fName)
Appends fileName to path.
Definition: FFaFilePath.C:303
std::string & addExtension(std::string &fileName, const std::string &ext)
Adds ext to fileName, if not already present.
Definition: FFaFilePath.C:356
char getPathSeparator()
Returns the path separator for this system.
Definition: FFaFilePath.C:344
std::string & makeItRelative(std::string &fName, const std::string &path)
Makes fileName a relative pathname with respect to absPath.
Definition: FFaFilePath.C:523
std::string appendFileNameToPath(const std::string &path, const std::string &fName)
Appends fileName to path.
Definition: FFaFilePath.C:263
bool hasPath(const std::string &fileName)
Checks if the provided fileName has a path.
Definition: FFaFilePath.C:123
std::string & unixStyle(std::string &thePath)
Modify the given path to using UNIX-style path separators.
Definition: FFaFilePath.C:98
std::string getRelativeFilename(const std::string &currentDirectory, const std::string &absoluteFilename)
Returns the relative path name with respect to an absolute path.
Definition: FFaFilePath.C:420
std::string distillName(const std::string &filePath, bool removePath=false)
Checks for illegal characters in file names.
Definition: FFaFilePath.C:539
std::string getPath(const std::string &fullPath, bool keepSlash=true)
Returns the path part of fullPath.
Definition: FFaFilePath.C:136
std::string & makeItAbsolute(std::string &fName, const std::string &path)
Makes fileName an absolute pathname by prefixing it with absPath.
Definition: FFaFilePath.C:317
bool isRelativePath(const std::string &pathName)
Determines if path is relative or absolute.
Definition: FFaFilePath.C:395
size_t checkName(char *thePath, size_t length)
Converts file pathnames from UNIX to Windows syntax and vice versa.
Definition: FFaFilePath.C:37