This source file includes following definitions.
- ShouldPackageFile
#include "chrome/browser/extensions/extension_creator_filter.h"
#include <vector>
#include <set>
#include "base/files/file_path.h"
#if defined(OS_WIN)
#include <windows.h>
#endif
namespace extensions {
bool ExtensionCreatorFilter::ShouldPackageFile(
const base::FilePath& file_path) {
const base::FilePath& base_name = file_path.BaseName();
if (base_name.empty()) {
return false;
}
const base::FilePath::StringType names_to_exclude[] = {
FILE_PATH_LITERAL(".DS_Store"),
FILE_PATH_LITERAL(".git"),
FILE_PATH_LITERAL(".svn"),
FILE_PATH_LITERAL("__MACOSX"),
FILE_PATH_LITERAL("desktop.ini"),
FILE_PATH_LITERAL("Thumbs.db")
};
std::set<base::FilePath::StringType> names_to_exclude_set(names_to_exclude,
names_to_exclude + arraysize(names_to_exclude));
std::vector<base::FilePath::StringType> components;
file_path.GetComponents(&components);
for (size_t i = 0; i < components.size(); i++) {
if (names_to_exclude_set.count(components[i]))
return false;
}
base::FilePath::CharType first_character = base_name.value()[0];
base::FilePath::CharType last_character =
base_name.value()[base_name.value().length() - 1];
if (first_character == '.') {
return false;
}
if (last_character == '~') {
return false;
}
if (first_character == '#' && last_character == '#') {
return false;
}
#if defined(OS_WIN)
DWORD file_attributes = ::GetFileAttributes(file_path.value().c_str());
if (file_attributes == INVALID_FILE_ATTRIBUTES) {
return false;
}
if ((file_attributes & FILE_ATTRIBUTE_HIDDEN) != 0) {
return false;
}
#endif
return true;
}
}