chromium/base/nix/mime_util_xdg.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/nix/mime_util_xdg.h"

#include <memory>
#include <utility>

#include "base/check.h"
#include "base/containers/stack.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/nix/xdg_util.h"
#include "base/no_destructor.h"
#include "base/numerics/byte_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "build/build_config.h"

#if !BUILDFLAG(IS_CHROMEOS)
#include "base/synchronization/lock.h"
#endif

namespace base::nix {
namespace {

// Ridiculously large size for a /usr/share/mime/mime.cache file.
// Default file is about 100KB, allow up to 10MB.
constexpr size_t kMaxMimeTypesFileSize =;
// Maximum number of nodes to allow in reverse suffix tree.
// Default file has ~3K nodes, allow up to 30K.
constexpr size_t kMaxNodes =;
// Maximum file extension size.
constexpr size_t kMaxExtSize =;
// Header size in mime.cache file.
constexpr size_t kHeaderSize =;
// Largest valid unicode code point is U+10ffff.
constexpr uint32_t kMaxUnicode =;
// Default mime glob weight is 50, max is 100.
constexpr uint8_t kDefaultGlobWeight =;

// Path and last modified of mime.cache file.
struct FileInfo {};

// Load all mime cache files on the system.
void LoadAllMimeCacheFiles(MimeTypeMap& map, std::vector<FileInfo>& files) {}

// Read 4 bytes from string `buf` at `offset` as network order uint32_t.
// Returns false if `offset > buf.size() - 4` or `offset` is not aligned to a
// 4-byte word boundary, or `*result` is not between `min_result` and
// `max_result`. `field_name` is used in error message.
bool ReadInt(const std::string& buf,
             uint32_t offset,
             const std::string& field_name,
             uint32_t min_result,
             size_t max_result,
             uint32_t* result) {}

}  // namespace

bool ParseMimeTypes(const FilePath& file_path, MimeTypeMap& out_mime_types) {}

std::string GetFileMimeType(const FilePath& filepath) {}

}  // namespace base::nix