Пример #1
0
        public int GetFileInformation(string filename, FileInformation fileinfo, DokanFileInfo info)
        {
            int ret = DokanNet.DOKAN_SUCCESS;

            filename = CleanFileName(filename);

            try
            {
                Debug("GetFileInformation {0}", filename);
                string Directory = nfsClient.GetDirectoryName(filename);
                string FileName  = nfsClient.GetFileName(filename);
                string FullPath  = nfsClient.Combine(FileName, Directory);

                NFSLibrary.Protocols.Commons.NFSAttributes nfsAttributes = nfsClient.GetItemAttributes(FullPath);
                if (nfsAttributes == null)
                {
                    return(DokanNet.DOKAN_ERROR);
                }

                if (nfsAttributes.NFSType == NFSLibrary.Protocols.Commons.NFSItemTypes.NFDIR)
                {
                    fileinfo.Attributes = System.IO.FileAttributes.Directory;
                }
                else
                {
                    fileinfo.Attributes = System.IO.FileAttributes.Archive;
                }

                fileinfo.LastAccessTime = nfsAttributes.LastAccessedDateTime;
                fileinfo.LastWriteTime  = nfsAttributes.ModifiedDateTime;
                fileinfo.CreationTime   = nfsAttributes.CreateDateTime;
                fileinfo.Length         = (long)nfsAttributes.Size;
            }
            catch (Exception ex)
            {
                ret = DokanNet.DOKAN_ERROR;
                Debug("GetFileInformation file {0} exception {1}", filename, ex.Message);
            }

            return(ret);
        }
Пример #2
0
        void RefreshRemote()
        {
            listViewRemote.Items.Clear();
            List <string> Items = nfsClient.GetItemList(RemoteFolder);

            Items = RemoveDuplicatesAndInvalid(Items);
            Items.Insert(0, "..");
            List <ListViewItem> ItemsList = new List <ListViewItem>();

            foreach (string Item in Items)
            {
                NFSLibrary.Protocols.Commons.NFSAttributes nfsAttribute = nfsClient.GetItemAttributes(nfsClient.Combine(Item, RemoteFolder));
                if (nfsAttribute != null)
                {
                    if (nfsAttribute.NFSType == NFSLibrary.Protocols.Commons.NFSItemTypes.NFDIR)
                    {
                        ListViewItem lvi = new ListViewItem(new string[] { Item, nfsAttribute.Size.ToString(), nfsAttribute.CreateDateTime.ToString() });
                        lvi.ImageIndex = 1;
                        ItemsList.Add(lvi);
                    }
                    else
                    if (nfsAttribute.NFSType == NFSLibrary.Protocols.Commons.NFSItemTypes.NFREG)
                    {
                        ListViewItem lvi = new ListViewItem(new string[] { Item, nfsAttribute.Size.ToString(), nfsAttribute.CreateDateTime.ToString(), nfsAttribute.ModifiedDateTime.ToString(), nfsAttribute.LastAccessedDateTime.ToString() });
                        if (Item == "..")
                        {
                            continue;
                        }

                        lvi.ImageIndex = 0;
                        ItemsList.Add(lvi);
                    }
                }
                else
                {
                    ListViewItem lvi = new ListViewItem(new string[] { Item, "", "" });
                    lvi.ImageIndex = 0;
                    ItemsList.Add(lvi);
                }
            }

            List <ListViewItem> OrderedList = new List <ListViewItem>();

            foreach (ListViewItem lvi in ItemsList)
            {
                if (lvi.Text == "..")
                {
                    if (!OrderedList.Contains(lvi))
                    {
                        OrderedList.Add(lvi);
                    }
                    break;
                }
            }

            foreach (ListViewItem lvi in ItemsList)
            {
                if (lvi.ImageIndex == 1 && lvi.Text != "..")
                {
                    if (!OrderedList.Contains(lvi))
                    {
                        OrderedList.Add(lvi);
                    }
                }
            }

            foreach (ListViewItem lvi in ItemsList)
            {
                if (lvi.ImageIndex == 0)
                {
                    if (!OrderedList.Contains(lvi))
                    {
                        OrderedList.Add(lvi);
                    }
                }
            }

            listViewRemote.Items.AddRange(OrderedList.ToArray());
        }