Hi,
I'm working on a plugin which needs to check what files are in a project. I want to use cbproject::GetFilesCount but this returns an incorrect number. Someone knows why?
void ProjectAnalyzer::analyze(cbProject* pProject) {
if (!pProject) return;
Manager::Get()->GetLogManager()->Log(_T("Project title:" ) +pProject->GetTitle());
int files = pProject->GetFilesCount();
Manager::Get()->GetLogManager()->Log(_T("files count..") +wxString::Format(_T("%i"), pProject->GetFilesCount()));
Manager::Get()->GetLogManager()->Log(_T("files count..") +wxString::Format(_T("%i"), files));
ProjectFile* project_file = pProject->GetFile(0);
if (project_file != NULL) {
Manager::Get()->GetLogManager()->Log(_T("file 0: ") +project_file->GetBaseName());
}
}
roxlu
Quote from: roxlu on August 01, 2009, 08:12:34 PM
int files = pProject->GetFilesCount();
I suggest trying unsigned int and see if symptom change.
unsigned int files = pProject->GetFilesCount();
wow, didnt expect such a quick response! Thanks.
Though it didn't work. :(
update: Hmm, linking against svn build does not work, but agains 8.02 does work.
(both with and w/o the unsigned btw)
roxlu
If the project is valid it should work anyway.
cbProject::GetFileCount() returns an int, but as I just saw the internally used filelist (declared with WX_DECLARE_LIST) uses size_t as return-value (at least in wxWidgets 2.8.10), so it might lead to an error if you have really very, very much files in a project.
Nevertheless it works here (actual trunk), if I use project-managers GetActiveProject() to fetch a project, no difference if it is a small test-project (12 files ) or a larger one (linux-kernel as test-project with more than 21000 files).