Opening files in O_TRUNC mode

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Opening files in O_TRUNC mode

Krishna Sai Veera Reddy
Is it possible to open files in O_TRUNC mode in erlang using the `file` module? If not, is this something we want added to the standard library?

Thanks,
Krishna

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Opening files in O_TRUNC mode

bengt e
Greetings,

file:open/2 documentation has this to say about Modes. Does it cover what you want to do?

write

The file is opened for writing. It is created if it does not exist. If the file exists and write is not combined with read, the file is truncated.

On 1 Oct 2018, at 05:24, Krishna Sai Veera Reddy <[hidden email]> wrote:

Is it possible to open files in O_TRUNC mode in erlang using the `file` module? If not, is this something we want added to the standard library?

Thanks,
Krishna
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Opening files in O_TRUNC mode

Krishna Sai Veera Reddy
In reply to this post by Krishna Sai Veera Reddy
Hello,

Opening file in `write` only mode seems to truncate the file but for whatever reason when `append` mode is also used the file doesn't truncate. Was this intentional?

Regards,
Krishna

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Opening files in O_TRUNC mode

bengt e
Speaking only for myself, and not even a native english speaker, I think that ‘append’ implies something that you want to put things after. If you truncate there is nothing to put things after. So one of them has to be ‘’wrong’’.
Maybe the person that wrote the software tossed a coin?


bengt

> On 1 Oct 2018, at 22:48, Krishna Sai Veera Reddy <[hidden email]> wrote:
>
> Hello,
>
> Opening file in `write` only mode seems to truncate the file but for whatever reason when `append` mode is also used the file doesn't truncate. Was this intentional?
>
> Regards,
> Krishna
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions