Allocate() public static method

Allocates a new DirectoryEntry object for the given settings.
This method is used to control the DirectoryEntry allocation and maintain a cache of them. Also used to prevent infinite name allocations.
If any one of the parameters is null. If the name is zero-length.
public static Allocate ( DirectoryEntry parent, string name, IVfsNode node ) : DirectoryEntry
parent DirectoryEntry The parent directory entry.
name string The name of the entry to create.
node IVfsNode The vfs node referenced by the directory entry.
return DirectoryEntry
Exemplo n.º 1
0
        /// <summary>
        /// Creates a new node in the (virtual) filesystem.
        /// </summary>
        /// <param name="path">The path to create.</param>
        /// <param name="type">The type of the node to create.</param>
        /// <param name="settings">Settings used to initialize the node.</param>
        /// <param name="access">Requests the specified access modes on the created object.</param>
        /// <param name="share">Requests the specified sharing settings on the object.</param>
        /// <returns>The created filesystem object.</returns>
        /// <remarks>
        /// This function creates new nodes in the virtual filesystem. In contrast to *nix this call
        /// creates all node types, e.g. files, directories, devices and more. Specific types may
        /// require additional settings, which are specified in a settings object passed as the third
        /// parameter.
        /// </remarks>
        public static object Create(string path, VfsNodeType type, object settings, System.IO.FileAccess access, System.IO.FileShare share)
        {
            // Retrieve the parent directory
            DirectoryEntry parent = PathResolver.Resolve(rootNode, ref path, PathResolutionFlags.RetrieveParent);

            // Check if the caller has write access in the directory
            AccessCheck.Perform(parent, AccessMode.Write, AccessCheckFlags.None);

            // Yes, we do have write access. Create the new vfs node
            IVfsNode node = parent.Node.Create(path, type, settings);
            // FIXME: Assert(null != node);
            DirectoryEntry entry = DirectoryEntry.Allocate(parent, path, node);

            // FIXME: Fix the permissions for this call. *nix does this using its bitmasks, Win32 through its huge CreateFile API.
            return(node.Open(access, share));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Mounts a new file system.
        /// </summary>
        /// <param name="source">The source of the filesystem. This is usually a device name, but can also be another directory.</param>
        /// <param name="target">The path including the name of the mount point, where to mount the new filesystem.</param>
        public static void Mount(string source, string target)
        {
            // Retrieve the parent directory of the mount
            DirectoryEntry parent = PathResolver.Resolve(rootNode, ref target, PathResolutionFlags.RetrieveParent);

            if (parent == null)
            {
                throw new System.ArgumentException();
            }

            IFileSystem root = FileSystemFactory.CreateFileSystem(source);

            if (root == null)
            {
                throw new System.ArgumentException();
            }

            PathSplitter path = new PathSplitter(target);

            DirectoryEntry.Allocate(parent, path.Last, root.Root);
        }