public IEnumerable <DirectoryData> GetDirectories(string parentVirtualPath) { var path = FileSystemPath.Directory(parentVirtualPath); return(from child in FindChildren(path, Restrictions.IsNull("Length")) select child.ToDirectoryData()); }
public void MoveDirectory(string fromVirtualPath, string destinationVirtualPath) { var source = FileSystemPath.Directory(fromVirtualPath); var target = FileSystemPath.Directory(destinationVirtualPath); if (target.IsDescendantOf(source)) { throw new ApplicationException("Cannot move directory into own subdictory."); } using (var trx = Session.BeginTransaction()) { var directory = GetSpecificItem(source); var descendants = Session .CreateCriteria <FileSystemItem>() .Add(Restrictions.Like("Path.Parent", directory.Path.ToString(), MatchMode.Start)) .List <FileSystemItem>(); foreach (var item in descendants) { item.Path.Rebase(source, target); } directory.Updated = Utility.CurrentTime(); directory.Path = target; Session.Update(directory); trx.Commit(); } if (DirectoryMoved != null) { DirectoryMoved.Invoke(this, new FileEventArgs(destinationVirtualPath, fromVirtualPath)); } }
public bool DirectoryExists(string virtualPath) { var path = FileSystemPath.Directory(virtualPath); var item = GetSpecificItem(path); return(item != null); }
public DirectoryData GetDirectory(string virtualPath) { var path = FileSystemPath.Directory(virtualPath); var item = GetSpecificItem(path); return(item == null ? null : item.ToDirectoryData()); }
private void CreateDirectoryInternal(string virtualPath) { var path = FileSystemPath.Directory(virtualPath); if (virtualPath != "/") { EnsureParentExists(path); } var item = new FileSystemItem { Path = path, Created = Utility.CurrentTime(), Updated = Utility.CurrentTime() }; Session.Save(item); }
public void CreateDirectory(string virtualPath) { var path = FileSystemPath.Directory(virtualPath); // Ensure consistent behavoir with the System.UI.Directory methods used by mapped and virtual filesystem if(DirectoryExists(path.ToString())) throw new IOException("The directory " + path.ToString() + " already exists."); using (var trx = Session.BeginTransaction()) { CreateDirectoryInternal(virtualPath); trx.Commit(); } if (DirectoryCreated != null) { DirectoryCreated.Invoke(this, new FileEventArgs(virtualPath, null)); } }
public void DeleteDirectory(string virtualPath) { var path = FileSystemPath.Directory(virtualPath); using (var trx = Session.BeginTransaction()) { DeleteDescendants(path); var directory = GetSpecificItem(path); Session.Delete(directory); trx.Commit(); } if (DirectoryDeleted != null) { DirectoryDeleted.Invoke(this, new FileEventArgs(virtualPath, null)); } }