summaryrefslogtreecommitdiff
path: root/src/fs_event_wrap.cc
Commit message (Collapse)AuthorAgeFilesLines
* src: do not include x.h if x-inl.h is includedJoyee Cheung2017-11-281-2/+0
| | | | | | | | | | | Backport-PR-URL: https://github.com/nodejs/node/pull/16610 Fixes: https://github.com/nodejs/node/issues/16519 PR-URL: https://github.com/nodejs/node/pull/16548 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* src: remove unneeded ABORT after CHECKyorkie2016-10-111-1/+0
| | | | | | | | | | CHECK includes node::Abort(), so that's unneeded to call ABORT after CHECK. PR-URL: https://github.com/nodejs/node/pull/8593 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* src: clean up PER_ISOLATE_STRING_PROPERTIES, v2Ben Noordhuis2016-08-241-2/+3
| | | | | | | | | | Remove strings from the PER_ISOLATE_STRING_PROPERTIES list that are only used once during initialization. It's less expensive to simply create them when needed than turn them into v8::Eternal instances. PR-URL: https://github.com/nodejs/node/pull/8207 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* src: guard against starting fs watcher twiceBen Noordhuis2016-07-051-0/+1
| | | | | | | | | | | This commit adds a CHECK that verifies that the file event watcher is not started twice, which would be indicative of a bug in lib/fs.js. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* src: initialize encoding_ data memberBen Noordhuis2016-07-051-6/+6
| | | | | | | | | | | | Pointed out by Coverity. Not really a bug because it's assigned before use but explicit assignment in the constructor is more obviously correct. PR-URL: https://github.com/nodejs/node/pull/7374 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* src: fix readability/inheritance cpplint warningsBen Noordhuis2016-07-051-1/+1
| | | | | PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* src: no abort from getter if object isn't wrappedTrevor Norris2016-06-021-2/+4
| | | | | | | | | | | | | | | | | v8::Object::GetAlignedPointerFromInternalField() returns a random value if Wrap() hasn't been run on the object handle. Causing v8 to abort if certain getters are accessed. It's possible to access these getters and functions during class construction through the AsyncWrap init() callback, and also possible in a subset of those scenarios while running the persistent handle visitor. Mitigate this issue by manually setting the internal aligned pointer field to nullptr in the BaseObject constructor and add necessary logic to return appropriate values when nullptr is encountered. PR-URL: https://github.com/nodejs/node/pull/6184 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* src: replace ARRAY_SIZE with typesafe arraysizeBen Noordhuis2016-04-051-1/+1
| | | | | | | | | To prevent `ARRAY_SIZE(&arg)` (i.e., taking the array size of a pointer) from happening again. PR-URL: https://github.com/nodejs/node/pull/5969 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* fs: Buffer and encoding enhancements to fs APIJames M Snell2016-03-251-5/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes several changes: 1. Allow path/filename to be passed in as a Buffer on fs methods 2. Add `options.encoding` to fs.readdir, fs.readdirSync, fs.readlink, fs.readlinkSync and fs.watch. 3. Documentation updates For 1... it's now possible to do: ```js fs.open(Buffer('/fs/foo/bar'), 'w+', (err, fd) => { }); ``` For 2... ```js fs.readdir('/fs/foo/bar', {encoding:'hex'}, (err,list) => { }); fs.readdir('/fs/foo/bar', {encoding:'buffer'}, (err, list) => { }); ``` encoding can also be passed as a string ```js fs.readdir('/fs/foo/bar', 'hex', (err,list) => { }); ``` The default encoding is set to UTF8 so this addresses the discrepency that existed previously between fs.readdir and fs.watch handling filenames differently. Fixes: https://github.com/nodejs/node/issues/2088 Refs: https://github.com/nodejs/node/issues/3519 PR-URL: https://github.com/nodejs/node/pull/5616 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* src: Add ABORT macroEvan Lucas2015-09-171-1/+1
| | | | | | | | | | | | Windows 8+ compiled in Release mode exits with code 0xC0000409 when abort() is called. This prevents us from being able to reliably verify an abort exit code (3) on windows. PR-URL: https://github.com/nodejs/node/pull/2776 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-by: Trevor Norris <trev.norris@gmail.com>
* src: replace usage of v8::Handle with v8::LocalMichaƫl Zasso2015-09-061-9/+8
| | | | | | | v8::Handle is deprecated: https://codereview.chromium.org/1224623004 PR-URL: https://github.com/nodejs/io.js/pull/2202 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* async-wrap: add provider id and object info cbTrevor Norris2015-06-171-0/+2
| | | | | | | | | | | | | | | | | | | Re-add the wrapper class id to AsyncWrap instances so they can be tracked directly in a heapdump. Previously the class id was given without setting the heap dump wrapper class info provider. Causing a segfault when a heapdump was taken. This has been added, and the label_ set to the given provider name so each instance can be identified. The id will not be set of the passed object has no internal field count. As the class pointer cannot be retrieved from the object. In order to properly report the allocated size of each class, the new pure virtual method self_size() has been introduces. PR-URL: https://github.com/nodejs/io.js/pull/1896 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* fs: improve error message descriptionsSakthipriyan Vairamani2015-06-101-1/+1
| | | | | | | | | | | | | | 1. Change "Bad arguments" error messages to a more helpful message "options should either be an object or a string". 2. Make braces consistent. 3. Return meaningful error message from fs_event_wrap's FSEvent's Start function. PR-URL: https://github.com/nodejs/io.js/pull/1870 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* Remove excessive copyright/license boilerplateisaacs2015-01-121-21/+0
| | | | | | | The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
* src: pass Isolate to node::Utf8Value constructorTrevor Norris2015-01-071-1/+1
| | | | | | | | Initial attempt to remove all uses of Isolate::GetCurrent(). Still exists a few locations, but this works out a heavy usage. PR-URL: https://github.com/iojs/io.js/pull/244 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
* src: mark virtual functions with override keywordBen Noordhuis2014-10-231-1/+1
| | | | | | Add `override` keywords where appropriate. Makes maintenance easier because the compiler will shout at you when a base class changes in an incompatible way.
* src: replace NULL with nullptrBen Noordhuis2014-10-231-2/+2
| | | | | | | | | | Now that we are building with C++11 features enabled, replace use of NULL with nullptr. The benefit of using nullptr is that it can never be confused for an integral type because it does not support implicit conversions to integral types except boolean - unlike NULL, which is defined as a literal `0`.
* src: attach env directly to api functionsBen Noordhuis2014-10-131-5/+5
| | | | | | | | | | | | | | | | | Attach the per-context execution environment directly to API functions. Rationale: * Gets node one step closer to multi-isolate readiness. * Avoids multi-context confusion, e.g. when the caller and callee live in different contexts. * Avoids expensive calls to pthread_getspecific() on platforms where V8 does not know how to use the thread-local storage directly. (Linux, the BSDs.) PR-URL: https://github.com/node-forward/node/pull/18 Reviewed-By: Fedor Indutny <fedor@indutny.com>
* src: replace assert() with CHECK()Ben Noordhuis2014-10-121-4/+4
| | | | | | | | | | | Mechanically replace assert() statements with UNREACHABLE(), CHECK(), or CHECK_{EQ,NE,LT,GT,LE,GE}() statements. The exceptions are src/node.h and src/node_object_wrap.h because they are public headers. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
* src: remove unnecessary HandleScopesBen Noordhuis2014-10-121-5/+0
| | | | | | | | API callback functions don't need to create a v8::HandleScope instance because V8 already creates one in the JS->C++ adapter frame. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
* Merge remote-tracking branch 'upstream/v0.10'Timothy J Fontaine2014-06-101-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: AUTHORS ChangeLog deps/v8/src/api.cc deps/v8/src/unicode-inl.h deps/v8/src/unicode.h lib/_stream_readable.js lib/http.js src/cares_wrap.cc src/node.cc src/node_crypto.cc src/node_dtrace.cc src/node_file.cc src/node_stat_watcher.cc src/node_version.h src/process_wrap.cc src/string_bytes.cc src/string_bytes.h src/udp_wrap.cc src/util.h test/simple/test-buffer.js test/simple/test-stream2-compatibility.js
| * src: replace usage of String::Utf8ValueTimothy J Fontaine2014-06-061-1/+2
| | | | | | | | | | v8::String::Utf8Value previously could allow invalid surrogates when interpreting values.
* | node: add signature to SET_PROTOTYPE_METHODC. Scott Ananian2014-04-021-2/+2
| | | | | | | | | | | | | | | | | | | | This prevents segfaults when a native method is reassigned to a different object (which corrupts args.This()). When unwrapping, clients should use args.Holder() instead of args.This(). Closes #6690. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
* | src: update to v8 3.24 APIsFedor Indutny2014-03-131-2/+2
| |
* | src: remove `node_isolate` from sourceFedor Indutny2014-02-221-9/+13
| | | | | | | | fix #6899
* | async_wrap: add provider types/pass to constructorTrevor Norris2014-02-051-1/+4
| | | | | | | | | | | | | | These will be used to allow users to filter for which types of calls they wish their callbacks to run. Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
* | node: register modules from DSO constructorsKeith M Wesolowski2014-01-271-1/+1
| | | | | | | | | | | | | | Built-in modules should be automatically registered, replacing the static module list. Add-on modules should also be automatically registered via DSO constructors. This improves flexibility in adding built-in modules and is also a prerequisite to pure-C addon modules.
* | src: fix Context::Scope usageBen Noordhuis2013-11-121-1/+1
| | | | | | | | | | env->context() may or may not create a new Local. It currently does not but don't depend on that behavior, create a HandleScope first.
* | src: fix Environment::GetCurrent() usageBen Noordhuis2013-11-111-3/+1
| | | | | | | | | | | | Create a HandleScope before calling the Environment::GetCurrent() that takes a v8::Isolate* as an argument because it creates a handle with the call to v8::Isolate::CurrentContext().
* | fs: make fs.watch() non-recursive by defaultBen Noordhuis2013-11-051-2/+2
| | | | | | | | Fixes a behavioral regression introduced in commit 691b9eb.
* | node: add AsyncListener supportTrevor Norris2013-10-311-5/+3
| | | | | | | | | | | | | | | | | | AsyncListener is a JS API that works in tandem with the AsyncWrap class to allow the user to be alerted to key events in the life cycle of an asynchronous event. The AsyncWrap class has its own MakeCallback implementation that core will be migrated to use, and uses state sharing techniques to allow quicker communication between JS and C++ whether the async event callbacks need to be called.
* | fs: add recursive subdirectory support to fs.watchNick Simmons2013-10-311-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently fs.watch does not have an option to specify if a directory should be recursively watched for events across all subdirectories. Several file watcher APIs support this. FSEvents on OS X > 10.5 is one example. libuv has added support for FSEvents, but fs.watch had no way to specify that a recursive watch was required. fs.watch now has an additional boolean option 'recursive'. When set to true, and when supported, fs.watch will return notifications for the entire directory tree hierarchy rooted at the specified path.
* | fs_event_wrap: update to new libuv apiTimothy J Fontaine2013-10-291-9/+13
| |
* | src: shorten Object{Wrap,Unwrap}Trevor Norris2013-10-291-2/+2
| | | | | | | | | | | | Going back to the original names of Wrap/Unwrap now that most all the class members that duplicate the name and functionality have been removed.
* | src: use function to get internal pointerTrevor Norris2013-10-291-4/+4
| | | | | | | | Remove the NODE_{WRAP,UNWRAP} macros and instead use template functions.
* | cpplint: disallow if one-linersFedor Indutny2013-10-171-1/+2
| |
* | src: add multi-context supportBen Noordhuis2013-09-061-27/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit makes it possible to use multiple V8 execution contexts within a single event loop. Put another way, handle and request wrap objects now "remember" the context they belong to and switch back to that context when the time comes to call into JS land. This could have been done in a quick and hacky way by calling v8::Object::GetCreationContext() on the wrap object right before making a callback but that leaves a fairly wide margin for bugs. Instead, we make the context explicit through a new Environment class that encapsulates everything (or almost everything) that belongs to the context. Variables that used to be a static or a global are now members of the aforementioned class. An additional benefit is that this approach should make it relatively straightforward to add full isolate support in due course. There is no JavaScript API yet but that will be added in the near future. This work was graciously sponsored by GitHub, Inc.
* | src: fix build break from generic macro nameTrevor Norris2013-08-121-2/+2
| | | | | | | | | | WRAP is too generic a macro name and causes the build to fail from conflicts. They have been prepended with NODE_.
* | src: centralize class wrap/unwrapTrevor Norris2013-08-121-8/+4
| | | | | | | | | | While almost all cases were handled by simple WRAP/UNWRAP macros, this extends those to cover all known occurrences.
* | src: use v8::String::NewFrom*() functionsBen Noordhuis2013-08-091-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change calls to String::New() and String::NewSymbol() to their respective one-byte, two-byte and UTF-8 counterparts. * Add a FIXED_ONE_BYTE_STRING macro that takes a string literal and turns it into a v8::Local<v8::String>. * Add helper functions that make v8::String::NewFromOneByte() easier to work with. Said function expects a `const uint8_t*` but almost every call site deals with `const char*` or `const unsigned char*`. Helps us avoid doing reinterpret_casts all over the place. * Code that handles file system paths keeps using UTF-8 for backwards compatibility reasons. At least now the use of UTF-8 is explicit. * Remove v8::String::NewSymbol() entirely. Almost all call sites were effectively minor de-optimizations. If you create a string only once, there is no point in making it a symbol. If you are create the same string repeatedly, it should probably be cached in a persistent handle.
* | src: remove no-op HandleWrap::Initialize()Ben Noordhuis2013-08-071-2/+0
| | | | | | | | It's never been used and we probably never will. Remove it.
* | src: lint c++ codeFedor Indutny2013-07-311-11/+7
| |
* | src, lib: update after internal api changeBen Noordhuis2013-07-201-6/+7
| | | | | | | | | | | | | | | | Libuv now returns errors directly. Make everything in src/ and lib/ follow suit. The changes to lib/ are not strictly necessary but they remove the need for the abominations that are process._errno and node::SetErrno().
* | lib, src: upgrade after v8 api changeBen Noordhuis2013-07-061-29/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a big commit that touches just about every file in the src/ directory. The V8 API has changed in significant ways. The most important changes are: * Binding functions take a const v8::FunctionCallbackInfo<T>& argument rather than a const v8::Arguments& argument. * Binding functions return void rather than v8::Handle<v8::Value>. The return value is returned with the args.GetReturnValue().Set() family of functions. * v8::Persistent<T> no longer derives from v8::Handle<T> and no longer allows you to directly dereference the object that the persistent handle points to. This means that the common pattern of caching oft-used JS values in a persistent handle no longer quite works, you first need to reconstruct a v8::Local<T> from the persistent handle with the Local<T>::New(isolate, persistent) factory method. A handful of (internal) convenience classes and functions have been added to make dealing with the new API a little easier. The most visible one is node::Cached<T>, which wraps a v8::Persistent<T> with some template sugar. It can hold arbitrary types but so far it's exclusively used for v8::Strings (which was by far the most commonly cached handle type.)
* | src: simplify HandleWrap initializationBen Noordhuis2013-05-301-1/+0
| |
* | src: replace c-style casts with c++-style castsBen Noordhuis2013-05-301-2/+2
| |
* | fs_event: use cached Persistent syms insteadTrevor Norris2013-05-161-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of String::New every time, use a Persistent sym. This can be accomplished in two ways: 1) Local<String> str = *persistent_str_sym; 2) Handle<String> str = persistent_str_sym; I've chosen to use the latter method for simplicity's sake. Other small changes include creating syms on Initialize and removing unnecessary Local casting on return values.
* | src: replace Holder() with This()Trevor Norris2013-04-191-3/+3
| | | | | | | | Switch to always use args.This() to retrieve object instance.
* | src: pass Isolate to all applicable apiTrevor Norris2013-03-201-10/+10
| | | | | | | | | | | | Update the api to pass node_isolate to all supported methods. Much thanks to Ben Noordhuis and his work in 51f6e6a.
* | bindings: update apiTrevor Norris2013-03-201-2/+3
|/ | | | | | | | | | | | | | | | | | | | | All compile time warnings about using deprecated APIs have been suppressed by updating node's API. Though there are still many function calls that can accept Isolate, and still need to be updated. node_isolate had to be added as an extern variable in node.h and node_object_wrap.h Also a couple small fixes for Error handling. Before v8 3.16.6 the error stack message was lazily written when it was needed, which allowed you to change the message after instantiation. Then the stack would be written with the new message the first time it was accessed. Though that has changed. Now it creates the stack message on instantiation. So setting a different message afterwards won't be displayed. This is not a complete fix for the problem. Getting error without any message isn't very useful.