Exemple #1
0
		/// <summary>
		/// Allocates a vfs root directory entry.
		/// </summary>
		/// <param name="node">The vfs node, which corresponds to the root directory.</param>
		/// <returns>The created directory entry.</returns>
		/// <exception cref="System.ArgumentNullException">The specified node is invalid.</exception>
		/// <remarks>
		/// This method creates a directory entry, which has some special properties. The first one is, that
		/// its parent is itself. This provides for the ability to cd .. on the root to stay on the root.
		/// <para/>
		/// The next ability is to create specialized root directories to isolate processes from the remainder
		/// of the filesystem. Setting a root directory created using this method effectively limits the process
		/// to access inside of the newly created namespace.
		/// </remarks>
		public static DirectoryEntry AllocateRoot (IVfsNode node)
		{
#if VFS_NO_EXCEPTIONS
			if (node == null)
				throw new ArgumentNullException(@"node");
#endif // #if VFS_NO_EXCEPTIONS
			DirectoryEntry result = new DirectoryEntry ();
			result.Setup (result, String.Empty, node);
			return result;
		}
Exemple #2
0
		/// <summary>
		/// Allocates a new DirectoryEntry object for the given settings.
		/// </summary>
		/// <param name="parent">The parent directory entry.</param>
		/// <param name="name">The name of the entry to create.</param>
		/// <param name="node">The vfs node referenced by the directory entry.</param>
		/// <returns>The allocated directory entry.</returns>
		/// <exception cref="System.ArgumentNullException">If any one of the parameters is null.</exception>
		/// <exception cref="System.ArgumentException">If the name is zero-length.</exception>
		/// <remarks>
		/// This method is used to control the DirectoryEntry allocation and maintain a cache of them. Also used to
		/// prevent infinite name allocations.
		/// </remarks>
		public static DirectoryEntry Allocate (DirectoryEntry parent, string name, IVfsNode node)
		{
			//#if VFS_NO_EXCEPTIONS
			if (parent == null)
				throw new ArgumentNullException (@"parent");

			if (name == null)
				throw new ArgumentNullException (@"name");
	
			if (node == null)
				throw new ArgumentNullException (@"node");
			
			if (name.Length == 0)
				throw new ArgumentException (@"Invalid directory entry name."); // , @"name"
			// FIXME: Add precondition check for invalid characters
			// FIXME: Localize exception messages
			//#endif // #if VFS_NO_EXCEPTIONS

			DirectoryEntry directory = new DirectoryEntry ();

			directory.Setup (parent, name, node);

			return directory;
		}