// Copyright 2015 The Shaderc Authors. All rights reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314#ifndef GLSLC_FILE_H_15#define GLSLC_FILE_H_1617#include "libshaderc_util/string_piece.h"1819namespace glslc {2021// Given a file name, returns its extension. If no extension exists,22// returns an empty string_piece.23shaderc_util::string_piece GetFileExtension(24const shaderc_util::string_piece& filename);2526// Returns true if the given file name ends with a known shader file extension.27inline bool IsStageFile(const shaderc_util::string_piece& filename) {28const shaderc_util::string_piece extension =29glslc::GetFileExtension(filename);30return extension == "vert" || extension == "frag" || extension == "tesc" ||31extension == "tese" || extension == "geom" || extension == "comp";32}3334// Returns the file extension if is either "glsl" or "hlsl", or an empty35// string otherwise.36inline std::string GetGlslOrHlslExtension(37const shaderc_util::string_piece& filename) {38auto extension = glslc::GetFileExtension(filename);39if ((extension == "glsl") || (extension == "hlsl")) return extension.str();40return "";41}4243} // namespace glslc4445#endif // GLSLC_FILE_H_464748