private string GetFilename() { var path = Parent.WorkingDirectory; var file = FileMask.Replace("%count%", Counter.ToString()); Directory.CreateDirectory(path); return(Path.Combine(path, file)); }
public FtpDownloader( HostTracking tracking, IDestination destination, IPredicate predicate) { Guard.NotNull(() => tracking, tracking); Guard.NotNull(() => destination, destination); Guard.NotNull(() => predicate, predicate); maskRegex = FileMask.GenerateFitMask(tracking.Config.FileMask); log.Debug("Generated mask: {0}", maskRegex); this.tracking = tracking; this.destination = destination; this.predicate = predicate; }
protected override void Validate() { if (ReceiveFolder.IsNullOrEmpty()) { throw new BindingException("Inbound file adapter has no source folder."); } if (FileMask.IsNullOrEmpty()) { throw new BindingException("Inbound file adapter has no source file mask."); } if (!Path.IsNetworkPath(ReceiveFolder) && !NetworkCredentials.UserName.IsNullOrEmpty()) { throw new BindingException("Alternate credentials to access the file folder cannot be supplied while accessing local drive or a mapped network drive."); } }
private void RemoveReaderWithFileNameCheck(string path) { if (!FileMask.IsMatch(Path.GetFileName(path))) { return; } lock (_readers) { if (_readers.ContainsKey(path)) { _readers[path].Dispose(); _readers.Remove(path); } } }
public SkipItem(XElement element) { Condition = (string)element.Attribute("condition"); FileMask = (string)element.Value; FileMaskRegex = new Regex(FileMask.Replace(".", "[.]").Replace("*", ".*").Replace("?", ".").Replace("\\", @"\\")); var name = element.Name.LocalName; SkipMode mode; Enum.TryParse <SkipMode>(name, out mode); Mode = mode; if (mode == SkipMode.Iteration) { int count; int.TryParse((string)element.Attribute("count"), out count); Count = count; } }
private void AddReaderWithFileNameCheck(string path) { if (!FileMask.IsMatch(Path.GetFileName(path))) { return; } lock (_readers) { if (!_readers.ContainsKey(path)) { ILogReader reader = _logReaderFactory.CreateReader(path, new FileInfo(path).Length, Encoding); reader.LineReaded += EvaluateEvents; reader.BeginRead(); _readers.Add(path, reader); } } }
public bool Equals(LogDescriptionConfig other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(other.FileMask.ToString(), FileMask.ToString()) && Equals(other.Encoding, Encoding) && Equals(other.Id, Id) && Equals(other.ConfigFileName, ConfigFileName) && other.LogDirectories.Count == LogDirectories.Count && other.LogDirectories.All(dir => LogDirectories.Contains(dir))); }
private string GetFilename() { var path = Parent.WorkingDirectory; var file = FileMask.Replace("%count%", _counter.ToString()); Directory.CreateDirectory(path); var fullPath = Path.Combine(path, file); int sameCount = 1; while (File.Exists(fullPath)) { var newFilename = Path.GetFileNameWithoutExtension(file) + $" ({sameCount++})" + Path.GetExtension(file); fullPath = Path.Combine(path, newFilename); } return(fullPath); }
private string GetFilename(InputPort port, string ext) { var name = string.IsNullOrEmpty(port.Connection?.Parent.Description) ? "signal" : port.Connection.Parent.Description; var path = WorkingDirectory; var file = FileMask.Replace("%count%", _counter.ToString()) .Replace("%name%", name) .Replace("%ext%", ext); Directory.CreateDirectory(path); var fullPath = Path.Combine(path, file); int sameCount = 1; while (File.Exists(fullPath)) { var newFilename = Path.GetFileNameWithoutExtension(file) + $" ({sameCount++})" + Path.GetExtension(file); fullPath = Path.Combine(path, newFilename); } return(fullPath); }
public override int GetHashCode() { int hash = 1; if (FileMask.Length != 0) { hash ^= FileMask.GetHashCode(); } if (StartDir.Length != 0) { hash ^= StartDir.GetHashCode(); } if (Recursive != false) { hash ^= Recursive.GetHashCode(); } if (IgnoreErrors != false) { hash ^= IgnoreErrors.GetHashCode(); } return(hash); }
private string GetInfoForMask(string mask) { if (mask.Length == 0) return ""; FileMask fileMask = new FileMask(mask); if (fileMask.type == FileMask.Type.Mask) { string ext = mask.Substring(2); return ShellIcon.GetTypeInfo("x." + ext); } return fileMask.GetTypeInfo(); }
public FindInFilesViewModel() { Title = "Find Results"; FindCommand = ReactiveCommand.Create(async() => { Results = null; SearchStats = null; var service = IoC.Get <IFindInFilesService>(); var results = service.Find(_searchTerm, CaseSensitive, WholeWords, Regex, FileMask?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)); Results = await Task.Run(() => new ObservableCollection <FindResultViewModel>(results.Select(r => new FindResultViewModel(r)))); SearchStats = $"{Results.Count} matches in {Results.GroupBy(r => r.FilePath).Count()} files"; }); }
public bool PassesLocalIncludes(string path, MatchReason reason) { IncludeFiltersRow[] includes = GetIncludeFiltersRows(); // it must match at least one global include foreach (IncludeFiltersRow include in includes) { FileMask wildcard = new FileMask(include.Mask); if (wildcard.IsMatch(path)) { reason.Set(include.Mask, MatchReason.Status.Included); return true; } } // didn't match any include return false; }
public bool PassesLocalExcludes(string path, MatchReason reason) { ExcludeFiltersRow[] excludes = GetExcludeFiltersRows(); // it must not match any global exclude foreach (ExcludeFiltersRow exclude in excludes) { FileMask wildcard = new FileMask(exclude.Mask); if (wildcard.IsMatch(path)) { reason.Set(exclude.Mask, MatchReason.Status.Excluded); return false; } } // passed excludes return true; }
public bool PassesGlobalIncludes(string path, MatchReason reason) { // it must match at least one global include foreach (GlobalIncludeFiltersRow row in GlobalIncludeFilters) { FileMask wildcard = new FileMask(row.Mask); if (wildcard.IsMatch(path)) { reason.Set(row.Mask, MatchReason.Status.Included); return true; } } // didn't match any include return false; }
public bool PassesGlobalExcludes(string path) { // it must not match any global exclude foreach (GlobalExcludeFiltersRow row in GlobalExcludeFilters) { FileMask wildcard = new FileMask(row.Mask); if (wildcard.IsMatch(path)) { return false; } } return true; }