@@ -108,6 +108,13 @@ bool Path::sameFileName(const std::string &fname1, const std::string &fname2)
108108#endif
109109}
110110
111+ // This wrapper exists because Sun's CC does not allow a static_cast
112+ // from extern "C" int(*)(int) to int(*)(int).
113+ static int tolowerWrapper (int c)
114+ {
115+ return std::tolower (c);
116+ }
117+
111118std::string Path::removeQuotationMarks (std::string path)
112119{
113120 path.erase (std::remove (path.begin (), path.end (), ' \" ' ), path.end ());
@@ -124,26 +131,29 @@ std::string Path::getFilenameExtension(const std::string &path)
124131 return extension;
125132}
126133
127-
128- // This wrapper exists because Sun's CC does not allow a static_cast
129- // from extern "C" int(*)(int) to int(*)(int).
130- static int tolowerWrapper (int c)
134+ std::string Path::getFilenameExtensionInLowerCase (const std::string &path)
131135{
132- return std::tolower (c);
136+ std::string extension = getFilenameExtension (path);
137+ std::transform (extension.begin (), extension.end (), extension.begin (), tolowerWrapper);
138+ return extension;
133139}
134140
135-
136- bool Path::acceptFile (const std::string &filename)
141+ bool Path::isC (const std::string &path)
137142{
138- std::string extension = Path::getFilenameExtension (filename );
139- if (extension == " " )
140- return false ;
141- std::transform (extension. begin (), extension. end (), extension. begin (), tolowerWrapper);
143+ const std::string extension = getFilenameExtensionInLowerCase (path );
144+ if (extension == " .c " ) {
145+ return true ;
146+ }
142147
148+ return false ;
149+ }
150+
151+ bool Path::isCPP (const std::string &path)
152+ {
153+ const std::string extension = getFilenameExtensionInLowerCase (path);
143154 if (extension == " .cpp" ||
144155 extension == " .cxx" ||
145156 extension == " .cc" ||
146- extension == " .c" ||
147157 extension == " .c++" ||
148158 extension == " .tpp" ||
149159 extension == " .txx" ) {
@@ -153,3 +163,33 @@ bool Path::acceptFile(const std::string &filename)
153163 return false ;
154164}
155165
166+ bool Path::isJava (const std::string &path)
167+ {
168+ const std::string extension = getFilenameExtensionInLowerCase (path);
169+ if (extension == " .java" ) {
170+ return true ;
171+ }
172+
173+ return false ;
174+ }
175+
176+ bool Path::isCSharp (const std::string &path)
177+ {
178+ const std::string extension = getFilenameExtensionInLowerCase (path);
179+ if (extension == " .cs" ) {
180+ return true ;
181+ }
182+
183+ return false ;
184+ }
185+
186+ bool Path::acceptFile (const std::string &filename)
187+ {
188+ if (Path::isCPP (filename) ||
189+ Path::isC (filename)) {
190+ return true ;
191+ }
192+
193+ return false ;
194+ }
195+
0 commit comments