OxL Справочник OxL
РусскийEnglish

method File.rename

Renames or moves (atomic within one file system; an existing destination file is replaced).

Example:

oxl✓ проверяется в CI
use std.io { File, fs }

fn main() io {
  let dir = fs.tempDir()!
  File.writeText("{dir}/a", "1")!
  File.rename("{dir}/a", "{dir}/b")!
  print("{File.exists("{dir}/a")} {File.exists("{dir}/b")}")
  fs.removeAll(dir)!
}
Вывод
false true
pub(api) static fn rename(from: str, to: str) -> () | IoError  io

С версии. 1.0.0-beta

Параметры

ИмяТип
fromstr
tostr

Возвращает

()

Ошибки

Эффекты

io

Определено в: std/io/io.oxl:437

См. также