// Copyright 2014 The Crashpad 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. #ifndef CRASHPAD_UTIL_FILE_FILE_WRITER_H_ #define CRASHPAD_UTIL_FILE_FILE_WRITER_H_ #include <sys/types.h> #include <vector> #include "base/files/file_path.h" #include "build/build_config.h" #include "util/file/file_io.h" #include "util/file/file_seeker.h" namespace crashpad { //! \brief A version of `iovec` with a `const` #iov_base field. //! //! This structure is intended to be used for write operations. // // Type compatibility with iovec is tested with static assertions in the // implementation file. struct WritableIoVec { … }; //! \brief An interface to write to files and other file-like objects with //! semantics matching the underlying platform (POSIX or Windows). class FileWriterInterface : public virtual FileSeekerInterface { … }; //! \brief A file writer backed by a FileHandle. //! //! FileWriter requires users to provide a FilePath to open, but this class //! accepts an already-open FileHandle instead. Like FileWriter, this class may //! write to a filesystem-based file, but unlike FileWriter, this class is not //! responsible for creating or closing the file. Users of this class must //! ensure that the file handle is closed appropriately elsewhere. Objects of //! this class may be used to write to file handles not associated with //! filesystem-based files, although special attention should be paid to the //! Seek() method, which may not function on file handles that do not refer to //! disk-based files. //! //! This class is expected to be used when other code is responsible for //! creating files and already provides file handles. class WeakFileHandleFileWriter : public FileWriterInterface { … }; //! \brief A file writer implementation that wraps traditional system file //! operations on files accessed through the filesystem. class FileWriter : public FileWriterInterface { … }; } // namespace crashpad #endif // CRASHPAD_UTIL_FILE_FILE_WRITER_H_