Swapper.NET Logo

Source Code Interfaces ~ IFileManager.cs


using System;
using System.Collections;
using System.IO;

namespace RevolutionaryStuff.P2P.Basics
{
	public interface IFileManager : IDownloadablePackageGetter, IFileServer
	{
		void AdoptFileSource(ILocalFileSource fs);
		string[] StoreCompletedPackage(IDownloadablePackage package);
		/// 
		/// Asking for help as to where to store the newly downloaded package
		/// 
		event DownloadablePackagePlacementEventHandler DownloadablePackagePlacement;
		/// 
		/// This file should be monitored and made available by the file manager
		/// 
		/// The paths of the files
		void TrackFiles(string[] paths);
		/// 
		/// This file should not longer be monitored by the file manager
		/// 
		/// The paths of the files
		void UnTrackFiles(string[] paths);
		/// 
		/// Perform a synchronous search
		/// 
		/// The search params
		/// The results
		ICollection Search(IFileSourceSearchParams searchParams);
		/// 
		/// Is File Sharing Allowed?
		/// 
		bool FileSharingAllowed { get; }
	}

	public class DownloadablePackagePlacementEventArgs : System.ComponentModel.CancelEventArgs
	{
		/// 
		/// The package we want to place
		/// 
		public readonly IDownloadablePackage Package;
		/// 
		/// The base path where we we place the contents
		/// 
		public string BasePath = null;
		/// 
		/// The file attributes that should be used
		/// 
		public FileAttributes Attributes = FileAttributes.Normal;

		public DownloadablePackagePlacementEventArgs(IDownloadablePackage package)
		{
			if (null==package) throw new ArgumentNullException("package");
			this.Package = package;
			this.Cancel = false;
		}
	}

	public delegate void DownloadablePackagePlacementEventHandler(object sender, DownloadablePackagePlacementEventArgs args);
}