Opened 17 years ago

Closed 12 years ago

#590 closed Feature Requests (fixed)

mkstemp

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
boost::filesystem?

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

jesus.malo@bsc.es

Change History (6)

comment:1 by Dave Abrahams, 15 years ago

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

Can't reassign to Beman until he logs into Trac at http://svn.boost.org and sets his email address.

comment:2 by Eric Niebler, 15 years ago

Owner: changed from nobody to Beman Dawes
Status: assignednew

comment:3 by Beman Dawes, 14 years ago

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.

--Beman

comment:4 by Beman Dawes, 13 years ago

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!

--Beman

comment:5 by Andrey Semashev, 13 years ago

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 by Beman Dawes, 12 years ago

Resolution: Nonefixed
Status: assignedclosed

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

Thanks,

--Beman

Note: See TracTickets for help on using tickets.