summaryrefslogtreecommitdiff
path: root/src/node_file.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/node_file.h')
-rw-r--r--src/node_file.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/node_file.h b/src/node_file.h
index fa373d46ad..1925e400f2 100644
--- a/src/node_file.h
+++ b/src/node_file.h
@@ -24,6 +24,8 @@ namespace fs {
class FSReqBase : public ReqWrap<uv_fs_t> {
public:
+ typedef MaybeStackBuffer<char, 64> FSReqBuffer;
+
FSReqBase(Environment* env, Local<Object> req, AsyncWrap::ProviderType type)
: ReqWrap(env, req, type) {
Wrap(object(), this);
@@ -34,9 +36,9 @@ class FSReqBase : public ReqWrap<uv_fs_t> {
}
void Init(const char* syscall,
- const char* data = nullptr,
- size_t len = 0,
- enum encoding encoding = UTF8) {
+ const char* data,
+ size_t len,
+ enum encoding encoding) {
syscall_ = syscall;
encoding_ = encoding;
@@ -49,6 +51,16 @@ class FSReqBase : public ReqWrap<uv_fs_t> {
}
}
+ FSReqBuffer& Init(const char* syscall, size_t len,
+ enum encoding encoding) {
+ syscall_ = syscall;
+ encoding_ = encoding;
+
+ buffer_.AllocateSufficientStorage(len + 1);
+ has_data_ = false; // so that the data does not show up in error messages
+ return buffer_;
+ }
+
virtual void FillStatsArray(const uv_stat_t* stat) = 0;
virtual void Reject(Local<Value> reject) = 0;
virtual void Resolve(Local<Value> value) = 0;
@@ -68,7 +80,7 @@ class FSReqBase : public ReqWrap<uv_fs_t> {
// Typically, the content of buffer_ is something like a file name, so
// something around 64 bytes should be enough.
- MaybeStackBuffer<char, 64> buffer_;
+ FSReqBuffer buffer_;
DISALLOW_COPY_AND_ASSIGN(FSReqBase);
};