Exemplo n.º 1
0
 public override void MapDirEntries(MapEntriesFn fn)
 {
     foreach (var file in sftpClient.ListDirectory(WireEncodedString(FullPath), null))
     {
         if ((file.Name == ".") || (file.Name == ".."))
         {
             continue;
         }
         var info = new Core.Info();
         if (file.IsSymbolicLink)
         {
             info.Type = Core.Info.TypeEn.Other;
         }
         else if (file.IsDirectory)
         {
             info.Type = Core.Info.TypeEn.Dir;
         }
         else if (file.IsRegularFile)
         {
             info.Type = Core.Info.TypeEn.File;
             info.Time = file.LastWriteTimeUtc;
             info.Size = (ulong)file.Length;
         }
         else
         {
             info.Type = Core.Info.TypeEn.Other;
         }
         string realName = Encoding.UTF8.GetString(Encoding.GetEncoding(1252).GetBytes(file.Name)).Normalize(NormalizationForm.FormC);
         //string realName = file.Name;
         fn(realName, info);
     }
 }
Exemplo n.º 2
0
 private string DescribeInfo(Core.Info info)
 {
     if (info.Type == Core.Info.TypeEn.File)
     {
         return(HumanizedByteSize(info.Size) + " " + HumanizedDate(info.Time));
     }
     else
     {
         return(info.Type.ToString());
     }
 }
Exemplo n.º 3
0
        public override void MapDirEntries(MapEntriesFn fn)
        {
            DirectoryInfo di = null;

            try
            {
                di = new DirectoryInfo(FullPath);
            }
            catch (PathTooLongException)
            {
                return;
            }
            catch (UnauthorizedAccessException)
            {
                return;
            }
            catch (IOException)
            {
                return;
            }

            foreach (FileSystemInfo fsi in di.GetFileSystemInfos("*"))
            {
                if ((fsi.Name == ".") || (fsi.Name == ".."))
                {
                    continue;
                }
                var info = new Core.Info();
                info.Type = TypeFromAttributes(fsi.Attributes);
                if (info.Type == Core.Info.TypeEn.File)
                {
                    info.Time = fsi.LastWriteTimeUtc;
                    info.Size = (ulong)(new FileInfo(fsi.FullName).Length);
                }
                fn(fsi.Name, info);
            }
        }