コード例 #1
0
ファイル: AutoAddPlugin.cs プロジェクト: randacc/hdkn
        internal void AddFile(WatchedFolder folder, string file)
        {
            try
            {
                // No filter, just add
                byte[] data = _fileSystem.ReadAllBytes(file);
                var manager = _bitTorrentEngine.AddTorrent(data);

                if(manager == null)
                    return;

                if (folder.AutoStart)
                    manager.Start();

                _fileSystem.DeleteFile(file);
            }
            catch(FileNotFoundException fileNotFoundException)
            {
                Logger.ErrorException(String.Format("File {0} not found", file), fileNotFoundException);
            }
            catch(IOException ioException)
            {
                Logger.ErrorException(String.Format("I/O exception when reading file {0}", file), ioException);
            }
        }
コード例 #2
0
ファイル: AutoAddPlugin.cs プロジェクト: randacc/hdkn
        internal void CheckFolder(WatchedFolder folder)
        {
            string[] files = _fileSystem.GetFiles(folder.Path, "*.torrent");

            foreach(var file in files)
            {
                string fileName = Path.GetFileName(file);

                if(String.IsNullOrEmpty(fileName))
                    continue;

                if(!String.IsNullOrEmpty(folder.IncludeFilter) || !String.IsNullOrEmpty(folder.ExcludeFilter))
                {
                    bool excludeAdd = !(!String.IsNullOrEmpty(folder.ExcludeFilter) && !Regex.IsMatch(fileName, folder.ExcludeFilter));
                    bool includeAdd = !(!String.IsNullOrEmpty(folder.IncludeFilter) && !Regex.IsMatch(fileName, folder.IncludeFilter));

                    if(excludeAdd && includeAdd)
                    {
                        AddFile(folder, file);
                    }
                }
                else
                {
                    AddFile(folder, file);
                }
            }
        }