CPacket listFiles(char *pDir, char *pRights) { CPacket retVal; CStringList files; struct stat fileStat; getSubFiles(pDir, files); for (int i = 0; i < files.count(); i++) { CPacket dir; CString fullName; fullName << pDir << files[i]; stat(fullName.text(), &fileStat); dir << (char)files[i].length() << files[i] << (char)strlen(pRights) << pRights << (long long)fileStat.st_size << (long long)fileStat.st_mtime; retVal << " " << (char)dir.length() << dir; } return retVal; }
////////////////////////////////////////////////////////////////////////// //get all files in the path //if need recursion, enter into sub folders void fileHandler::getFiles(std::string path, std::string& pattern) { std::vector<std::string> files = fh.getFileSpecs(path,pattern); std::string key; mapIterator it; packageInfo* pack; for (size_t i=0; i<files.size();i++) { key = getFileKeyName(files[i]); it = results.find(key); if (it == results.end()) { pack = new packageInfo(); pack->addFileName(files[i]); results[key] = pack; } else { it->second->addFileName(files[i]); } } if (needRecursion)getSubFiles(path,pattern); }