mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
BREAKING(fs): remove Deno.ftruncate[Sync]()
(#25412)
Towards #22079 Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
parent
ac33fc2892
commit
3d36cbd056
9 changed files with 6 additions and 131 deletions
91
cli/tsc/dts/lib.deno.ns.d.ts
vendored
91
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -5193,97 +5193,6 @@ declare namespace Deno {
|
|||
options?: SymlinkOptions,
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Truncates or extends the specified file stream, to reach the specified
|
||||
* `len`.
|
||||
*
|
||||
* If `len` is not specified then the entire file contents are truncated as if
|
||||
* `len` was set to `0`.
|
||||
*
|
||||
* If the file previously was larger than this new length, the extra data is
|
||||
* lost.
|
||||
*
|
||||
* If the file previously was shorter, it is extended, and the extended part
|
||||
* reads as null bytes ('\0').
|
||||
*
|
||||
* ### Truncate the entire file
|
||||
*
|
||||
* ```ts
|
||||
* const file = await Deno.open(
|
||||
* "my_file.txt",
|
||||
* { read: true, write: true, create: true }
|
||||
* );
|
||||
* await Deno.ftruncate(file.rid);
|
||||
* ```
|
||||
*
|
||||
* ### Truncate part of the file
|
||||
*
|
||||
* ```ts
|
||||
* const file = await Deno.open(
|
||||
* "my_file.txt",
|
||||
* { read: true, write: true, create: true }
|
||||
* );
|
||||
* await file.write(new TextEncoder().encode("Hello World"));
|
||||
* await Deno.ftruncate(file.rid, 7);
|
||||
* const data = new Uint8Array(32);
|
||||
* await Deno.read(file.rid, data);
|
||||
* console.log(new TextDecoder().decode(data)); // Hello W
|
||||
* ```
|
||||
*
|
||||
* @deprecated This will be removed in Deno 2.0. See the
|
||||
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
|
||||
* for migration instructions.
|
||||
*
|
||||
* @category File System
|
||||
*/
|
||||
export function ftruncate(rid: number, len?: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Synchronously truncates or extends the specified file stream, to reach the
|
||||
* specified `len`.
|
||||
*
|
||||
* If `len` is not specified then the entire file contents are truncated as if
|
||||
* `len` was set to `0`.
|
||||
*
|
||||
* If the file previously was larger than this new length, the extra data is
|
||||
* lost.
|
||||
*
|
||||
* If the file previously was shorter, it is extended, and the extended part
|
||||
* reads as null bytes ('\0').
|
||||
*
|
||||
* ### Truncate the entire file
|
||||
*
|
||||
* ```ts
|
||||
* const file = Deno.openSync(
|
||||
* "my_file.txt",
|
||||
* { read: true, write: true, truncate: true, create: true }
|
||||
* );
|
||||
* Deno.ftruncateSync(file.rid);
|
||||
* ```
|
||||
*
|
||||
* ### Truncate part of the file
|
||||
*
|
||||
* ```ts
|
||||
* const file = Deno.openSync(
|
||||
* "my_file.txt",
|
||||
* { read: true, write: true, create: true }
|
||||
* );
|
||||
* file.writeSync(new TextEncoder().encode("Hello World"));
|
||||
* Deno.ftruncateSync(file.rid, 7);
|
||||
* Deno.seekSync(file.rid, 0, Deno.SeekMode.Start);
|
||||
* const data = new Uint8Array(32);
|
||||
* Deno.readSync(file.rid, data);
|
||||
* console.log(new TextDecoder().decode(data)); // Hello W
|
||||
* ```
|
||||
*
|
||||
* @deprecated This will be removed in Deno 2.0. See the
|
||||
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
|
||||
* for migration instructions.
|
||||
*
|
||||
* @category File System
|
||||
*/
|
||||
export function ftruncateSync(rid: number, len?: number): void;
|
||||
|
||||
/**
|
||||
* Synchronously changes the access (`atime`) and modification (`mtime`) times
|
||||
* of a file system object referenced by `path`. Given times are either in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue