Ejemplo n.º 1
0
        public IEnumerable <DirectoryData> GetDirectories(string parentVirtualPath)
        {
            var path = FileSystemPath.Directory(parentVirtualPath);

            return(from child in FindChildren(path, Restrictions.IsNull("Length"))
                   select child.ToDirectoryData());
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        public bool DirectoryExists(string virtualPath)
        {
            var path = FileSystemPath.Directory(virtualPath);
            var item = GetSpecificItem(path);

            return(item != null);
        }
Ejemplo n.º 4
0
        public DirectoryData GetDirectory(string virtualPath)
        {
            var path = FileSystemPath.Directory(virtualPath);
            var item = GetSpecificItem(path);

            return(item == null
                ? null
                : item.ToDirectoryData());
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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));
            }
        }
Ejemplo n.º 7
0
        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));
            }
        }