Add sub-controls for Hack array compat runtime checks
[hiphop-php.git] / hphp / runtime / base / temp-file.h
blobb3b0f65b1f771d19a65dae772e244bd3d388dce3
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_TEMP_FILE_H_
18 #define incl_HPHP_TEMP_FILE_H_
20 #include "hphp/runtime/base/plain-file.h"
22 namespace HPHP {
23 ///////////////////////////////////////////////////////////////////////////////
25 /**
26 * A temporary read/write file system file for php://temp, it will be deleted
27 * from the file system on close.
29 struct TempFile : PlainFile {
30 DECLARE_RESOURCE_ALLOCATION(TempFile);
32 explicit TempFile(bool autoDelete = true,
33 const String& wrapper_type = null_string,
34 const String& stream_type = empty_string_ref);
35 virtual ~TempFile();
37 // overriding ResourceData
38 const String& o_getClassNameHook() const override { return classnameof(); }
40 // implementing File
41 bool open(const String& filename, const String& mode) override;
42 bool close() override;
44 Object await(uint16_t /*events*/, double /*timeout*/) override {
45 SystemLib::throwExceptionObject(
46 "Temporary stream does not support awaiting");
49 bool seek(int64_t offset, int whence = SEEK_SET) override;
50 bool truncate(int64_t size) override;
51 int64_t tell() override;
53 private:
54 bool m_autoDelete;
55 std::string m_rawName;
57 bool closeImpl();
58 int64_t getLength();
61 ///////////////////////////////////////////////////////////////////////////////
64 #endif // incl_HPHP_TEMP_FILE_H_