[英]How to port stlport ifstream(HANDLE) to MS stl ifstream?
I'm currently porting code from stlport 5.1.3 to stl with MSVS 2010. I'm facing a problem and I hope someone can help me. 我目前正在将代码从stlport 5.1.3移植到带有MSVS 2010的stl。我遇到了问题,希望有人能为我提供帮助。
Somewhere in the code is: 代码中的某处是:
HANDLE lHandle = CreateFileW(...);
ifstream lStream( lHandle );
// more job here...
This builds with stlport because the basic_ifstream has a cTor that takes a void*. 这是用stlport构建的,因为basic_ifstream的cTor需要一个void *。 But standard stl doesn't.
但是标准的stl没有。 I should write something like:
我应该写这样的东西:
ifstream lStream( /*FileName*/ );
...but my file name is a wchar_t *. ...但是我的文件名是wchar_t *。 ifstream cTor only takes char *...
ifstream cTor仅使用char * ...
Do you know a work around? 您知道周围有什么工作吗?
Thanks in advance, 提前致谢,
Dominique 多米尼克
Well, it seems that stl included in MSVC2010 provides all the stuff I needed but it was not in the doc. 好吧,似乎MSVC2010中包含的stl提供了我需要的所有内容,但未包含在文档中。
CreateFile was use because the former std::fstream could not handle wide char file name. 之所以使用CreateFile是因为以前的std :: fstream无法处理宽字符文件名。 Now, it has a cTor and a open() member for that.
现在,它具有一个cTor和一个open()成员。
Also, the new flavor of ifstream allows the programmer to set a sharing protection mode. 另外,ifstream的新风格允许程序员设置共享保护模式。 I needed that also and it was done by CreateFile...
我也需要它,它是由CreateFile完成的...
Thus, the "new" stl give me all the power I needed. 因此,“新” stl给了我所需的全部力量。 Just a little flaw in the doc.
只是文档中的一个小缺陷。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.