Truncate a file: Difference between revisions

Content added Content deleted
m (promoted to task)
(Haskell information)
Line 109: Line 109:


When specifying a new file size larger than current value, the file will be extended and padded with null bytes.
When specifying a new file size larger than current value, the file will be extended and padded with null bytes.

=={{header|Haskell}}==
This can be achieved by using the <code>setFileSize</code> function in [http://hackage.haskell.org/packages/archive/unix-compat/0.1.2.1/doc/html/System-PosixCompat-Files.html#13 System.PosixCompat.Files]:

<lang Haskell>setFileSize :: FilePath -> FileOffset -> IO ()
-- Truncates the file down to the specified length.
-- If the file was larger than the given length
-- before this operation was performed the extra is lost.
-- Note: calls truncate.
</lang>


==Icon and {{header|Unicon}}==
==Icon and {{header|Unicon}}==