www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - append - too many files

reply Joel <joelcnz gmail.com> writes:
I get this error after a while (seems append doesn't close the 
file each time):
std.file.FileException std/file.d(836): history.txt: Too many 
open files

```d
auto jm_addToHistory(T...)(T args) {
	import std.conv : text;
	import std.file : append;

	auto txt = text(args);
	append("history.txt", txt);

	return txt;
}
```
Jan 10 2023
next sibling parent "H. S. Teoh" <hsteoh qfbox.info> writes:
On Wed, Jan 11, 2023 at 02:15:13AM +0000, Joel via Digitalmars-d-learn wrote:
 I get this error after a while (seems append doesn't close the file
 each time):
 std.file.FileException std/file.d(836): history.txt: Too many open files
 
 ```d
 auto jm_addToHistory(T...)(T args) {
 	import std.conv : text;
 	import std.file : append;
 
 	auto txt = text(args);
 	append("history.txt", txt);
 
 	return txt;
 }
 ```
This is a bug, please file an issue in mantis. Phobos functions should not leak file descriptors. T -- "No, John. I want formats that are actually useful, rather than over-featured megaliths that address all questions by piling on ridiculous internal links in forms which are hideously over-complex." -- Simon St. Laurent on xml-dev
Jan 10 2023
prev sibling parent reply Salih Dincer <salihdb hotmail.com> writes:
On Wednesday, 11 January 2023 at 02:15:13 UTC, Joel wrote:
 I get this error after a while (seems append doesn't close the 
 file each time):
There is no error in the function or Phobos. There may be another error on your system or depending on how you use it. Could it be that more than one program tried to open the same file? How do you use this function? SDB 79
Jan 10 2023
parent Joel <joelcnz gmail.com> writes:
On Wednesday, 11 January 2023 at 06:00:26 UTC, Salih Dincer wrote:
 On Wednesday, 11 January 2023 at 02:15:13 UTC, Joel wrote:
 I get this error after a while (seems append doesn't close the 
 file each time):
There is no error in the function or Phobos. There may be another error on your system or depending on how you use it. Could it be that more than one program tried to open the same file? How do you use this function? SDB 79
I kinda have an update function that gets the update text, it writes it to the terminal, to a text file and returns the text (for like display on screen). Oh, looking at my code now, I was looking at the wrong function. Not to do with append. Sorry, forget about it.
Jan 10 2023