Missing ftruncate

Krasimir Angelov ka2_mail at yahoo.com
Tue Jan 4 12:51:19 EST 2005


--- Simon Marlow <simonmar at microsoft.com> wrote:
> I seem to recall
> there was a proposal to add hSetFileSize at one
> point... ah yes:
> 
>
http://www.haskell.org/pipermail/haskell/2002-January/008677.html
> 
> unfortunately we never followed up on that promise
> :-)  Looks like it
> shouldn't be too hard - on Windows there's no
> truncate(), but there is
> SetEndOfFile() instead.

 Under Windows there is also _chsize function from
MSVCRT. It is easy to define hSetFileSize function.

 I also would like to have some functions for creation
of temporary files. My proposal is:

openTempFile :: FilePath 
             -> String 
             -> IO (FilePath, Handle)
openBinaryTempFile :: ...

The first argument is the directory where to create
the file and the second argument is the file name
template. The template is something like "foo.bar"
with this template the name of the created file will
be fooXXX.bar where XXX is some random number. The
function should create immediatelly the file in order
to prevent other processes to create a file with the
same name. The returned path is the complete path to
the created file and the handle is the handle to the
created file.

Cheers,
  Krasimir



		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 


More information about the Libraries mailing list