简体   繁体   English

检查文件是否在磁盘wchar_t上的C ++方法

[英]C++ method to check if a File is on Disk wchar_t

I wanted a means of checking is a file exists on the disk based on wchar_t * path. 我想要一种检查方法是基于wchar_t *路径的磁盘上是否存在文件。 A ready to use method is available on SO but for char * path. 可以在SO上使用一种现成的方法,但用于char * path。 Is there a variant for wchar_t * without using boost. wchar_t *是否有不使用boost的变体。

Loot at this example: 在此示例中抢劫:

#include <fstream>
#include <string>

bool check_if_file_exists(std::wstring path)
{
    std::ifstream ff(path.c_str());
    return ff.is_open();
}

But this is windows only, since std::ifstream(wchar_t*) is MSVC extension. 但这仅是Windows,因为std :: ifstream(wchar_t *)是MSVC扩展名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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