Thread overview
append - too many files
Jan 11, 2023
Joel
Jan 11, 2023
H. S. Teoh
Jan 11, 2023
Salih Dincer
Jan 11, 2023
Joel
January 11, 2023

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

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

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

	return txt;
}
January 10, 2023
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
January 11, 2023

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

January 11, 2023

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.