bool FileInfosFilter::PassesFilterByFilename(const FileInfo& fi) const {

		// Use regex engine:
		if (query_->UseRegex) {
			if (!helpers::Utf16ToUtf8(fi.GetName(), buffer_.get(), kBufferSize)) return false;

			return re2::RE2::PartialMatch(buffer_.get(), *re_);
		}

		// Use Indexer++ implemented search (only with * ):
		if (filename_filter_->MinLength == 0) {
			return true;
		}

		if (fi.NameLength < filename_filter_->MinLength) {
			return false;
		}

		if (filename_filter_->NChars.size() == 0)  // No wildcards.
		{
			return search(fi.GetName(), filename_filter_->Strs[0], match_case_table_) != nullptr;
		}

		int index = 0;
		for (auto i = 0; i < filename_filter_->NStrs; ++i) {
			auto* res = search(fi.GetName() + index, filename_filter_->Strs[i], match_case_table_);

			if (res == nullptr) return false;

			index = (res - fi.GetName()) + filename_filter_->StrLengths[i];
		}

		return true;
	}
// TODO implement ? wildcard.
bool FileInfosFilter::PassesFilterByFilename(const FileInfo& fi) const {

    if (filename_filter_->MinLength == 0) {
        return true;
    }

    if (fi.NameLength < filename_filter_->MinLength) {
        return false;
    }

    if (filename_filter_->NChars.size() == 0)  // No wildcards.
    {
        return search(fi.GetName(), filename_filter_->Strs[0], match_case_table_) != nullptr;
    }

    int index = 0;
    for (auto i = 0; i < filename_filter_->NStrs; ++i) {
        auto* res = search(fi.GetName() + index, filename_filter_->Strs[i], match_case_table_);

        if (res == nullptr) return false;

        index = (res - fi.GetName()) + filename_filter_->StrLengths[i];
    }

    return true;
}
示例#3
0
  __forceinline void operator()(const FileInfo& file){
    if(file.IsDirectory()){
      int namesize = CurrentDestPath.size();

      CurrentDestPath.append(file.GetName());
      CurrentDestPath.push_back('/');

      CurrentPath /= file.cFileName;

      namesize = CurrentDestPath.size()-namesize;

      //lambda recursion fun times
      //ForEachFile(CurrentPath, foreachFunc);

      //CurrentPath.remove_filename()

      //shrink the path back down one directory
      CurrentPathS.resize(CurrentPathS.size()-namesize);
      CurrentDestPath.resize(CurrentDestPath.size()-namesize);

    }else{
      CurrentPath/file.cFileName;
    }
  }