Example #1
0
// Return all suffix-matched files in the directory 'dirpath'
bool
suffix_matched_files_in_dir(const char *dirpath, StringList &file_list, const char *suffix, bool use_fullname)
{
	Directory dir(dirpath);
	bool found_it = false;

	file_list.clearAll();
	const char *f = NULL;

	dir.Rewind();
	while( (f=dir.Next()) ) {

		if( dir.IsDirectory() ) {
			continue;
		}

		if( has_suffix(f, suffix) ) {
			if( use_fullname ) {
				file_list.append(dir.GetFullPath());
			}else {
				file_list.append(f);
			}
			found_it = true;
		}
	}
	return found_it;
}
Example #2
0
// copy attrs into stringlist, returns true if list was modified
// if append is false, list is cleared first.
// if check_exist is true, items are only added if the are not already in the list. comparison is case-insensitive.
bool initStringListFromAttrs(StringList & list, bool append, const classad::References & attrs, bool check_exist /*=false*/)
{
    bool modified = false;
    if ( ! append) {
        if ( ! list.isEmpty()) {
            modified = true;
            list.clearAll();
        }
        check_exist = false; // no need to do this if we cleared the list
    }
    for (classad::References::const_iterator it = attrs.begin(); it != attrs.end(); ++it) {
        if (check_exist && list.contains_anycase(it->c_str())) {
            continue;
        }
        list.append(it->c_str());
        modified = true;
    }
    return modified;
}
Example #3
0
// Create the list of all files in the given directory
void 
find_all_files_in_dir(const char *dirpath, StringList &file_list, bool use_fullname)
{
	Directory dir(dirpath);

	file_list.clearAll();

	const char *f = NULL;

	dir.Rewind();
	while( (f=dir.Next()) ) {

		if( dir.IsDirectory() ) {
			continue;
		}

		if( use_fullname ) {
			file_list.append(dir.GetFullPath());
		}else {
			file_list.append(f);
		}
	}
	return;
}