FileInfoSeq PathUtil::getFileInfos(const String& base, const String& path, const String& filters, int flags) { FileInfoSeq fileinfos; _wfinddata_t finddata; long handle; int num_files = 0; size_t baselen = base.length(); Filter filter(filters); String pattern = path; if (!PathUtil::isDirectoryLetter(pattern[pattern.length() - 1])) { pattern += '/'; } pattern += '*'; handle = _wfindfirst(const_cast<wchar_t *>(u2w(pattern).c_str()), &finddata); if (handle == -1) { _findclose(handle); return fileinfos; } do { FileInfo info; if (finddata.attrib & _A_SUBDIR) { if (!wcscmp(finddata.name, L".") || !wcscmp(finddata.name, L"..")) { continue; } if (!(flags & File::List_needCVS)) { if (!wcscmp(finddata.name, L"CVS")) { continue; } } if (flags & File::List_nodirectory) { continue; } if (flags & File::List_filterDirectory) { if (!filter.In(w2u(finddata.name))) continue; } info.isDir = true; } else { if (flags & File::List_nofile) { continue; } if (!(flags & File::List_nofilterfile)) { if (!filter.In(w2u(finddata.name))) continue; } info.isDir = false; } info.fullpath = (path + "/" + w2u(finddata.name)).c_str() + baselen; info.filetype = File::Stdio; info.filesize = finddata.size; info.filetime = finddata.time_write; info.localtime = *_localtime64(&finddata.time_write); PathUtil::splitPath(info.fullpath, info.filepath, info.filename, info.fileext); info.filename = PathUtil::removeDir(info.fullpath); fileinfos.push_back(info); num_files++; } while (_wfindnext(handle, &finddata) != -1); _findclose(handle); if (flags & File::List_sort) { std::sort(fileinfos.begin(), fileinfos.end(), CmpFileInfoNameLess); } return fileinfos; }
bool IcePatch2::Patcher::patch(const string& d) { string dir = simplify(nativeToUTF8(_serverNoCompress->ice_getCommunicator(), d)); if(dir.empty() || dir == ".") { if(!_removeFiles.empty()) { if(!removeFiles(_removeFiles)) { return false; } } if(!_updateFiles.empty()) { if(!updateFiles(_updateFiles)) { return false; } } if(!_updateFlags.empty()) { if(!updateFlags(_updateFlags)) { return false; } } return true; } else { string dirWithSlash = simplify(dir + '/'); FileInfoSeq remove; for(FileInfoSeq::const_iterator p = _removeFiles.begin(); p != _removeFiles.end(); ++p) { if(p->path == dir) { remove.push_back(*p); } else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0) { remove.push_back(*p); } } FileInfoSeq update; for(FileInfoSeq::const_iterator p = _updateFiles.begin(); p != _updateFiles.end(); ++p) { if(p->path == dir) { update.push_back(*p); } else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0) { update.push_back(*p); } } FileInfoSeq updateFlag; for(FileInfoSeq::const_iterator p = _updateFlags.begin(); p != _updateFlags.end(); ++p) { if(p->path == dir) { updateFlag.push_back(*p); } else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0) { updateFlag.push_back(*p); } } if(!remove.empty()) { if(!removeFiles(remove)) { return false; } } if(!update.empty()) { if(!updateFiles(update)) { return false; } } if(!updateFlag.empty()) { if(!updateFlags(updateFlag)) { return false; } } return true; } }