public void Custom_Root_Name_Should_Be_Returned_If_Set()
        {
            provider = new LocalFileSystemProvider("FOO");
            root     = provider.GetFileSystemRoot();

            Assert.AreEqual("FOO", root.Name);
        }
示例#2
0
        protected FolderItem GetFileSystemRootImplementation2()
        {
            VirtualFolderInfo rootInfo;

            if (RootDirectory == null)
            {
                //create artificial one
                rootInfo = new VirtualFolderInfo {
                    FullName = String.Empty, IsEmpty = false
                };
            }
            else
            {
                //create from root directory
                rootInfo = RootDirectory.CreateFolderResourceInfo();
                if (UseRelativePaths)
                {
                    rootInfo.FullName         = PathUtil.RelativeRootPrefix;
                    rootInfo.ParentFolderPath = null;
                }
            }

            rootInfo.Name         = RootName;
            rootInfo.IsRootFolder = true;
            return(new FolderItem(RootDirectory, rootInfo));
        }
        /// <summary>
        /// Gets the root of the file system. This is a dummy folder, which
        /// represents the file system as a whole, and provides the top level contents
        /// of the underlying file system as files and folders.<br/>
        /// In case of this provider, the root either corresponds to
        /// the <see cref="RootDirectory"/>, if set, or the machine itself.
        /// </summary>
        public override VirtualFolderInfo GetFileSystemRoot()
        {
            VirtualFolderInfo root;

            if (RootDirectory == null)
            {
                root = new VirtualFolderInfo
                {
                    IsRootFolder = true,
                    Name         = RootName,
                    FullName     = String.Empty
                };
            }
            else
            {
                root              = RootDirectory.CreateFolderResourceInfo();
                root.Name         = RootName;
                root.IsRootFolder = true;

                //hide the path
                if (UseRelativePaths)
                {
                    root.FullName = PathUtil.RelativeRootPrefix;
                }
            }

            return(root);
        }
        public void Init()
        {
            rootDirectory = TestUtil.CreateTestDirectory();

            //init provider
            DownloadTransferStore = new TestTransferStore <LocalDownloadTransfer>();
            UploadTransferStore   = new TestTransferStore <LocalUploadTransfer>();

            var configuration = LocalFileSystemConfiguration.CreateForRootDirectory(rootDirectory, true);

            configuration.DownloadStore = DownloadTransferStore;
            configuration.UploadStore   = UploadTransferStore;
            configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
            configuration.UploadTokenExpirationTime   = TimeSpan.FromHours(24);
            configuration.DefaultDownloadBlockSize    = 32768;
            configuration.MaxDownloadBlockSize        = 32768 * 2;
            configuration.MaxUploadBlockSize          = 32768 * 4;

            AdjustFileSystemConfiguration(configuration);
            FileSystemConfiguration = configuration;

            provider = new LocalFileSystemProvider(FileSystemConfiguration);
            root     = provider.GetFileSystemRoot();

            InitInternal();
        }
    public void Init()
    {
      rootDirectory = TestUtil.CreateTestDirectory();

      //init provider
      DownloadTransferStore = new TestTransferStore<LocalDownloadTransfer>();
      UploadTransferStore = new TestTransferStore<LocalUploadTransfer>();

      var configuration = LocalFileSystemConfiguration.CreateForRootDirectory(rootDirectory, true);
      configuration.DownloadStore = DownloadTransferStore;
      configuration.UploadStore = UploadTransferStore;
      configuration.DownloadTokenExpirationTime = TimeSpan.FromHours(24);
      configuration.UploadTokenExpirationTime = TimeSpan.FromHours(24);
      configuration.DefaultDownloadBlockSize = 32768;
      configuration.MaxDownloadBlockSize = 32768 * 2;
      configuration.MaxUploadBlockSize = 32768 * 4;

      AdjustFileSystemConfiguration(configuration);
      FileSystemConfiguration = configuration;

      provider = new LocalFileSystemProvider(FileSystemConfiguration);
      root = provider.GetFileSystemRoot();

      InitInternal();
    }
示例#6
0
        public static VirtualFolderInfo ToFolderInfo(this ZipNode node)
        {
            Ensure.ArgumentNotNull(node, "node");

            if (!node.IsDirectoryNode)
            {
                string msg = "ZIP entry [{0}] does not represent a directory.";
                msg = String.Format(msg, node.FullName);
                throw new InvalidOperationException(msg);
            }

            //get local name
            var fileName = node.FullName;

            if (fileName.EndsWith("/"))
            {
                fileName = fileName.Substring(0, fileName.Length - 1);
            }
            fileName = Path.GetFileName(fileName);

            var fi = new VirtualFolderInfo
            {
                Name         = fileName,
                IsRootFolder = node.IsRootNode,
                IsEmpty      = node.ChildNodes.Count() == 0
            };

            SetCommonProperties(fi, node);
            return(fi);
        }
    public void Custom_Root_Name_Should_Be_Returned_If_Set()
    {
      provider = new LocalFileSystemProvider("FOO");
      root = provider.GetFileSystemRoot();

      Assert.AreEqual("FOO", root.Name);
    }
示例#8
0
    public static VirtualFolderInfo ToFolderInfo(this ZipNode node)
    {
      Ensure.ArgumentNotNull(node, "node");

      if(!node.IsDirectoryNode)
      {
        string msg = "ZIP entry [{0}] does not represent a directory.";
        msg = String.Format(msg, node.FullName);
        throw new InvalidOperationException(msg);
      }

      //get local name
      var fileName = node.FullName;
      if (fileName.EndsWith("/")) fileName = fileName.Substring(0, fileName.Length - 1);
      fileName = Path.GetFileName(fileName);

      var fi = new VirtualFolderInfo
                               {
                                 Name = fileName,
                                 IsRootFolder =  node.IsRootNode,
                                 IsEmpty = node.ChildNodes.Count() == 0
                               };

      SetCommonProperties(fi, node);
      return fi;
    }
        public void Parent_Folder_Of_Root_Should_Be_Null()
        {
            root = provider.GetFileSystemRoot();
            Assert.IsNull(root.ParentFolderPath);

            root = provider.GetFolderInfo(root.FullName);
            Assert.IsNull(root.ParentFolderPath);
        }
示例#10
0
        public void Adding_A_Folder_To_Unavailable_Parent_Directory_Should_Fail()
        {
            var parent = new VirtualFolderInfo {
                FullName = "/Foo/Bar"
            };

            provider.CreateFolder(parent, "ChildOfUnknownParent");
        }
示例#11
0
 protected override void InitInternal()
 {
     illegalFile = new VirtualFileInfo {
         FullName = "a?:<>@*%&/"
     };
     illegalFolder = new VirtualFolderInfo {
         FullName = "a?:<>@*%&/"
     };
 }
示例#12
0
        /// <summary>
        /// Checks whether the <see cref="VirtualResourceInfo.FullName"/>
        /// matches an existing directory on the local file system. If that's
        /// not the case, a <see cref="VirtualResourceNotFoundException"/> is
        /// thrown.
        /// </summary>
        /// <param name="folder">The folder to check.</param>
        /// <param name="rootDirectory">The used root directory, if any, which is used
        /// to resolve relative paths.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="folder"/>
        /// is a null reference.</exception>
        /// <exception cref="VirtualResourceNotFoundException">If the submitted
        /// folder's <see cref="VirtualResourceInfo.FullName"/> does not link to
        /// an existing directory.</exception>
        internal static void VerifyDirectoryExists(this VirtualFolderInfo folder, DirectoryInfo rootDirectory)
        {
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }

            string path = PathUtil.GetAbsolutePath(folder.FullName, rootDirectory);

            if (String.IsNullOrEmpty(path) || !Directory.Exists(path))
            {
                string msg = String.Format("Directory '{0}' not found on local file system.", folder.FullName);
                throw new VirtualResourceNotFoundException(msg)
                      {
                          Resource = folder
                      };
            }
        }
示例#13
0
        /// <summary>
        /// Creates a folder item that represents the ZIP file itself and thus the
        /// root of the file system. Accordingly the returned <see cref="ZipFolderItem.Node"/>
        /// returns the <see cref="RootNode"/> of the repository.
        /// </summary>
        /// <returns>A folder item that represents the file system root.</returns>
        public ZipFolderItem CreateRootItem()
        {
            string rootName = String.IsNullOrEmpty(Configuration.RootName)
                          ? Configuration.ZipFileInfo.Name
                          : Configuration.RootName;


            var root = new VirtualFolderInfo
            {
                Name         = rootName,
                FullName     = RootFolderPath,
                IsRootFolder = true
            };

            return(new ZipFolderItem {
                Node = RootNode, ResourceInfo = root
            });
        }
        protected VirtualFolderInfo GetFolderInfoInternal(string virtualFolderPath, bool mustExist, out string absolutePath)
        {
            try
            {
                //make sure we operate on absolute paths
                absolutePath = PathUtil.GetAbsolutePath(virtualFolderPath ?? "", RootDirectory);

                if (IsRootPath(absolutePath))
                {
                    return(GetFileSystemRoot());
                }

                var di = new DirectoryInfo(absolutePath);
                VirtualFolderInfo folderInfo = di.CreateFolderResourceInfo();

                //convert to relative paths if required (also prevents qualified paths in validation exceptions)
                if (UseRelativePaths)
                {
                    folderInfo.MakePathsRelativeTo(RootDirectory);
                }

                //make sure the user is allowed to access the resource
                ValidateResourceAccess(folderInfo);

                //verify folder exists on FS
                if (mustExist)
                {
                    folderInfo.VerifyDirectoryExists(RootDirectory);
                }

                return(folderInfo);
            }
            catch (VfsException)
            {
                //just bubble internal exceptions
                throw;
            }
            catch (Exception e)
            {
                VfsLog.Debug(e, "Could not create directory based on path '{0}' with root '{1}'", virtualFolderPath,
                             RootDirectory);
                throw new ResourceAccessException("Invalid path submitted: " + virtualFolderPath);
            }
        }
        /// <summary>
        /// Resolves the parent folder for a virtual resource.
        /// </summary>
        /// <param name="child">The child file or folder.</param>
        /// <returns>The parent folder info.</returns>
        private VirtualFolderInfo GetParentInternal(VirtualResourceInfo child)
        {
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }

            string path = PathUtil.GetAbsolutePath(child.FullName, RootDirectory);

            if (IsRootPath(path))
            {
                //only log the request for the root's parent - do not include that
                //info in an exception in case we're hiding path information
                string msg = "Error while requesting parent of resource {0} - the folder itself already is the root.";
                VfsLog.Error(msg, child.FullName);

                //create exception with a relative path, if required
                string exceptionPath = UseRelativePaths ? PathUtil.RelativeRootPrefix : child.FullName;
                msg = String.Format(msg, exceptionPath);
                throw new ResourceAccessException(msg);
            }

            //make sure the processed directory exists
            VirtualFolderInfo folder = child as VirtualFolderInfo;

            if (folder != null)
            {
                folder.VerifyDirectoryExists(RootDirectory);
            }
            else
            {
                VirtualFileInfo file = (VirtualFileInfo)child;
                file.VerifyFileExists(RootDirectory);
            }

            //get the path of the parent (returned value may be null!)
            string parentPath = Path.GetDirectoryName(path);

            //get folder info
            return(GetFolderInfo(parentPath));
        }
示例#16
0
        public void Creating_Item_From_Existing_Directory_Should_Include_All_Information()
        {
            DirectoryInfo di = new FileInfo(GetType().Assembly.Location).Directory;

            Assert.IsTrue(di.Exists);

            VirtualFolderInfo item = di.CreateFolderResourceInfo();

            Assert.AreEqual(di.Name, item.Name);
            Assert.AreEqual(di.FullName, item.FullName);

            //timestamps should match file info
            Assert.AreEqual((DateTimeOffset)di.CreationTime, item.CreationTime);
            Assert.AreEqual((DateTimeOffset)di.LastAccessTime, item.LastAccessTime);
            Assert.AreEqual((DateTimeOffset)di.LastWriteTime, item.LastWriteTime);

            //the item should not be hidden
            Assert.IsFalse(item.IsHidden);

            //directory is not a root folder
            Assert.IsFalse(item.IsRootFolder);
        }
示例#17
0
        public void Requesting_Arbitrary_Folder_Above_Root_Should_Fail()
        {
            foreach (var drive in Directory.GetLogicalDrives())
            {
                try
                {
                    VirtualFolderInfo driveFolder = new VirtualFolderInfo {
                        FullName = drive
                    };
                    provider.GetFolderParent(driveFolder);
                    Assert.Fail("Could request drive resource");
                }
                catch (ResourceAccessException)
                {
                }
            }

            VirtualFolderInfo folder = new VirtualFolderInfo {
                FullName = rootDirectory.Parent.FullName
            };

            provider.GetFolderParent(folder);
        }
示例#18
0
        public void Creating_Item_From_Inexisting_Folder_Should_Provides_Names_And_Default_Properties()
        {
            DirectoryInfo di = new DirectoryInfo("test");

            Assert.IsFalse(di.Exists);

            VirtualFolderInfo item = di.CreateFolderResourceInfo();

            Assert.AreEqual("test", item.Name);
            Assert.AreEqual(di.FullName, item.FullName);

            //timestamps should be null
            Assert.IsNull(item.CreationTime);
            Assert.IsNull(item.LastAccessTime);
            Assert.IsNull(item.LastWriteTime);

            //the item should not be hidden / readonly
            Assert.IsFalse(item.IsHidden);
            Assert.IsFalse(item.IsReadOnly);

            //item is not root folder
            Assert.IsFalse(item.IsRootFolder);
        }
示例#19
0
        public FolderItem ResolveFolderResourcePath2(string submittedFolderPath, FileSystemTask context)
        {
            //make sure we operate on absolute paths
            string absolutePath = PathUtil.GetAbsolutePath(submittedFolderPath ?? "", RootDirectory);

            if (IsRootPath(absolutePath))
            {
                return(GetFileSystemRootImplementation() as FolderItem);
            }

            var di = new DirectoryInfo(absolutePath);
            VirtualFolderInfo folderInfo = di.CreateFolderResourceInfo();

            var item = new FolderItem(di, folderInfo);

            //convert to relative paths if required (also prevents qualified paths in validation exceptions)
            if (UseRelativePaths)
            {
                item.MakePathsRelativeTo(RootDirectory);
            }

            ValidateFolderRequestAccess(item, submittedFolderPath, context);
            return(item);
        }
示例#20
0
 /// <summary>
 /// Copies a given folder and all its contents to a new destination.
 /// </summary>
 /// <param name="folder">Represents the resource in the file system.</param>
 /// <param name="destinationPath">The new path of the resource. Can be another name
 /// for the resource itself.</param>
 /// <returns>A <see cref="VirtualFolderInfo"/> object that represents the new
 /// directory in the file system.</returns>
 /// <exception cref="ArgumentNullException">If any of the parameters is a
 /// null reference.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access, or if the operation is not possible (e.g. a resource being
 /// moved/copied to itself).</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the resource that
 /// should be moved does not exist in the file system.</exception>
 /// <exception cref="ResourceOverwriteException">If a resource that matches the
 /// submitted <paramref name="destinationPath"/> already exists.</exception>
 public VirtualFolderInfo CopyFolder(VirtualFolderInfo folder, string destinationPath)
 {
     return(FaultUtil.SecureFunc(FileSystemTask.FolderCopyRequest, () => Decorated.CopyFolder(folder, destinationPath)));
 }
示例#21
0
 /// <summary>
 /// Gets all files and folders of a given <paramref name="parent"/> folder that match
 /// the specified <paramref name="searchPattern"/>.
 /// </summary>
 /// <param name="parent">The processed parent folder.</param>
 /// <param name="searchPattern">A search string which is used to limit the returned
 /// results to folders with matching names.</param>
 /// <returns>The files and folders of the submitted parent.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="parent"/>
 /// is a null reference.</exception>
 /// <exception cref="ArgumentNullException">If <paramref name="searchPattern"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented
 /// by <paramref name="parent"/> does not exist in the file system.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 public FolderContentsInfo GetFolderContents(VirtualFolderInfo parent, string searchPattern)
 {
     return(FaultUtil.SecureFunc(FileSystemTask.FolderContentsRequest,
                                 () => Decorated.GetFolderContents(parent, searchPattern)));
 }
    /// <summary>
    /// Gets the root of the file system. This is a dummy folder, which
    /// represents the file system as a whole, and provides the top level contents
    /// of the underlying file system as files and folders.<br/>
    /// In case of this provider, the root either corresponds to
    /// the <see cref="RootDirectory"/>, if set, or the machine itself.
    /// </summary>
    public override VirtualFolderInfo GetFileSystemRoot()
    {
      VirtualFolderInfo root;
      if (RootDirectory == null)
      {
        root = new VirtualFolderInfo
                 {
                     IsRootFolder = true,
                     Name = RootName,
                     FullName = String.Empty
                 };
      }
      else
      {
        root = RootDirectory.CreateFolderResourceInfo();
        root.Name = RootName;
        root.IsRootFolder = true;

        //hide the path
        if(UseRelativePaths) root.FullName = PathUtil.RelativeRootPrefix;
      }

      return root;
    }
示例#23
0
 public FolderItem(DirectoryInfo localDirectory, VirtualFolderInfo virtualFolder)
 {
     LocalDirectory = localDirectory;
     ResourceInfo   = virtualFolder;
 }
 public void Adding_A_Folder_To_Unavailable_Parent_Directory_Should_Fail()
 {
   var parent = new VirtualFolderInfo {FullName = "/Foo/Bar"};
   provider.CreateFolder(parent, "ChildOfUnknownParent");
 }
    public void Requesting_Arbitrary_Folder_Above_Root_Should_Fail()
    {
      foreach (var drive in Directory.GetLogicalDrives())
      {
        try
        {
          VirtualFolderInfo driveFolder = new VirtualFolderInfo {FullName = drive};
          provider.GetFolderParent(driveFolder);
          Assert.Fail("Could request drive resource");
        }
        catch (ResourceAccessException)
        {
        }
      }

      VirtualFolderInfo folder = new VirtualFolderInfo {FullName = rootDirectory.Parent.FullName};
      provider.GetFolderParent(folder);
    }
示例#26
0
 public ZipFolderItem(ZipNode folderEntry, VirtualFolderInfo virtualFolder)
 {
     Node         = folderEntry;
     ResourceInfo = virtualFolder;
 }
示例#27
0
 /// <summary>
 /// Gets the parent folder of a given file system resource.
 /// </summary>
 /// <param name="child">An arbitrary folder resource of the file system.</param>
 /// <returns>The parent of the folder.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="child"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented
 /// by <paramref name="child"/> does not exist in the file system.</exception>
 public VirtualFolderInfo GetFolderParent(VirtualFolderInfo child)
 {
     return(FaultUtil.SecureFunc(FileSystemTask.FolderParentRequest, () => Decorated.GetFolderParent(child)));
 }
示例#28
0
    /// <summary>
    /// Creates a folder item that represents the ZIP file itself and thus the
    /// root of the file system. Accordingly the returned <see cref="ZipFolderItem.Node"/>
    /// returns the <see cref="RootNode"/> of the repository.
    /// </summary>
    /// <returns>A folder item that represents the file system root.</returns>
    public ZipFolderItem CreateRootItem()
    {
      string rootName = String.IsNullOrEmpty(Configuration.RootName)
                          ? Configuration.ZipFileInfo.Name
                          : Configuration.RootName;


      var root = new VirtualFolderInfo
                                 {
                                   Name = rootName,
                                   FullName = RootFolderPath,
                                   IsRootFolder = true
                                 };

      return new ZipFolderItem { Node = RootNode, ResourceInfo = root};   
    }
示例#29
0
 public ZipFolderItem(ZipNode folderEntry, VirtualFolderInfo virtualFolder)
 {
   Node = folderEntry;
   ResourceInfo = virtualFolder;
 }
示例#30
0
 /// <summary>
 /// Gets all child folders of a given <paramref name="parent"/> folder.
 /// </summary>
 /// <param name="parent">The processed parent folder.</param>
 /// <returns>The child folders of the folder.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="parent"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented
 /// by <paramref name="parent"/> does not exist in the file system.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 public IEnumerable <VirtualFolderInfo> GetChildFolders(VirtualFolderInfo parent)
 {
     return(FaultUtil.SecureFunc(FileSystemTask.ChildFoldersRequest, () => Decorated.GetChildFolders(parent)));
 }
示例#31
0
 /// <summary>
 /// Gets the parent folder of a given file system resource.
 /// </summary>
 /// <param name="child">An arbitrary folder resource of the file system.</param>
 /// <returns>The parent of the folder.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="child"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented
 /// by <paramref name="child"/> does not exist in the file system.</exception>
 public VirtualFolderInfo GetFolderParent(VirtualFolderInfo child)
 {
   return FaultUtil.SecureFunc(FileSystemTask.FolderParentRequest, () => Decorated.GetFolderParent(child));
 }
示例#32
0
 /// <summary>
 /// Creates a new folder in the file system.
 /// </summary>
 /// <param name="parent">The designated parent folder, which
 /// needs to exists, and provide write access.</param>
 /// <param name="folderName">The name of the folder to be created.</param>
 /// <returns>A <see cref="VirtualFileInfo"/> instance which represents
 /// the created folder.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="parent"/>
 /// is a null reference.</exception>
 /// <exception cref="ArgumentNullException">If <paramref name="folderName"/>
 /// is a null reference.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the <paramref name="parent"/>
 /// folder does not exist.</exception>
 /// <exception cref="ResourceOverwriteException">If the folder already exists on the file
 /// system.</exception>
 public VirtualFolderInfo CreateFolder(VirtualFolderInfo parent, string folderName)
 {
     return(FaultUtil.SecureFunc(FileSystemTask.FolderCreateRequest, () => Decorated.CreateFolder(parent, folderName)));
 }
示例#33
0
 /// <summary>
 /// Gets all files of a given <paramref name="parent"/> folder that match
 /// the specified <paramref name="searchPattern"/>.
 /// </summary>
 /// <param name="parent">The processed parent folder.</param>
 /// <param name="searchPattern">A search string which is used to limit the returned
 /// results to folders with matching names.</param>
 /// <returns>The files in the submitted <paramref name="parent"/> folder.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="parent"/>
 /// is a null reference.</exception>
 /// <exception cref="ArgumentNullException">If <paramref name="searchPattern"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented
 /// by <paramref name="parent"/> does not exist in the file system.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 public IEnumerable <VirtualFileInfo> GetChildFiles(VirtualFolderInfo parent, string searchPattern)
 {
     return(FaultUtil.SecureFunc(FileSystemTask.ChildFilesRequest, () => Decorated.GetChildFiles(parent, searchPattern)));
 }
 public void Init()
 {
     provider = new LocalFileSystemProvider();
     root     = provider.GetFileSystemRoot();
 }
示例#35
0
 /// <summary>
 /// Gets all child folders of a given <paramref name="parent"/> folder.
 /// </summary>
 /// <param name="parent">The processed parent folder.</param>
 /// <returns>The child folders of the folder.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="parent"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented
 /// by <paramref name="parent"/> does not exist in the file system.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 public IEnumerable<VirtualFolderInfo> GetChildFolders(VirtualFolderInfo parent)
 {
   return FaultUtil.SecureFunc(FileSystemTask.ChildFoldersRequest, () => Decorated.GetChildFolders(parent));
 }
    public void Parent_Folder_Of_Root_Should_Be_Null()
    {
      root = provider.GetFileSystemRoot();
      Assert.IsNull(root.ParentFolderPath);

      root = provider.GetFolderInfo(root.FullName);
      Assert.IsNull(root.ParentFolderPath);
    }
    protected override void InitInternal()
    {

      illegalFile = new VirtualFileInfo { FullName = "a?:<>@*%&/" };
      illegalFolder = new VirtualFolderInfo { FullName = "a?:<>@*%&/" };
    }
示例#38
0
 /// <summary>
 /// Gets all files of a given <paramref name="parent"/> folder that match
 /// the specified <paramref name="searchPattern"/>.
 /// </summary>
 /// <param name="parent">The processed parent folder.</param>
 /// <param name="searchPattern">A search string which is used to limit the returned
 /// results to folders with matching names.</param>
 /// <returns>The files in the submitted <paramref name="parent"/> folder.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="parent"/>
 /// is a null reference.</exception>
 /// <exception cref="ArgumentNullException">If <paramref name="searchPattern"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented
 /// by <paramref name="parent"/> does not exist in the file system.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 public IEnumerable<VirtualFileInfo> GetChildFiles(VirtualFolderInfo parent, string searchPattern)
 {
   return FaultUtil.SecureFunc(FileSystemTask.ChildFilesRequest, () => Decorated.GetChildFiles(parent, searchPattern));
 }
 public void Init()
 {
   provider = new LocalFileSystemProvider();
   root = provider.GetFileSystemRoot();
 }
示例#40
0
 /// <summary>
 /// Gets all files and folders of a given <paramref name="parent"/> folder that match
 /// the specified <paramref name="searchPattern"/>.
 /// </summary>
 /// <param name="parent">The processed parent folder.</param>
 /// <param name="searchPattern">A search string which is used to limit the returned
 /// results to folders with matching names.</param>
 /// <returns>The files and folders of the submitted parent.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="parent"/>
 /// is a null reference.</exception>
 /// <exception cref="ArgumentNullException">If <paramref name="searchPattern"/>
 /// is a null reference.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the folder that is represented
 /// by <paramref name="parent"/> does not exist in the file system.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 public FolderContentsInfo GetFolderContents(VirtualFolderInfo parent, string searchPattern)
 {
   return FaultUtil.SecureFunc(FileSystemTask.FolderContentsRequest,
                               () => Decorated.GetFolderContents(parent, searchPattern));
 }
示例#41
0
 protected override void InitInternal()
 {
     originalDir    = rootDirectory.GetDirectories().First();
     originalFolder = provider.GetFolderInfo(originalDir.FullName);
     targetDir      = new DirectoryInfo(Path.Combine(rootDirectory.GetDirectories().Last().FullName, "target"));
 }
示例#42
0
 /// <summary>
 /// Creates a new folder in the file system.
 /// </summary>
 /// <param name="parent">The designated parent folder, which
 /// needs to exists, and provide write access.</param>
 /// <param name="folderName">The name of the folder to be created.</param>
 /// <returns>A <see cref="VirtualFileInfo"/> instance which represents
 /// the created folder.</returns>
 /// <exception cref="ArgumentNullException">If <paramref name="parent"/>
 /// is a null reference.</exception>
 /// <exception cref="ArgumentNullException">If <paramref name="folderName"/>
 /// is a null reference.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access.</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the <paramref name="parent"/>
 /// folder does not exist.</exception>
 /// <exception cref="ResourceOverwriteException">If the folder already exists on the file
 /// system.</exception>
 public VirtualFolderInfo CreateFolder(VirtualFolderInfo parent, string folderName)
 {
   return FaultUtil.SecureFunc(FileSystemTask.FolderCreateRequest, () => Decorated.CreateFolder(parent, folderName));
 }
示例#43
0
 /// <summary>
 /// Copies a given folder and all its contents to a new destination.
 /// </summary>
 /// <param name="folder">Represents the resource in the file system.</param>
 /// <param name="destinationPath">The new path of the resource. Can be another name
 /// for the resource itself.</param>
 /// <returns>A <see cref="VirtualFolderInfo"/> object that represents the new
 /// directory in the file system.</returns>
 /// <exception cref="ArgumentNullException">If any of the parameters is a
 /// null reference.</exception>
 /// <exception cref="ResourceAccessException">In case of invalid or prohibited
 /// resource access, or if the operation is not possible (e.g. a resource being
 /// moved/copied to itself).</exception>
 /// <exception cref="VirtualResourceNotFoundException">If the resource that
 /// should be moved does not exist in the file system.</exception>
 /// <exception cref="ResourceOverwriteException">If a resource that matches the
 /// submitted <paramref name="destinationPath"/> already exists.</exception>
 public VirtualFolderInfo CopyFolder(VirtualFolderInfo folder, string destinationPath)
 {
   return FaultUtil.SecureFunc(FileSystemTask.FolderCopyRequest, () => Decorated.CopyFolder(folder, destinationPath));
 }
示例#44
0
 public FolderItem(DirectoryInfo localDirectory, VirtualFolderInfo virtualFolder)
 {
   LocalDirectory = localDirectory;
   ResourceInfo = virtualFolder;
 }
 protected override void InitInternal()
 {
   originalDir = rootDirectory.GetDirectories().First();
   originalFolder = provider.GetFolderInfo(originalDir.FullName);
   targetDir = new DirectoryInfo(Path.Combine(rootDirectory.GetDirectories().Last().FullName, "target"));
 }
        protected  FolderItem GetFileSystemRootImplementation2() {
            VirtualFolderInfo rootInfo;
            if (RootDirectory == null) {
                //create artificial one
                rootInfo = new VirtualFolderInfo { FullName = String.Empty, IsEmpty = false };
            }
            else {
                //create from root directory
                rootInfo = RootDirectory.CreateFolderResourceInfo();
                if (UseRelativePaths) {
                    rootInfo.FullName = PathUtil.RelativeRootPrefix;
                    rootInfo.ParentFolderPath = null;
                }
            }

            rootInfo.Name = RootName;
            rootInfo.IsRootFolder = true;
            return new FolderItem(RootDirectory, rootInfo);
        }