检查文件中是否存在带有通配符的文件 [英] check if file exists with wildcards in filename
问题描述
我需要为c ++:
if(fileExists(c:\foo\bar * .txt )){
cout<< 文件已存在;
} else {
cout<< file does not exist;
}
它与这里描述的几乎相同:如何检查文件是否在Java中有通配符?,但是对于c ++
由于您没有指定平台,因此有几个选项。对于POSIX兼容系统,有此解决方案的答案(信用他不是我的):
您可以使用[
glob()
] [1 ] POSIX库函数。
或者对于窗口有 链接到 我无法保证 或者对于一个简单的跨平台库,您可以尝试 shwild 或 wildcmp ,或使用此问题的答案自行编写。 / p> What i Need for c++: Its nearly the same as descripted here: How to check a file if exists with wildcard in Java? , but for c++ Since you haven't specified a platform there are a few options. For POSIX compliant systems there is the answer from this solution (credit his not mine): You can use the [ alternatively for windows there is this solution: Link with I can't vouch for how well it does it though. Or for a simple cross platform library you could try shwild or wildcmp or write your own with the answer to this question. 这篇关于检查文件中是否存在带有通配符的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
setargv。 obj
(或 wsetargv.obj
)和argv []将会为你类似于Unix shell的做法:
if( fileExists("c:\foo\bar*.txt") ){
cout << "file exists";
}else{
cout << "file does not exists";
}
glob()
][1] POSIX library function.
setargv.obj
(or wsetargv.obj
) and argv[] will be globbed for you similar to how the Unix shells do it: