summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/js/file_info.ts6
-rw-r--r--cli/js/lib.deno.ns.d.ts12
-rw-r--r--cli/js/ops/fs/stat.ts2
-rw-r--r--cli/js/tests/files_test.ts16
-rw-r--r--cli/ops/fs.rs4
5 files changed, 18 insertions, 22 deletions
diff --git a/cli/js/file_info.ts b/cli/js/file_info.ts
index e7ac646fb..827239769 100644
--- a/cli/js/file_info.ts
+++ b/cli/js/file_info.ts
@@ -3,7 +3,7 @@ import { StatResponse } from "./ops/fs/stat.ts";
import { build } from "./build.ts";
export interface FileInfo {
- len: number;
+ size: number;
modified: number | null;
accessed: number | null;
created: number | null;
@@ -26,7 +26,7 @@ export interface FileInfo {
export class FileInfoImpl implements FileInfo {
private readonly _isFile: boolean;
private readonly _isSymlink: boolean;
- len: number;
+ size: number;
modified: number | null;
accessed: number | null;
created: number | null;
@@ -64,7 +64,7 @@ export class FileInfoImpl implements FileInfo {
this._isFile = this._res.isFile;
this._isSymlink = this._res.isSymlink;
- this.len = this._res.len;
+ this.size = this._res.size;
this.modified = modified ? modified : null;
this.accessed = accessed ? accessed : null;
this.created = created ? created : null;
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index 751e4452b..daae8b09d 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -661,7 +661,7 @@ declare namespace Deno {
append?: boolean;
/** Sets the option for truncating a previous file. If a file is
* successfully opened with this option set it will truncate the file to `0`
- * length if it already exists. The file must be opened with write access
+ * size if it already exists. The file must be opened with write access
* for truncate to work. */
truncate?: boolean;
/** Sets the option to allow creating a new file, if one doesn't already
@@ -1058,16 +1058,12 @@ declare namespace Deno {
// @url js/file_info.d.ts
- /** UNSTABLE: 'len' maybe should be 'length' or 'size'.
- *
- * A FileInfo describes a file and is returned by `stat`, `lstat`,
+ /** A FileInfo describes a file and is returned by `stat`, `lstat`,
* `statSync`, `lstatSync`. A list of FileInfo is returned by `readdir`,
* `readdirSync`. */
export interface FileInfo {
- /** **UNSTABLE**: `.len` maybe should be `.length` or `.size`.
- *
- * The size of the file, in bytes. */
- len: number;
+ /** The size of the file, in bytes. */
+ size: number;
/** The last modification time of the file. This corresponds to the `mtime`
* field from `stat` on Linux/Mac OS and `ftLastWriteTime` on Windows. This
* may not be available on all platforms. */
diff --git a/cli/js/ops/fs/stat.ts b/cli/js/ops/fs/stat.ts
index 032cc97ee..20ca3e6b1 100644
--- a/cli/js/ops/fs/stat.ts
+++ b/cli/js/ops/fs/stat.ts
@@ -5,7 +5,7 @@ import { FileInfo, FileInfoImpl } from "../../file_info.ts";
export interface StatResponse {
isFile: boolean;
isSymlink: boolean;
- len: number;
+ size: number;
modified: number;
accessed: number;
created: number;
diff --git a/cli/js/tests/files_test.ts b/cli/js/tests/files_test.ts
index 49fecabe0..29e2812d4 100644
--- a/cli/js/tests/files_test.ts
+++ b/cli/js/tests/files_test.ts
@@ -19,7 +19,7 @@ unitTest({ perms: { read: true } }, async function filesCopyToStdout(): Promise<
const file = await Deno.open(filename);
assert(file.rid > 2);
const bytesWritten = await Deno.copy(Deno.stdout, file);
- const fileSize = Deno.statSync(filename).len;
+ const fileSize = Deno.statSync(filename).size;
assertEquals(bytesWritten, fileSize);
console.log("bytes written", bytesWritten);
file.close();
@@ -234,12 +234,12 @@ unitTest(
const f = await Deno.create(filename);
let fileInfo = Deno.statSync(filename);
assert(fileInfo.isFile());
- assert(fileInfo.len === 0);
+ assert(fileInfo.size === 0);
const enc = new TextEncoder();
const data = enc.encode("Hello");
await f.write(data);
fileInfo = Deno.statSync(filename);
- assert(fileInfo.len === 5);
+ assert(fileInfo.size === 5);
f.close();
// TODO: test different modes
@@ -258,11 +258,11 @@ unitTest(
// assert file was created
let fileInfo = Deno.statSync(filename);
assert(fileInfo.isFile());
- assertEquals(fileInfo.len, 0);
+ assertEquals(fileInfo.size, 0);
// write some data
await file.write(data);
fileInfo = Deno.statSync(filename);
- assertEquals(fileInfo.len, 13);
+ assertEquals(fileInfo.size, 13);
// assert we can't read from file
let thrown = false;
try {
@@ -277,7 +277,7 @@ unitTest(
// assert that existing file is truncated on open
file = await Deno.open(filename, "w");
file.close();
- const fileSize = Deno.statSync(filename).len;
+ const fileSize = Deno.statSync(filename).size;
assertEquals(fileSize, 0);
await Deno.remove(tempDir, { recursive: true });
}
@@ -296,11 +296,11 @@ unitTest(
// assert file was created
let fileInfo = Deno.statSync(filename);
assert(fileInfo.isFile());
- assertEquals(fileInfo.len, 0);
+ assertEquals(fileInfo.size, 0);
// write some data
await file.write(data);
fileInfo = Deno.statSync(filename);
- assertEquals(fileInfo.len, 13);
+ assertEquals(fileInfo.size, 13);
const buf = new Uint8Array(20);
// seeking from beginning of a file
diff --git a/cli/ops/fs.rs b/cli/ops/fs.rs
index 01ce548ba..6c978d51c 100644
--- a/cli/ops/fs.rs
+++ b/cli/ops/fs.rs
@@ -431,7 +431,7 @@ fn op_copy_file(
return Err(OpError::not_found("File not found".to_string()));
}
- // returns length of from as u64 (we ignore)
+ // returns size of from as u64 (we ignore)
fs::copy(&from, &to)?;
Ok(json!({}))
})
@@ -469,7 +469,7 @@ fn get_stat_json(
let mut json_val = json!({
"isFile": metadata.is_file(),
"isSymlink": metadata.file_type().is_symlink(),
- "len": metadata.len(),
+ "size": metadata.len(),
// In seconds. Available on both Unix or Windows.
"modified":to_seconds!(metadata.modified()),
"accessed":to_seconds!(metadata.accessed()),