Lars Gullik Bjønnes wrote:
>>> Is anybody unhappy with this change?
> 
> yes a bit.
> 
> | The following might be a minuscule problem:
>>
> | unlink() deletes the file right?
> | So if the temporary file was created in e.g. /tmp, theoretically
> | some other process might "steal" the name if it's been deleted?
> 
> Right. By deleting the file you are removing the point in using
> mkstemp.

Ok. Then I'll shelve the suggestion.

> also... is the correct solutoin to use fs::native or is fs::nocheck
> perhaps better?

I don't know what fs::nocheck does. Could you expand a little?


My understanding is that fs::path stores the file path internally in 
a 'generic' format. Anything manipulating fs::paths should therefore 
use this internal format. Eg, fs::path has no operator== or operator< 
so client code should be written:

        fs::path file1, file2;
        if (file1.string() == file2.string())...
        if (file1.string() < file2.string())...

However, when interacting with the 'outside world', we should use 
fs::path::native_file_string() as this is the format that the world 
outside expects:

        fs::path file;
        std::fstream os(file.native_string_file().c_str());

Yes I'm aware of fs::fstream. The above is exactly what the 
fs::fstream classes do:

      explicit basic_ofstream( const path & file_ph,
        std::ios_base::openmode mode = std::ios_base::out )
        : std::basic_ofstream<charT,traits>(
        file_ph.native_file_string().c_str(), mode ) {}



-- 
Angus

Reply via email to