Esempio n. 1
0
        /// <summary>
        /// Creates a new VFS entry and returns a wrapper.
        /// </summary>
        /// <param name="entry">The VirtualFileEntry to be created.</param>
        /// <param name="relativePath">The relative path of the entry.</param>
        /// <returns>The VfsEntry wrapper of the created entry.</returns>
        public VfsEntry CreateEntry(VirtualFileEntry entry, string relativePath)
        {
            Add(entry, relativePath);

            return(new VfsEntry
            {
                vfs = this,
                entryHash = GetEntryHash(relativePath)
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Adds an arbitrary entry object at the given relative path
        /// </summary>
        /// <param name="entry">The VirtualFileEntry to be added</param>
        /// <param name="relativePath">The relative path of the entry</param>
        public void Add(VirtualFileEntry entry, string relativePath)
        {
            // Get the top level folder of the current file
            // and try to traverse backwards to generate the folder structure
            var path = Path.GetDirectoryName(relativePath);

            CreateFolderStructure(path);

            // Attach the filename to the current entry from the relative file path
            // Also link it to the current VFS
            entry.Name = Path.GetFileName(relativePath);
            entry.VFS  = this;

            // Add the entry and link it to the top-level directory
            entries[GetEntryHash(relativePath)] = entry;
            LinkEntryAndDirectory(relativePath, path);
        }