⚡ fonksiyon

truncate

fonksiyon truncate

Truncate file to specified size.

Dosyayı belirtilen boyuta kırp.

Parameters / Parametreler

  • file: The file handle (must be writable) / Dosya handle'ı (yazılabilir olmalı)
  • size: New size in bytes / Yeni boyut byte cinsinden

Returns / Dönüş Değeri

Returns Ok(empty) on success, or error. Başarıda Tamam(boş) döner, veya hata.

Example / Örnek

değişken f = io.open("large.log", "Write")?
io.truncate(f, 1024)?  // Shrink to 1KB
// File position may change, use seek if needed

Performance / Performans

O(1) - System call to set file size. O(1) - Dosya boyutunu ayarlamak için sistem çağrısı.

📍 Kaynak Kodu

Satır 0