[英]How can I set the flag FILE_FLAG_BACKUP_SEMANTICS for an fstream object?
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. 没有充分的文档说明,但是在vs2008中,fstream将FILE对象用作构造函数。 You can create a FILE object from a file id with _fdopen().
您可以使用_fdopen()从文件ID创建FILE对象。 You can get a file id from an os handle using _open_osfhandle.
您可以使用_open_osfhandle从os句柄获取文件ID。
So I think it's like: 所以我认为这就像:
int id = _open_osfhandle(CreateFile(..., FILE_FLAG_BACKUP_SEMANTICS...));
fstream f = new fstream(_fdopen(id));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.