1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
vector<string> queuedFolders;
void DIR_GetFolders(string dir)
{
unsigned char isFolder = 0x4;
DIR * f;
struct dirent *folder;
char slova[dir.length() + 1]; // ============ String to char array, will this work ?
strcpy(slova, dir.c_str());
f = opendir(slova);
if (f != NULL)
{
while (folder = readdir(f))
{
if (folder->d_type == isFolder && strcmp(folder->d_name,".") && strcmp(folder->d_name,".."))
{
string a = "";
a += dir;
a += "/";
a += folder->d_name;
queuedFolders.push_back(a);
}
}
}
}
int main()
{
char* HOMEDIR = getenv("HOME");
char* CURFOLDER = HOMEDIR;
strcat(CURFOLDER,"/Downloads");
DIR_GetFolders(CURFOLDER);
for (vector<string>::iterator I = queuedFolders.begin() ; I != queuedFolders.end( ) ; I++ )
{
char slova[*I.length()+1]; //Here is error for this line: /home/igor/Documents/CodeBlocks/OOP/main.cpp|77|error: ‘class __gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >’ has no member named ‘length’|
strcpy(slova,*I.c_str); // /home/igor/Documents/CodeBlocks/OOP/main.cpp|78|error: ‘slova’ was not declared in this scope| + again the same error as for line above
DIR_GetFolders(slova);
}
return EXIT_SUCCESS;
}
|