Index: src/v8utils.h |
=================================================================== |
--- src/v8utils.h (revision 6353) |
+++ src/v8utils.h (working copy) |
@@ -316,6 +316,39 @@ |
} |
} |
+ |
+// A resource for using mmapped files to back external strings that are read |
+// from files. |
+class MemoryMappedExternalResource: public |
+ v8::String::ExternalAsciiStringResource { |
+ public: |
+ explicit MemoryMappedExternalResource(const char* filename); |
+ MemoryMappedExternalResource(const char* filename, |
+ bool remove_file_on_cleanup); |
+ virtual ~MemoryMappedExternalResource(); |
+ |
+ virtual const char* data() const { return data_; } |
+ virtual size_t length() const { return length_; } |
+ |
+ bool exists() const { return file_ != NULL; } |
+ bool is_empty() const { return length_ == 0; } |
+ |
+ bool EnsureIsAscii(bool abort_if_failed) const; |
+ bool EnsureIsAscii() const { return EnsureIsAscii(true); } |
+ bool IsAscii() const { return EnsureIsAscii(false); } |
+ |
+ private: |
+ void Init(const char* filename); |
+ |
+ char* filename_; |
+ OS::MemoryMappedFile* file_; |
+ |
+ const char* data_; |
+ size_t length_; |
+ bool remove_file_on_cleanup_; |
+}; |
+ |
+ |
} } // namespace v8::internal |
#endif // V8_V8UTILS_H_ |