using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using System.Web.Security;
using System.Text.RegularExpressions;
using Yavsc.Model.FileSystem;
namespace Yavsc.Controllers
{
///
/// File system controller.
///
public class FileSystemController : Controller
{
///
/// Gets the users base directory.
///
/// The users dir.
public string RootDir {
get {
return mgr.Prefix;
}
}
FileSystemManager mgr = null ;
///
/// Initialize the specified requestContext.
///
/// Request context.
protected override void Initialize (System.Web.Routing.RequestContext requestContext)
{
base.Initialize (requestContext);
mgr = new FileSystemManager (
string.Format("~/users/{0}",Membership.GetUser().UserName));
}
///
/// Index this instance.
///
[Authorize]
public ActionResult Index (string id)
{
return View (mgr.GetFiles (id));
}
///
/// Details the specified id.
///
/// Identifier.
public ActionResult Details (string id)
{
foreach (char x in Path.GetInvalidPathChars()) {
if (id.Contains (x)) {
ViewData ["Message"] =
string.Format (
"Something went wrong following the following path : {0} (\"{1}\")",
id, x);
return RedirectToAction ("Index");
}
}
FileInfo fi = mgr.FileInfo (id);
ViewData ["Content"] = Url.Content (fi.FullName);
return View (fi);
}
///
/// Create the specified id.
///
/// Identifier.
[HttpPost]
[Authorize]
public ActionResult Create (string id)
{
mgr.Put ( id, Request.Files);
return View ("Index",mgr.GetFiles(id));
}
///
/// Gets the user's base dir.
///
/// The base dir.
public string UserBaseDir { get { return Path.Combine (RootDir, Membership.GetUser ().UserName); } }
///
/// Edit the specified id.
///
/// Identifier.
public ActionResult Edit (int id)
{
throw new NotImplementedException ();
}
///
/// Edit the specified id and collection.
///
/// Identifier.
/// Collection.
[HttpPost]
public ActionResult Edit (int id, FormCollection collection)
{
throw new NotImplementedException ();
}
///
/// Delete the specified id.
///
/// Identifier.
public ActionResult Delete (int id)
{
throw new NotImplementedException ();
}
///
/// Delete the specified id and collection.
///
/// Identifier.
/// Collection.
[HttpPost]
public ActionResult Delete (int id, FormCollection collection)
{
throw new NotImplementedException ();
}
}
}