예제 #1
0
        public Gen::List <SftpFileInfo> SetList(string path, java::util.Vector entries)
        {
            string dir = path;

            if (!dir.EndsWith("/"))
            {
                dir += "/";
            }

            System.DateTime          dt   = System.DateTime.Now;
            Gen::List <SftpFileInfo> list = new Gen::List <SftpFileInfo>();

            foreach (jsch::ChannelSftp.LsEntry entry in entries)
            {
                string filename = entry.getFilename();
                if (filename == ".")
                {
                    string       filepath = path;
                    SftpFileInfo item     = new SftpFileInfo(operation, filepath, entry.getAttrs(), dt);
                    this.InternalSetAttr(item);
                }
                else if (filename == "..")
                {
                    continue;
                }
                else
                {
                    string       filepath = dir + filename;
                    SftpFileInfo item     = new SftpFileInfo(operation, filepath, entry.getAttrs(), dt);
                    list.Add(item);
                    this.InternalSetAttr(item);
                }
            }
            diclist[path] = new lsres_t(list, dt);

            this.DiscardOld();
            return(list);
        }
예제 #2
0
        private Gen::List <SftpFileInfo> ls(string path)
        {
            if (path.Length > 1 && path[path.Length - 1] == '/')
            {
                path = path.Substring(0, path.Length - 1);
            }

            Gen::List <SftpFileInfo> ret;

            if (this.stat_cache.TryGetList(path, out ret))
            {
                return(ret);
            }
            lock (stat_cache){            // (double-checked locking)
                if (this.stat_cache.TryGetList(path, out ret))
                {
                    return(ret);
                }

                session.Message.Write(1, "$ ls {0}", path);
                java::util.Vector vec = session.Sftp.ls(path);
                return(this.stat_cache.SetList(path, vec));
            }
        }