|
Cppcheck
|
Path handling routines. More...
#include <path.h>
Static Public Member Functions | |
| static std::string | toNativeSeparators (std::string path) |
| Convert path to use native separators. | |
| static std::string | fromNativeSeparators (std::string path) |
| Convert path to use internal path separators. | |
| static std::string | simplifyPath (const char *originalPath) |
| Simplify path "foo/bar/.." => "foo". | |
| static std::string | getPathFromFilename (const std::string &filename) |
| Lookup the path part from a filename (e.g., '/tmp/a.h' -> '/tmp/', 'a.h' -> '') | |
| static bool | sameFileName (const std::string &fname1, const std::string &fname2) |
| Compare filenames to see if they are the same. | |
| static std::string | removeQuotationMarks (std::string path) |
| Remove quotation marks (") from the path. | |
| static std::string | getFilenameExtension (const std::string &path) |
| Get an extension of the filename. | |
| static std::string | getFilenameExtensionInLowerCase (const std::string &path) |
| Get an extension of the filename in lower case. | |
| static std::string | getRelativePath (const std::string &absolutePath, const std::vector< std::string > &basePaths) |
| Create a relative path from an absolute one, if absolute path is inside the basePaths. | |
| static bool | acceptFile (const std::string &filename) |
| Check if the file extension indicates that it's a C/C++ source file. | |
| static bool | isC (const std::string &path) |
| Identify language based on file extension. | |
| static bool | isCPP (const std::string &extensionInLowerCase) |
| Identify language based on file extension. | |
Static Private Member Functions | |
| static bool | isHeader (const std::string &path) |
| Is filename a header based on file extension. | |
Path handling routines.
Internally cppcheck wants to store paths with / separator which is also native separator for Unix-derived systems. When giving path to user or for other functions we convert path separators back to native type.
| bool Path::acceptFile | ( | const std::string & | filename | ) | [static] |
Check if the file extension indicates that it's a C/C++ source file.
Check if the file has source file extension: *.c;*.cpp;*.cxx;*.c++;*.cc;*.txx
| path | filename to check. path info is optional |
Definition at line 209 of file path.cpp.
References isC(), isCPP(), and isHeader().
Referenced by CppCheck::processFile(), and FileLister::recursiveAddFiles2().
| std::string Path::fromNativeSeparators | ( | std::string | path | ) | [static] |
Convert path to use internal path separators.
| path | Path string to convert. |
Definition at line 50 of file path.cpp.
Referenced by AddInclPathsToList(), Suppressions::addSuppressionLine(), Preprocessor::handleIncludes(), Preprocessor::missingInclude(), CmdLineParser::ParseFromArgs(), and ErrorLogger::ErrorMessage::FileLocation::setfile().
| std::string Path::getFilenameExtension | ( | const std::string & | path | ) | [static] |
Get an extension of the filename.
| path | Path containing filename. |
Definition at line 148 of file path.cpp.
References caseInsensitiveFilesystem(), and tolowerWrapper().
Referenced by getFilenameExtensionInLowerCase(), isC(), isCPP(), and CppCheckExecutor::parseFromArgs().
| std::string Path::getFilenameExtensionInLowerCase | ( | const std::string & | path | ) | [static] |
Get an extension of the filename in lower case.
| path | Path containing filename. |
Definition at line 163 of file path.cpp.
References getFilenameExtension(), and tolowerWrapper().
Referenced by isCPP(), and isHeader().
| std::string Path::getPathFromFilename | ( | const std::string & | filename | ) | [static] |
| std::string Path::getRelativePath | ( | const std::string & | absolutePath, |
| const std::vector< std::string > & | basePaths | ||
| ) | [static] |
Create a relative path from an absolute one, if absolute path is inside the basePaths.
| absolutePath | Path to be made relative. |
| basePaths | Paths to which it may be made relative. |
Definition at line 170 of file path.cpp.
Referenced by TokenList::createTokens(), and Tokenizer::tokenize().
| bool Path::isC | ( | const std::string & | path | ) | [static] |
Identify language based on file extension.
| path | filename to check. path info is optional |
Definition at line 185 of file path.cpp.
References getFilenameExtension().
Referenced by acceptFile().
| bool Path::isCPP | ( | const std::string & | extensionInLowerCase | ) | [static] |
Identify language based on file extension.
| path | filename to check. path info is optional |
Definition at line 192 of file path.cpp.
References getFilenameExtension(), and getFilenameExtensionInLowerCase().
Referenced by acceptFile(), and Preprocessor::getcode().
| bool Path::isHeader | ( | const std::string & | path | ) | [static, private] |
Is filename a header based on file extension.
| path | filename to check. path info is optional |
Definition at line 214 of file path.cpp.
References getFilenameExtensionInLowerCase().
Referenced by acceptFile().
| std::string Path::removeQuotationMarks | ( | std::string | path | ) | [static] |
Remove quotation marks (") from the path.
| path | path to be cleaned. |
Definition at line 142 of file path.cpp.
Referenced by AddInclPathsToList(), and CmdLineParser::ParseFromArgs().
| bool Path::sameFileName | ( | const std::string & | fname1, |
| const std::string & | fname2 | ||
| ) | [static] |
Compare filenames to see if they are the same.
On Linux the comparison is case-sensitive. On Windows it is case-insensitive.
| fname1 | one filename |
| fname2 | other filename |
Definition at line 120 of file path.cpp.
Referenced by TokenList::createTokens(), and FileLister::recursiveAddFiles2().
| std::string Path::simplifyPath | ( | const char * | originalPath | ) | [static] |
Simplify path "foo/bar/.." => "foo".
| originalPath | path to be simplified, must have / -separators. |
Definition at line 58 of file path.cpp.
Referenced by Suppressions::FileMatcher::addFile(), TokenList::createTokens(), Preprocessor::handleIncludes(), CmdLineParser::ParseFromArgs(), CppCheck::processFile(), ErrorLogger::ErrorMessage::FileLocation::setfile(), and Tokenizer::tokenize().
| std::string Path::toNativeSeparators | ( | std::string | path | ) | [static] |
Convert path to use native separators.
| path | Path string to convert. |
Definition at line 37 of file path.cpp.
Referenced by CppCheck::checkFile(), ErrorLogger::ErrorMessage::FileLocation::getfile(), Preprocessor::handleIncludes(), Preprocessor::missingInclude(), openHeader(), CppCheckExecutor::parseFromArgs(), CppCheck::processFile(), and ErrorLogger::ErrorMessage::FileLocation::stringify().
1.7.6.1