Opened 13 years ago

Closed 9 years ago

#590 closed Feature Requests (fixed)


Reported by: nobody Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: None Severity: Not Applicable
Keywords: Cc: bdawes@…

Description (last modified by Dave Abrahams)

Could you add a function similar to mkstemp in

It would be interesting if it could receive an
boost::filesystem::path or an std::string as input and
return a ofstream and a path or a string as output

Change History (6)

comment:1 Changed 11 years ago by Dave Abrahams

Cc: bdawes@… added
Component: Nonefilesystem
Description: modified (diff)
Severity: Showstopper

Can't reassign to Beman until he logs into Trac at and sets his email address.

comment:2 Changed 11 years ago by Eric Niebler

Owner: changed from nobody to Beman Dawes
Status: assignednew

comment:3 Changed 10 years ago by Beman Dawes

Severity: ShowstopperNot Applicable

I'm considering #590 and #1090 as indications of interest and need, but feel that there are various details to be worked out first. mkstemp and similar functions seem pretty dated. The C++ approach suggested by #1090 is appealing, but more work needs to be done. Suggestions welcome.


comment:4 Changed 10 years ago by Beman Dawes

Milestone: To Be Determined
Status: newassigned

No progress yet. Needs a design that abstracts away differences between POSIX and Windows. Contributions and/or suggestions welcome!


comment:5 Changed 9 years ago by Andrey Semashev

Not sure if this applies to this ticket, but I've been in need of temp files support many times, too. So here are my thoughts.

Maybe, on the low level, such functionality could be reached through fstreams extension: if it was possible to construct fstream from FILE* then the tmpfile function could be used to create temporary files. On the higher level a wrapper function could be provided, such as:

void open_temp_file(fstream& strm);

The function would internally call tmpfile or whatever other API to create the file and attach it to the stream.

Scoped files, while they look appealing for some cases, are limiting when the lifetime of the stream has to span across scopes. A simple wrapper derived from the fstream and on top of open_temp_file can be provided, but it should not be the only way to do it.

comment:6 Changed 9 years ago by Beman Dawes

Resolution: Nonefixed
Status: assignedclosed

The unique_path() function in Version 3 addresses the problem. Version 3 will ship with 1.44.



Note: See TracTickets for help on using tickets.