예제 #1
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
        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;
            }
        }
예제 #2
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
        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);
            }
        }
예제 #3
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 protected FsConnection GetConnection(RemotePath connectionRoot)
 {
     return(Connections.GetOrAdd(connectionRoot, root => {
         var connection = new FsConnection(connectionRoot, this);
         return connection;
     }));
 }
예제 #4
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
        public virtual bool Disconnect(RemotePath disconnectRoot)
        {
            if (Connections.TryRemove(disconnectRoot, out var connection))
            {
                connection.Disconnect();
                return(true);
            }

            return(false);
        }
예제 #5
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
        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);
        }
예제 #6
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual ExecResult ExecuteProperties(TcWindow mainWin, RemotePath remoteName)
 {
     return(ExecResult.Yourself);
 }
예제 #7
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 /// <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);
 }
예제 #8
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 /// <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);
 }
예제 #9
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual Task <FileSystemExitCode> PutFileAsync(string localName, RemotePath remoteName, CopyFlags copyFlags, Action <int> setProgress, CancellationToken token)
 {
     return(Task.FromResult(FileSystemExitCode.NotSupported));
 }
예제 #10
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 /// <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);
 }
예제 #11
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual FileSystemExitCode RenMovFile(RemotePath oldName, RemotePath newName, bool move, bool overwrite, RemoteInfo remoteInfo)
 {
     return(FileSystemExitCode.NotSupported);
 }
예제 #12
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual bool SetTime(RemotePath remoteName, DateTime?creationTime, DateTime?lastAccessTime, DateTime?lastWriteTime)
 {
     return(false);
 }
예제 #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);
예제 #14
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual IEnumerable <FindData> GetFiles(RemotePath path)
 {
     return(new FindData[0]);
 }
예제 #15
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual bool DeleteFile(RemotePath fileName)
 {
     return(false);
 }
예제 #16
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual bool MkDir(RemotePath dir)
 {
     return(false);
 }
예제 #17
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual bool RemoveDir(RemotePath dirName)
 {
     return(false);
 }
예제 #18
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual ExecResult ExecuteCommand(TcWindow mainWin, RemotePath remoteName, string command)
 {
     return(ExecResult.Yourself);
 }
예제 #19
0
파일: FsPlugin.cs 프로젝트: r-Larch/TcBuild
 public virtual bool SetAttr(RemotePath remoteName, FileAttributes attr)
 {
     return(false);
 }
예제 #20
0
 private ExecResult(ExecEnum type, RemotePath symlinkTarget = default)
 {
     Type          = type;
     SymlinkTarget = symlinkTarget;
 }
예제 #21
0
 internal FsConnection(RemotePath connectionRoot, FsPlugin plugin)
 {
     _plugin        = plugin;
     ConnectionRoot = connectionRoot;
     _data          = new ConcurrentDictionary <string, object>();
 }