Exemple #1
0
        public ListDirectoryResult ListDirectory(BrowserFileInfo path)
        {
            lock (this)
            {
                //return this.DoListDirectory(path);
                ListDirectoryResult result = new ListDirectoryResult(path);
                String ArgsPscp            = ToArgs(this.Session, this.Session.Password, path.Path);
                RunPscp(
                    result,
                    ArgsPscp,
                    CommandLineOptions.replacePassword(ArgsPscp, "XXXXX"),
                    null,
                    null,
                    (lines) =>
                {
                    // successful list
                    ScpLineParser parser = new ScpLineParser();
                    foreach (string rawLine in lines)
                    {
                        string line = rawLine.TrimEnd();
                        BrowserFileInfo fileInfo;
                        if (parser.TryParseFileLine(line, out fileInfo))
                        {
                            if (fileInfo.Name != ".")
                            {
                                fileInfo.Path = MakePath(path.Path, fileInfo.Name);
                                result.Add(fileInfo);
                            }
                        }
                    }
                });

                return(result);
            }
        }
Exemple #2
0
        /// <summary>
        /// Copy files
        /// </summary>
        /// <param name="sourceFiles"></param>
        /// <param name="target"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public FileTransferResult CopyFiles(List <BrowserFileInfo> sourceFiles, BrowserFileInfo target, TransferUpdateCallback callback)
        {
            lock (this)
            {
                // Known Issues:
                // - If a large exe (or other file that the OS will virus scan) is tranfered, the operation will timeout.
                //   After completion, the OS seems to block on the final write (while scanning).  During this time the process looks like it's
                //   hanging and the timeout logic kicks in.  Hacked in "completed" logic into inlineOut/Err handlers but this is awkward

                FileTransferResult result = new FileTransferResult();

                string        args      = ToArgs(this.Session, this.Session.Password, sourceFiles, target);
                string        argsToLog = ToArgs(this.Session, "XXXXX", sourceFiles, target);
                ScpLineParser parser    = new ScpLineParser();
                RunPscp(
                    result, args, argsToLog,
                    (line) =>
                {
                    bool completed = false;
                    if (callback != null)
                    {
                        FileTransferStatus status;
                        if (parser.TryParseTransferStatus(line, out status))
                        {
                            completed = status.PercentComplete == 100;
                            callback(completed, false, status);
                        }
                    }
                    return(completed);
                },
                    null, null);

                return(result);
            }
        }
Exemple #3
0
        public ListDirectoryResult ListDirectory(BrowserFileInfo path)
        {
            lock (this)
            {
                //return this.DoListDirectory(path);
                ListDirectoryResult result = new ListDirectoryResult(path);

                RunPscp(
                    result,
                    ToArgs(this.Session, this.Session.Password, path.Path),
                    ToArgs(this.Session, "XXXXX", path.Path),
                    null,
                    null,
                    (lines) =>
                    {
                        // successful list
                        ScpLineParser parser = new ScpLineParser();
                        foreach (string rawLine in lines)
                        {
                            string line = rawLine.TrimEnd();
                            BrowserFileInfo fileInfo;
                            if (parser.TryParseFileLine(line, out fileInfo))
                            {
                                if (fileInfo.Name != ".")
                                {
                                    fileInfo.Path = MakePath(path.Path, fileInfo.Name);
                                    result.Add(fileInfo);
                                }
                            }
                        }
                    });

                return result;
            }
        }
Exemple #4
0
        /// <summary>
        /// Copy files
        /// </summary>
        /// <param name="sourceFiles"></param>
        /// <param name="target"></param>
        /// <param name="callback"></param>
        /// <returns></returns>
        public FileTransferResult CopyFiles(List<BrowserFileInfo> sourceFiles, BrowserFileInfo target, TransferUpdateCallback callback)
        {
            lock(this)
            {
                /// Known Issues:
                /// - If a large exe (or other file that the OS will virus scan) is tranfered, the operation will timeout.
                ///   After completion, the OS seems to block on the final write (while scanning).  During this time the process looks like it's
                ///   hanging and the timeout logic kicks in.  Hacked in "completed" logic into inlineOut/Err handlers but this is awkward

                FileTransferResult result = new FileTransferResult();

                string args = ToArgs(this.Session, this.Session.Password, sourceFiles, target);
                string argsToLog = ToArgs(this.Session, "XXXXX", sourceFiles, target);
                ScpLineParser parser = new ScpLineParser();
                RunPscp(
                    result, args, argsToLog,
                    (line) =>
                    {
                        bool completed = false;
                        if (callback != null)
                        {
                            FileTransferStatus status;
                            if (parser.TryParseTransferStatus(line, out status))
                            {
                                completed = status.PercentComplete == 100;
                                callback(completed, false, status);
                            }
                        }
                        return completed;
                    },
                    null, null);

                return result;
            }
        }