Example #1
0
        private object ExecuteRemoveCommand(IDictionary <string, object> args)
        {
            FileItemPathInfo pathInfoParam = GetPathInfoParam("pathInfo", args);

            FileSystemProvider.Remove(pathInfoParam);
            return(null);
        }
Example #2
0
        private object ExecuteGetDirContentCommand(IDictionary <string, object> args)
        {
            FileItemPathInfo pathInfoParam = GetPathInfoParam("pathInfo", args);

            return((from item in FileSystemProvider.GetDirectoryContents(pathInfoParam)
                    where item.IsDirectory || IsValidFileExtension(item.Name)
                    select item).ToList());
        }
Example #3
0
        private object ExecuteCopyCommand(IDictionary <string, object> args)
        {
            FileItemPathInfo pathInfoParam  = GetPathInfoParam("sourcePathInfo", args);
            FileItemPathInfo pathInfoParam2 = GetPathInfoParam("destinationPathInfo", args);

            FileSystemProvider.Copy(pathInfoParam, pathInfoParam2);
            return(null);
        }
Example #4
0
        private object ExecuteCreateDirCommand(IDictionary <string, object> args)
        {
            FileItemPathInfo pathInfoParam = GetPathInfoParam("pathInfo", args);
            string           commandParam  = GetCommandParam("name", args);

            FileSystemProvider.CreateDirectory(pathInfoParam, commandParam);
            return(null);
        }
Example #5
0
        private object ExecuteRenameCommand(IDictionary <string, object> args)
        {
            FileItemPathInfo pathInfoParam = GetPathInfoParam("pathInfo", args);
            string           commandParam  = GetCommandParam("name", args);

            ValidateFileExtension(commandParam);
            FileSystemProvider.Rename(pathInfoParam, commandParam);
            return(null);
        }
Example #6
0
        private static FileItemPathInfo[] GetPathInfoListParam(string key, IDictionary <string, object> args)
        {
            JArray jArray = args.ContainsKey(key) ? (args[key] as JArray) : null;

            if (jArray == null)
            {
                return(new FileItemPathInfo[0]);
            }
            return((from JArray rawInfo in jArray
                    select FileItemPathInfo.Create(rawInfo)).ToArray());
        }
Example #7
0
 private object ExecuteDownloadCommand(IDictionary <string, object> args)
 {
     FileItemPathInfo[] pathInfoListParam = GetPathInfoListParam("pathInfoList", args);
     if (pathInfoListParam.Length == 0)
     {
         return(null);
     }
     if (pathInfoListParam.Length == 1)
     {
         FileItemPathInfo pathInfo = pathInfoListParam[0];
         return(GetFileContentResult(pathInfo));
     }
     return(CreateZipArchive(pathInfoListParam));
 }
        public Stream GetFileContent(FileItemPathInfo pathInfo)
        {
            string path = pathInfo?.GetPath();
            string text = Path.Combine(RootDirectoryPath, PreparePath(path));

            if (Path.GetDirectoryName(text) == null)
            {
                _ = string.Empty;
            }
            if (FileSystemService.FileExists(text))
            {
                return(FileSystemService.GetFileContent(text));
            }
            FileManagementExceptionExecutor.ThrowFileNotFound(text);
            return(null);
        }
Example #9
0
 private static FileItemPathInfo GetPathInfoParam(string key, IDictionary <string, object> args)
 {
     return(FileItemPathInfo.Create(args.ContainsKey(key) ? (args[key] as JArray) : null));
 }
Example #10
0
        private FileContentResult GetFileContentResult(FileItemPathInfo pathInfo)
        {
            string fileItemName = pathInfo.GetFileItemName();

            return(new FileContentResult(FileSystemProvider.GetFileContent(pathInfo), fileItemName));
        }
Example #11
0
 public void CreateDirectory(FileItemPathInfo pathInfo, string name)
 {
     CreateDirectory(pathInfo?.GetPath(), name);
 }
Example #12
0
 public IList <IClientFileSystemItem> GetDirectoryContents(FileItemPathInfo pathInfo)
 {
     return(GetDirectoryContents(pathInfo?.GetPath()));
 }
Example #13
0
 public void Remove(FileItemPathInfo pathInfo)
 {
     Remove(pathInfo?.GetPath());
 }
Example #14
0
 public void Copy(FileItemPathInfo sourcePathInfo, FileItemPathInfo destinationPathInfo)
 {
     Copy(sourcePathInfo?.GetPath(), destinationPathInfo?.GetPath());
 }
Example #15
0
 public void Move(FileItemPathInfo sourcePathInfo, FileItemPathInfo destinationPathInfo)
 {
     Move(sourcePathInfo?.GetPath(), destinationPathInfo?.GetPath());
 }
Example #16
0
 public void Rename(FileItemPathInfo pathInfo, string newName)
 {
     Rename(pathInfo?.GetPath(), newName);
 }