简体   繁体   中英

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 .

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));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM