Example #1
0
        public virtual FileSystemExitCode PutFile(string localName, RemotePath remoteName, CopyFlags copyFlags)
        {
            try {
                // My ThreadKeeper class is needed here because calls to ProgressProc must be made from this thread and not from some random async one.
                using (var exec = new ThreadKeeper()) {
                    void Progress(int percentDone)
                    {
                        exec.RunInMainThread(() => {
                            if (ProgressProc(localName, remoteName, percentDone))
                            {
                                exec.Cancel();
                            }
                        });
                    }

                    var ret = exec.ExecAsync(asyncFunc: (token) => PutFileAsync(localName, remoteName, copyFlags, Progress, token));

                    return(ret);
                }
            }
            catch (TaskCanceledException) {
                return(FileSystemExitCode.UserAbort);
            }
            catch (OperationCanceledException) {
                return(FileSystemExitCode.UserAbort);
            }
            catch (AggregateException e) {
                if (HasCanceledException(e))
                {
                    return(FileSystemExitCode.UserAbort);
                }

                throw;
            }
        }
Example #2
0
        public ExecResult ExecuteFile(TcWindow mainWin, RemotePath remoteName, string verb)
        {
            if (string.IsNullOrEmpty(verb))
            {
                return(ExecResult.Error);
            }

            var cmd = verb.Split(' ')[0].ToLower();

            switch (cmd)
            {
            case "open":
                return(ExecuteOpen(mainWin, remoteName));

            case "properties":
                return(ExecuteProperties(mainWin, remoteName));

            case "chmod":
                return(ExecuteCommand(mainWin, remoteName, verb.Trim()));

            case "quote":
                return(ExecuteCommand(mainWin, remoteName, verb.Substring(6).Trim()));

            default:
                return(ExecResult.Yourself);
            }
        }
Example #3
0
 protected FsConnection GetConnection(RemotePath connectionRoot)
 {
     return(Connections.GetOrAdd(connectionRoot, root => {
         var connection = new FsConnection(connectionRoot, this);
         return connection;
     }));
 }
Example #4
0
        public virtual bool Disconnect(RemotePath disconnectRoot)
        {
            if (Connections.TryRemove(disconnectRoot, out var connection))
            {
                connection.Disconnect();
                return(true);
            }

            return(false);
        }
Example #5
0
        public virtual object FindFirst(RemotePath path, out FindData findData)
        {
            var enumerable = GetFiles(path);

            if (enumerable != null)
            {
                var enumerator = enumerable.GetEnumerator();
                if (enumerator.MoveNext())
                {
                    findData = enumerator.Current;
                    return(enumerator);
                }
            }

            // empty list
            findData = null;
            return(null);
        }
Example #6
0
 public virtual ExecResult ExecuteProperties(TcWindow mainWin, RemotePath remoteName)
 {
     return(ExecResult.Yourself);
 }
Example #7
0
 /// <summary>
 /// GetPreviewBitmap is called when a file/directory is displayed in thumbnail view.
 /// It can be used to return a custom bitmap for that file/directory.
 /// This function is new in version 1.4. It requires Total Commander >=7.0, but is ignored by older versions.
 /// </summary>
 /// <param name="remoteName">This is the full path to the file or directory whose bitmap is to be retrieved.</param>
 /// <param name="width">The maximum dimensions of the preview bitmap. If your image is smaller, or has a different side ratio, then you need to return an image which is smaller than these dimensions! See notes below!</param>
 /// <param name="height">The maximum dimensions of the preview bitmap. If your image is smaller, or has a different side ratio, then you need to return an image which is smaller than these dimensions! See notes below!</param>
 /// <returns><see cref="PreviewBitmapResult"/> with the extracted Bitmap, caching infos or the path to a local file where TC can extract the bitmap on its own.</returns>
 public virtual PreviewBitmapResult GetPreviewBitmap(RemotePath remoteName, int width, int height)
 {
     return(PreviewBitmapResult.None);
 }
Example #8
0
 /// <summary>
 /// GetLocalName must not be implemented unless your plugin is a temporary file panel plugin! Temporary file panels just hold links to files on the local file system.
 /// </summary>
 /// <remarks>
 /// If your plugin is a temporary panel plugin, the following functions MUST be thread-safe (can be called from background transfer manager):
 /// - GetLocalName
 /// - FindFirst
 /// - FindNext
 /// - FindClose
 ///     This means that when uploading subdirectories from your plugin to FTP in the background, Total Commander will call these functions in a background thread.If the user continues to work in the foreground, calls to FsFindFirst and FsFindNext may be occuring at the same time! Therefore it's very important to use the search handle to keep temporary information about the search.
 ///     FsStatusInfo will NOT be called from the background thread!
 /// </remarks>
 /// <param name="remoteName">Full path to the file name in the plugin namespace, e.g. \somedir\file.ext</param>
 /// <param name="maxLen">Maximum number of characters you can return in RemoteName, including the final 0.</param>
 /// <returns>Return the path of the file on the local file system, e.g. c:\windows\file.ext or null if it does not point to a local file.</returns>
 public virtual string GetLocalName(RemotePath remoteName, int maxLen)
 {
     return(null);
 }
Example #9
0
 public virtual Task <FileSystemExitCode> PutFileAsync(string localName, RemotePath remoteName, CopyFlags copyFlags, Action <int> setProgress, CancellationToken token)
 {
     return(Task.FromResult(FileSystemExitCode.NotSupported));
 }
Example #10
0
 /// <summary>
 /// ExtractCustomIcon is called when a file/directory is displayed in the file list.
 /// It can be used to specify a custom icon for that file/directory.
 /// This function is new in version 1.1. It requires Total Commander >=5.51, but is ignored by older versions.
 /// </summary>
 /// <param name="remoteName">This is the full path to the file or directory whose icon is to be retrieved</param>
 /// <param name="extractFlags">Flags for the extract operation. A combination of <see cref="ExtractIconFlags"/></param>
 /// <returns><see cref="ExtractIconResult"/> with the extracted Icon, caching infos or the path to a local file where TC can extract the Icon on its own.</returns>
 public virtual ExtractIconResult ExtractCustomIcon(RemotePath remoteName, ExtractIconFlags extractFlags)
 {
     return(ExtractIconResult.UseDefault);
 }
Example #11
0
 public virtual FileSystemExitCode RenMovFile(RemotePath oldName, RemotePath newName, bool move, bool overwrite, RemoteInfo remoteInfo)
 {
     return(FileSystemExitCode.NotSupported);
 }
Example #12
0
 public virtual bool SetTime(RemotePath remoteName, DateTime?creationTime, DateTime?lastAccessTime, DateTime?lastWriteTime)
 {
     return(false);
 }
Example #13
0
 /// <summary> It was a (symbolic) link or .lnk file pointing to another file or directory. </summary>
 /// <param name="symlinkTarget">The file or directory where the symlink points to.</param>
 public static ExecResult SymLink(RemotePath symlinkTarget) => new ExecResult(ExecEnum.SymLink, symlinkTarget);
Example #14
0
 public virtual IEnumerable <FindData> GetFiles(RemotePath path)
 {
     return(new FindData[0]);
 }
Example #15
0
 public virtual bool DeleteFile(RemotePath fileName)
 {
     return(false);
 }
Example #16
0
 public virtual bool MkDir(RemotePath dir)
 {
     return(false);
 }
Example #17
0
 public virtual bool RemoveDir(RemotePath dirName)
 {
     return(false);
 }
Example #18
0
 public virtual ExecResult ExecuteCommand(TcWindow mainWin, RemotePath remoteName, string command)
 {
     return(ExecResult.Yourself);
 }
Example #19
0
 public virtual bool SetAttr(RemotePath remoteName, FileAttributes attr)
 {
     return(false);
 }
Example #20
0
 private ExecResult(ExecEnum type, RemotePath symlinkTarget = default)
 {
     Type          = type;
     SymlinkTarget = symlinkTarget;
 }
Example #21
0
 internal FsConnection(RemotePath connectionRoot, FsPlugin plugin)
 {
     _plugin        = plugin;
     ConnectionRoot = connectionRoot;
     _data          = new ConcurrentDictionary <string, object>();
 }