Inheritance: ISharedListing
Ejemplo n.º 1
0
        public Message CreateRespondDirListingMessage(Node messageTo, LocalDirectory directory)
        {
            SharedDirectoryInfo info = new SharedDirectoryInfo(directory);

            info.Files = directory.Files.Select(f => new SharedFileListing((LocalFile)f, false)).ToArray();
            info.Directories = directory.Directories.Select(d => d.Name).ToArray();

            Message message = new Message (network, MessageType.RespondDirListing);
            message.To = messageTo.NodeID;
            message.Content = info;
            return message;
        }
Ejemplo n.º 2
0
        internal void UpdateFromInfo(SharedDirectoryInfo info)
        {
            var newDirectories = new RemoteDirectory[info.Directories.Length];
            for (int x = 0; x < info.Directories.Length; x++) {
                RemoteDirectory dir = (RemoteDirectory) GetSubdirectory(info.Directories[x]);
                if (dir == null)
                    dir = new RemoteDirectory(PathUtil.Join(m_FullPath, info.Directories[x]));
                newDirectories[x] = dir;
            }

            var newFiles = new RemoteFile[info.Files.Length];
            for (int x = 0; x < info.Files.Length; x++) {
                RemoteFile file = (RemoteFile) GetFile(info.Files[x].Name);
                if (file == null)
                    file = new RemoteFile(this, info.Files[x]);
                else
                    file.UpdateFromInfo(info.Files[x]);
                newFiles[x] = file;
            }

            m_SubDirectories = newDirectories;
            m_Files          = newFiles;

            m_State = RemoteDirectoryState.ContentsReceived;
        }