diff --git a/src/file.cc b/src/file.cc index edb4e7bcc7..b7a6579a6c 100644 --- a/src/file.cc +++ b/src/file.cc @@ -18,6 +18,44 @@ using namespace v8; // In javascript it is called "File". static Persistent fs; +class FileSystem { +public: + static Handle Rename (const Arguments& args); + static int AfterRename (eio_req *req); + + static Handle Stat (const Arguments& args); + static int AfterStat (eio_req *req); + + static Handle StrError (const Arguments& args); +}; + +class File { +public: + File (Handle handle); + ~File (); + + static Handle New (const Arguments& args); + + static Handle Open (const Arguments& args); + static int AfterOpen (eio_req *req); + + static Handle Close (const Arguments& args); + static int AfterClose (eio_req *req); + + static Handle Write (const Arguments& args); + static int AfterWrite (eio_req *req); + + static Handle Read (const Arguments& args); + static int AfterRead (eio_req *req); + +private: + static File* Unwrap (Handle handle); + bool HasUtf8Encoding (void); + int GetFD (void); + static void MakeWeak (Persistent _, void *data); + Persistent handle_; +}; + static void CallTopCallback (Handle handle, const int argc, Handle argv[]) { @@ -57,44 +95,6 @@ InitActionQueue (Handle handle) handle->Set(ACTION_QUEUE_SYMBOL, Array::New()); } -class File { -public: - File (Handle handle); - ~File (); - - static File* Unwrap (Handle handle); - - static Handle Open (const Arguments& args); - static int AfterOpen (eio_req *req); - - static Handle Close (const Arguments& args); - static int AfterClose (eio_req *req); - - static Handle Write (const Arguments& args); - static int AfterWrite (eio_req *req); - - static Handle Read (const Arguments& args); - static int AfterRead (eio_req *req); - - -private: - bool HasUtf8Encoding (void); - Persistent handle_; - int GetFD (void); - static void MakeWeak (Persistent _, void *data); -}; - -class FileSystem { -public: - static Handle Rename (const Arguments& args); - static int AfterRename (eio_req *req); - - static Handle Stat (const Arguments& args); - static int AfterStat (eio_req *req); - - static Handle StrError (const Arguments& args); -}; - Handle FileSystem::Rename (const Arguments& args) { @@ -471,8 +471,8 @@ File::AfterRead (eio_req *req) return 0; } -static Handle -NewFile (const Arguments& args) +Handle +File::New(const Arguments& args) { HandleScope scope; File *file = new File(args.Holder()); @@ -490,7 +490,7 @@ NodeInit_file (Handle target) HandleScope scope; - Local file_template = FunctionTemplate::New(NewFile); + Local file_template = FunctionTemplate::New(File::New); file_template->InstanceTemplate()->SetInternalFieldCount(1); fs = Persistent::New(file_template->GetFunction());