Brian R. Bondy
Brian R. Bondy

Reputation: 347406

How can I set the flag FILE_FLAG_BACKUP_SEMANTICS for an fstream object?

How can I set the flag FILE_FLAG_BACKUP_SEMANTICS for an fstream object?

You can set most flags with fstream, but it seems like this one is not availble. You can read about the flag here.

Upvotes: 2

Views: 837

Answers (1)

Tony Lee
Tony Lee

Reputation: 5632

I've done this sort thing in the past but it's been a while so I'm not sure I have it right.

Not well documented, but in vs2008, fstream takes a FILE object as a constructor. You can create a FILE object from a file id with _fdopen(). You can get a file id from an os handle using _open_osfhandle.

So I think it's like:

int id = _open_osfhandle(CreateFile(..., FILE_FLAG_BACKUP_SEMANTICS...));
fstream f = new fstream(_fdopen(id));

Upvotes: 1

Related Questions