mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 12:49:10 +00:00
Remove FileInfo.path
This commit is contained in:
parent
7d25c559fc
commit
e02d8bcf18
4 changed files with 1 additions and 20 deletions
|
@ -435,7 +435,6 @@ table StatRes {
|
||||||
mode: uint;
|
mode: uint;
|
||||||
has_mode: bool; // false on windows
|
has_mode: bool; // false on windows
|
||||||
name: string;
|
name: string;
|
||||||
path: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
table Truncate {
|
table Truncate {
|
||||||
|
|
|
@ -1284,8 +1284,6 @@ fn op_stat(
|
||||||
fs::metadata(&filename)?
|
fs::metadata(&filename)?
|
||||||
};
|
};
|
||||||
|
|
||||||
let filename_str = builder.create_string(&filename_);
|
|
||||||
|
|
||||||
let inner = msg::StatRes::create(
|
let inner = msg::StatRes::create(
|
||||||
builder,
|
builder,
|
||||||
&msg::StatResArgs {
|
&msg::StatResArgs {
|
||||||
|
@ -1297,7 +1295,6 @@ fn op_stat(
|
||||||
created: to_seconds!(metadata.created()),
|
created: to_seconds!(metadata.created()),
|
||||||
mode: get_mode(&metadata.permissions()),
|
mode: get_mode(&metadata.permissions()),
|
||||||
has_mode: cfg!(target_family = "unix"),
|
has_mode: cfg!(target_family = "unix"),
|
||||||
path: Some(filename_str),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1340,7 +1337,6 @@ fn op_read_dir(
|
||||||
let metadata = entry.metadata().unwrap();
|
let metadata = entry.metadata().unwrap();
|
||||||
let file_type = metadata.file_type();
|
let file_type = metadata.file_type();
|
||||||
let name = builder.create_string(entry.file_name().to_str().unwrap());
|
let name = builder.create_string(entry.file_name().to_str().unwrap());
|
||||||
let path = builder.create_string(entry.path().to_str().unwrap());
|
|
||||||
|
|
||||||
msg::StatRes::create(
|
msg::StatRes::create(
|
||||||
builder,
|
builder,
|
||||||
|
@ -1352,7 +1348,6 @@ fn op_read_dir(
|
||||||
accessed: to_seconds!(metadata.accessed()),
|
accessed: to_seconds!(metadata.accessed()),
|
||||||
created: to_seconds!(metadata.created()),
|
created: to_seconds!(metadata.created()),
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
path: Some(path),
|
|
||||||
mode: get_mode(&metadata.permissions()),
|
mode: get_mode(&metadata.permissions()),
|
||||||
has_mode: cfg!(target_family = "unix"),
|
has_mode: cfg!(target_family = "unix"),
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,12 +27,9 @@ export interface FileInfo {
|
||||||
*/
|
*/
|
||||||
mode: number | null;
|
mode: number | null;
|
||||||
|
|
||||||
/** Returns the file or directory name. */
|
/** The file or directory name. */
|
||||||
name: string | null;
|
name: string | null;
|
||||||
|
|
||||||
/** Returns the file or directory path. */
|
|
||||||
path: string | null;
|
|
||||||
|
|
||||||
/** Returns whether this is info for a regular file. This result is mutually
|
/** Returns whether this is info for a regular file. This result is mutually
|
||||||
* exclusive to `FileInfo.isDirectory` and `FileInfo.isSymlink`.
|
* exclusive to `FileInfo.isDirectory` and `FileInfo.isSymlink`.
|
||||||
*/
|
*/
|
||||||
|
@ -59,7 +56,6 @@ export class FileInfoImpl implements FileInfo {
|
||||||
created: number | null;
|
created: number | null;
|
||||||
mode: number | null;
|
mode: number | null;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
path: string | null;
|
|
||||||
|
|
||||||
/* @internal */
|
/* @internal */
|
||||||
constructor(private _inner: msg.StatRes) {
|
constructor(private _inner: msg.StatRes) {
|
||||||
|
@ -69,7 +65,6 @@ export class FileInfoImpl implements FileInfo {
|
||||||
const hasMode = this._inner.hasMode();
|
const hasMode = this._inner.hasMode();
|
||||||
const mode = this._inner.mode(); // negative for invalid mode (Windows)
|
const mode = this._inner.mode(); // negative for invalid mode (Windows)
|
||||||
const name = this._inner.name();
|
const name = this._inner.name();
|
||||||
const path = this._inner.path();
|
|
||||||
|
|
||||||
this._isFile = this._inner.isFile();
|
this._isFile = this._inner.isFile();
|
||||||
this._isSymlink = this._inner.isSymlink();
|
this._isSymlink = this._inner.isSymlink();
|
||||||
|
@ -80,7 +75,6 @@ export class FileInfoImpl implements FileInfo {
|
||||||
// null on Windows
|
// null on Windows
|
||||||
this.mode = hasMode ? mode : null;
|
this.mode = hasMode ? mode : null;
|
||||||
this.name = name ? name : null;
|
this.name = name ? name : null;
|
||||||
this.path = path ? path : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isFile(): boolean {
|
isFile(): boolean {
|
||||||
|
|
|
@ -3,8 +3,6 @@ import { testPerm, assert, assertEquals } from "./test_util.ts";
|
||||||
|
|
||||||
type FileInfo = Deno.FileInfo;
|
type FileInfo = Deno.FileInfo;
|
||||||
|
|
||||||
const isWin = Deno.build.os === "win";
|
|
||||||
|
|
||||||
function assertSameContent(files: FileInfo[]): void {
|
function assertSameContent(files: FileInfo[]): void {
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
|
@ -15,11 +13,6 @@ function assertSameContent(files: FileInfo[]): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.name === "002_hello.ts") {
|
if (file.name === "002_hello.ts") {
|
||||||
if (isWin) {
|
|
||||||
assert(file.path.endsWith(`tests\\${file.name}`));
|
|
||||||
} else {
|
|
||||||
assert(file.path.endsWith(`tests/${file.name}`));
|
|
||||||
}
|
|
||||||
assertEquals(file.mode!, Deno.statSync(`tests/${file.name}`).mode!);
|
assertEquals(file.mode!, Deno.statSync(`tests/${file.name}`).mode!);
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue