chromium/third_party/mediapipe/src/mediapipe/tasks/cc/core/external_file_handler.cc

/* Copyright 2022 The MediaPipe Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "mediapipe/tasks/cc/core/external_file_handler.h"

#include <errno.h>
#include <fcntl.h>
#include <stddef.h>

#ifdef ABSL_HAVE_MMAP
#include <sys/mman.h>
#endif

#ifdef _WIN32
#include <direct.h>
#include <io.h>
#include <windows.h>
#else
#include <unistd.h>
#endif  // _WIN32

#include <memory>
#include <string>

#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/match.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "mediapipe/framework/port/status_macros.h"
#include "mediapipe/tasks/cc/common.h"
#include "mediapipe/tasks/cc/core/proto/external_file.pb.h"
#include "mediapipe/util/resource_util.h"

namespace mediapipe {
namespace tasks {
namespace core {
namespace {

StatusCode;

#ifndef O_BINARY
#ifdef _O_BINARY
#define O_BINARY
#else
#define O_BINARY
#endif              // _O_BINARY
#endif              // O_BINARY

// Gets the offset aligned to page size for mapping given files into memory by
// file descriptor correctly, as according to mmap(2), the offset used in mmap
// must be a multiple of sysconf(_SC_PAGE_SIZE).
int64_t GetPageSizeAlignedOffset(int64_t offset) {}

}  // namespace

/* static */
absl::StatusOr<std::unique_ptr<ExternalFileHandler>>
ExternalFileHandler::CreateFromExternalFile(
    const proto::ExternalFile* external_file) {}

absl::Status ExternalFileHandler::MapExternalFile() {}

absl::string_view ExternalFileHandler::GetFileContent() {}

ExternalFileHandler::~ExternalFileHandler() {}

}  // namespace core
}  // namespace tasks
}  // namespace mediapipe