This is now mainly for history reason.

(cherry picked from commit babfb5261dd827564a273ba4f855de702eecc983)
This commit is contained in:
Cheng Zhao 2015-06-10 13:55:04 +08:00 коммит произвёл Aleksei Kuzmin
Родитель bac51bfc75
Коммит 71f8f8aa22
2 изменённых файлов: 54 добавлений и 0 удалений

Просмотреть файл

@ -937,6 +937,12 @@ fs.lstatSync = function(path) {
return getStatsFromBinding(stats); return getStatsFromBinding(stats);
}; };
fs.lstatSyncNoException = function(path) {
nullCheck(path);
var stats = binding.lstatNoException(pathModule._makeLong(path));
return stats !== false ? statsFromValues() : stats;
};
fs.statSync = function(path) { fs.statSync = function(path) {
path = getPathFromURL(path); path = getPathFromURL(path);
validatePath(path); validatePath(path);
@ -947,6 +953,12 @@ fs.statSync = function(path) {
return getStatsFromBinding(stats); return getStatsFromBinding(stats);
}; };
fs.statSyncNoException = function(path) {
nullCheck(path);
var stats = binding.statNoException(pathModule._makeLong(path));
return stats !== false ? statsFromValues() : stats;
};
fs.readlink = function(path, options, callback) { fs.readlink = function(path, options, callback) {
callback = makeCallback(typeof options === 'function' ? options : callback); callback = makeCallback(typeof options === 'function' ? options : callback);
options = getOptions(options, {}); options = getOptions(options, {});

Просмотреть файл

@ -845,6 +845,26 @@ static void Stat(const FunctionCallbackInfo<Value>& args) {
} }
} }
static void StatNoException(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());
if (args.Length() < 1 || !args[0]->IsString()) {
args.GetReturnValue().Set(v8::Boolean::New(env->isolate(), false));
return;
}
String::Utf8Value path(args[0]);
FSReqWrapSync req_wrap;
int result = uv_fs_stat(uv_default_loop(), &req_wrap.req, *path, NULL);
if (result < 0)
args.GetReturnValue().Set(v8::Boolean::New(env->isolate(), false));
else
FillStatsArray(env->fs_stats_field_array(),
static_cast<const uv_stat_t*>(req_wrap.req.ptr));
}
static void LStat(const FunctionCallbackInfo<Value>& args) { static void LStat(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args); Environment* env = Environment::GetCurrent(args);
@ -875,6 +895,26 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
} }
} }
static void LStatNoException(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());
String::Utf8Value path(args[0]);
if (args.Length() < 1 || !args[0]->IsString()) {
args.GetReturnValue().Set(v8::Boolean::New(env->isolate(), false));
return;
}
FSReqWrapSync req_wrap;
int result = uv_fs_lstat(uv_default_loop(), &req_wrap.req, *path, NULL);
if (result < 0)
args.GetReturnValue().Set(v8::Boolean::New(env->isolate(), false));
else
FillStatsArray(env->fs_stats_field_array(),
static_cast<const uv_stat_t*>(req_wrap.req.ptr));
}
static void FStat(const FunctionCallbackInfo<Value>& args) { static void FStat(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args); Environment* env = Environment::GetCurrent(args);
@ -1877,7 +1917,9 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "internalModuleReadJSON", InternalModuleReadJSON); env->SetMethod(target, "internalModuleReadJSON", InternalModuleReadJSON);
env->SetMethod(target, "internalModuleStat", InternalModuleStat); env->SetMethod(target, "internalModuleStat", InternalModuleStat);
env->SetMethod(target, "stat", Stat); env->SetMethod(target, "stat", Stat);
env->SetMethod(target, "statNoException", StatNoException);
env->SetMethod(target, "lstat", LStat); env->SetMethod(target, "lstat", LStat);
env->SetMethod(target, "lstatNoException", LStatNoException);
env->SetMethod(target, "fstat", FStat); env->SetMethod(target, "fstat", FStat);
env->SetMethod(target, "link", Link); env->SetMethod(target, "link", Link);
env->SetMethod(target, "symlink", Symlink); env->SetMethod(target, "symlink", Symlink);