14f94c520f8d699a5973956a1716272146be17128Zonr Chang/* 24f94c520f8d699a5973956a1716272146be17128Zonr Chang * Copyright 2012, The Android Open Source Project 34f94c520f8d699a5973956a1716272146be17128Zonr Chang * 44f94c520f8d699a5973956a1716272146be17128Zonr Chang * Licensed under the Apache License, Version 2.0 (the "License"); 54f94c520f8d699a5973956a1716272146be17128Zonr Chang * you may not use this file except in compliance with the License. 64f94c520f8d699a5973956a1716272146be17128Zonr Chang * You may obtain a copy of the License at 74f94c520f8d699a5973956a1716272146be17128Zonr Chang * 84f94c520f8d699a5973956a1716272146be17128Zonr Chang * http://www.apache.org/licenses/LICENSE-2.0 94f94c520f8d699a5973956a1716272146be17128Zonr Chang * 104f94c520f8d699a5973956a1716272146be17128Zonr Chang * Unless required by applicable law or agreed to in writing, software 114f94c520f8d699a5973956a1716272146be17128Zonr Chang * distributed under the License is distributed on an "AS IS" BASIS, 124f94c520f8d699a5973956a1716272146be17128Zonr Chang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134f94c520f8d699a5973956a1716272146be17128Zonr Chang * See the License for the specific language governing permissions and 144f94c520f8d699a5973956a1716272146be17128Zonr Chang * limitations under the License. 154f94c520f8d699a5973956a1716272146be17128Zonr Chang */ 164f94c520f8d699a5973956a1716272146be17128Zonr Chang 17c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#ifndef BCC_SUPPORT_OUTPUT_FILE_H 18c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#define BCC_SUPPORT_OUTPUT_FILE_H 194f94c520f8d699a5973956a1716272146be17128Zonr Chang 20c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/Support/File.h" 21c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#include "bcc/Support/FileBase.h" 224f94c520f8d699a5973956a1716272146be17128Zonr Chang 234f94c520f8d699a5973956a1716272146be17128Zonr Changnamespace llvm { 244f94c520f8d699a5973956a1716272146be17128Zonr Chang class raw_fd_ostream; 254f94c520f8d699a5973956a1716272146be17128Zonr Chang} 264f94c520f8d699a5973956a1716272146be17128Zonr Chang 274f94c520f8d699a5973956a1716272146be17128Zonr Changnamespace bcc { 284f94c520f8d699a5973956a1716272146be17128Zonr Chang 294f94c520f8d699a5973956a1716272146be17128Zonr Changclass OutputFile : public File<FileBase::kWriteMode> { 304f94c520f8d699a5973956a1716272146be17128Zonr Chang typedef File<FileBase::kWriteMode> super; 314f94c520f8d699a5973956a1716272146be17128Zonr Changpublic: 324f94c520f8d699a5973956a1716272146be17128Zonr Chang OutputFile(const std::string &pFilename, unsigned pFlags = 0); 334f94c520f8d699a5973956a1716272146be17128Zonr Chang 344f94c520f8d699a5973956a1716272146be17128Zonr Chang ssize_t write(const void *pBuf, size_t count); 354f94c520f8d699a5973956a1716272146be17128Zonr Chang 364f94c520f8d699a5973956a1716272146be17128Zonr Chang void truncate(); 374f94c520f8d699a5973956a1716272146be17128Zonr Chang 384f94c520f8d699a5973956a1716272146be17128Zonr Chang // This is similar to the system call dup(). It creates a copy of the file 394f94c520f8d699a5973956a1716272146be17128Zonr Chang // descriptor it contains and wrap it in llvm::raw_fd_ostream object. It 404f94c520f8d699a5973956a1716272146be17128Zonr Chang // returns a non-NULL object if everything goes well and user should later 414f94c520f8d699a5973956a1716272146be17128Zonr Chang // use delete operator to destroy it by itself. 424f94c520f8d699a5973956a1716272146be17128Zonr Chang llvm::raw_fd_ostream *dup(); 434f94c520f8d699a5973956a1716272146be17128Zonr Chang}; 444f94c520f8d699a5973956a1716272146be17128Zonr Chang 454f94c520f8d699a5973956a1716272146be17128Zonr Chang} // end namespace bcc 464f94c520f8d699a5973956a1716272146be17128Zonr Chang 47c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#endif // BCC_SUPPORT_OUTPUT_FILE_H 48