#include "util/file/file_io.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/file.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <algorithm>
#include <limits>
#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "util/misc/random_string.h"
namespace crashpad {
namespace {
struct ReadTraits { … };
struct WriteTraits { … };
template <typename Traits>
FileOperationResult ReadOrWrite(int fd,
typename Traits::BufferType buffer,
size_t size) { … }
FileHandle OpenFileForOutput(int rdwr_or_wronly,
const base::FilePath& path,
FileWriteMode mode,
FilePermissions permissions) { … }
}
namespace internal {
FileOperationResult NativeWriteFile(FileHandle file,
const void* buffer,
size_t size) { … }
}
FileOperationResult ReadFile(FileHandle file, void* buffer, size_t size) { … }
FileHandle OpenFileForRead(const base::FilePath& path) { … }
FileHandle OpenFileForWrite(const base::FilePath& path,
FileWriteMode mode,
FilePermissions permissions) { … }
FileHandle OpenFileForReadAndWrite(const base::FilePath& path,
FileWriteMode mode,
FilePermissions permissions) { … }
FileHandle LoggingOpenFileForRead(const base::FilePath& path) { … }
FileHandle LoggingOpenFileForWrite(const base::FilePath& path,
FileWriteMode mode,
FilePermissions permissions) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
FileHandle LoggingOpenMemoryFileForReadAndWrite(const base::FilePath& name) { … }
#endif
FileHandle LoggingOpenFileForReadAndWrite(const base::FilePath& path,
FileWriteMode mode,
FilePermissions permissions) { … }
#if CRASHPAD_FLOCK_ALWAYS_SUPPORTED
FileLockingResult LoggingLockFile(FileHandle file,
FileLocking locking,
FileLockingBlocking blocking) { … }
bool LoggingUnlockFile(FileHandle file) { … }
#endif
FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence) { … }
bool LoggingTruncateFile(FileHandle file) { … }
bool LoggingCloseFile(FileHandle file) { … }
FileOffset LoggingFileSizeByHandle(FileHandle file) { … }
FileHandle StdioFileHandle(StdioStream stdio_stream) { … }
}