- 论坛徽章:
- 0
|
当前目录是/test
在此目录下有目录/mydir以及文件test.cpp
截取如下:
int main(int argc, char* argv[])
{
if (argc < 2) {
cout << "usage: <src path> ..." << endl;
return -1;
}
string src_path = argv[1];
..........................................................................
int get_dir_files(const string& src_path,
vector<string>& src_files)
{
DIR *dp;
struct dirent *dentp;
struct stat buf;
string src_file;
dp = opendir(src_path.c_str());
if(dp == 0)
{
std::cout << "open dir " << src_path << " error..." << std::endl;
return -1;
}
...................................................
$CC -o mytest test.cpp
$ ./mytest mydir
编译后提示
open dir mydir error...
为什么总是打不开目录mydir???目录 /test/mydir是存在的,而且访问目录mydir的权限也有 |
|