diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-09-25 13:30:49 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-09-25 13:30:49 (GMT) |
commit | 6736678ca367da834c1a9ca89b48ad2e02a30f9b (patch) | |
tree | 9a723b030be1bddf541f07d8ad0e278974b49210 | |
parent | c6384c19b4793f1e18414c8f92780cd80d80c7a8 (diff) | |
download | CMake-6736678ca367da834c1a9ca89b48ad2e02a30f9b.zip CMake-6736678ca367da834c1a9ca89b48ad2e02a30f9b.tar.gz CMake-6736678ca367da834c1a9ca89b48ad2e02a30f9b.tar.bz2 |
Add detection of file format from extension
-rw-r--r-- | Source/cmSystemTools.cxx | 38 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 25 |
2 files changed, 62 insertions, 1 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2be5fe8..f4fd0da 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2148,3 +2148,41 @@ bool cmSystemTools::GetShortPath(const char* path, std::string& shortPath) return true; #endif } + +cmSystemTools::e_FileFormat cmSystemTools::GetFileFormat(const char* cext) +{ + if ( ! cext || *cext == 0 ) + { + return cmSystemTools::NO_FILE_FORMAT; + } + std::string ext = cmSystemTools::LowerCase(cext); + if ( ext == "c" || ext == ".c" ) { return cmSystemTools::C_FILE_FORMAT; } + if ( ext == "cxx" || ext == ".cxx" || + ext == "cpp" || ext == ".cpp" || + ext == "c++" || ext == ".c++" || + ext == "cc" || ext == ".cc" ) { return cmSystemTools::CXX_FILE_FORMAT; } + if ( ext == "java" || ext == ".java" ) { return cmSystemTools::JAVA_FILE_FORMAT; } + if ( ext == "h" || ext == ".h" || + ext == "hpp" || ext == ".hpp" || + ext == "h++" || ext == ".h++" || + ext == "hxx" || ext == ".hxx" ) { return cmSystemTools::HEADER_FILE_FORMAT; } + if ( ext == "rc" || ext == ".rc" ) { return cmSystemTools::RESOURCE_FILE_FORMAT; } + if ( ext == "def" || ext == ".def" ) { return cmSystemTools::DEFINITION_FILE_FORMAT; } + if ( ext == "lib" || ext == ".lib" || + ext == "a" || ext == ".a") { return cmSystemTools::STATIC_LIBRARY_FILE_FORMAT; } + if ( ext == "o" || ext == ".o" || + ext == "obj" || ext == ".obj") { return cmSystemTools::OBJECT_FILE_FORMAT; } +#ifdef __APPLE__ + if ( ext == "dylib" || ext == ".dylib" ) + { return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT; } + if ( ext == "so" || ext == ".so" || + ext == "bundle" || ext == ".bundle" ) + { return cmSystemTools::MODULE_FILE_FORMAT; } +#else // __APPLE__ + if ( ext == "so" || ext == ".so" || + ext == "sl" || ext == ".sl" || + ext == "dll" || ext == ".dll" ) + { return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT; } +#endif // __APPLE__ + return cmSystemTools::UNKNOWN_FILE_FORMAT; +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 422bfc6..716c2cf 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -287,6 +287,30 @@ public: static void DisableRunCommandOutput() {s_DisableRunCommandOutput = true; } static void EnableRunCommandOutput() {s_DisableRunCommandOutput = false; } static bool GetRunCommandOutput() { return s_DisableRunCommandOutput; } + + /** + * Come constants for different file formats. + */ + enum e_FileFormat { + NO_FILE_FORMAT = 0, + C_FILE_FORMAT, + CXX_FILE_FORMAT, + JAVA_FILE_FORMAT, + HEADER_FILE_FORMAT, + RESOURCE_FILE_FORMAT, + DEFINITION_FILE_FORMAT, + STATIC_LIBRARY_FILE_FORMAT, + SHARED_LIBRARY_FILE_FORMAT, + MODULE_FILE_FORMAT, + OBJECT_FILE_FORMAT, + UNKNOWN_FILE_FORMAT + }; + + /** + * Determine the file type based on the extension + */ + static e_FileFormat GetFileFormat(const char* ext); + protected: // these two functions can be called from ConvertToOutputPath /** @@ -302,7 +326,6 @@ protected: * if there are spaces in the string it is double quoted. */ static std::string ConvertToWindowsOutputPath(const char*); - private: static bool s_ErrorOccured; |