forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(node/fs): faster
existsSync
when not exists (denoland#21458)
- Loading branch information
Showing
7 changed files
with
93 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. | ||
|
||
use std::path::PathBuf; | ||
|
||
use deno_core::error::AnyError; | ||
use deno_core::op2; | ||
use deno_core::OpState; | ||
use deno_fs::FileSystemRc; | ||
|
||
use crate::NodePermissions; | ||
|
||
#[op2(fast)] | ||
pub fn op_node_fs_exists_sync<P>( | ||
state: &mut OpState, | ||
#[string] path: String, | ||
) -> Result<bool, AnyError> | ||
where | ||
P: NodePermissions + 'static, | ||
{ | ||
let path = PathBuf::from(path); | ||
state | ||
.borrow_mut::<P>() | ||
.check_read_with_api_name(&path, Some("node:fs.existsSync()"))?; | ||
let fs = state.borrow::<FileSystemRc>(); | ||
Ok(fs.lstat_sync(&path).is_ok()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters