예제 #1
0
 /// <summary>
 /// Creates the row given the directory name.
 /// </summary>
 /// <param name="bucket">The bucket that owns the directory.</param>
 /// <param name="name">The name (path) to the directory.</param>
 /// <returns>The newly created <seealso cref="GcsRow"/>.</returns>
 public static GcsRow CreateDirectoryRow(string bucket, string name) =>
 new GcsRow
 {
     Bucket        = bucket,
     BlobName      = name,
     LeafName      = GcsPathUtils.GetFileName(name),
     FormattedSize = NoValuePlaceholder,
     LastModified  = NoValuePlaceholder,
     ContentType   = NoValuePlaceholder,
     IsDirectory   = true,
 };
예제 #2
0
 /// <summary>
 /// Creates a file row from the given GCS <seealso cref="Object"/>.
 /// </summary>
 /// <param name="obj">The GCS <seealso cref="Object"/></param>
 /// <returns>The newly created <seealso cref="GcsRow"/>.</returns>
 public static GcsRow CreateFileRow(Object obj) =>
 new GcsRow
 {
     Bucket        = obj.Bucket,
     BlobName      = obj.Name,
     IsFile        = true,
     Size          = obj.Size.HasValue ? obj.Size.Value : 0L,
     FormattedSize = obj.Size.HasValue ? FormatSize(obj.Size.Value) : NoValuePlaceholder,
     LastModified  = obj.Updated?.ToString() ?? NoValuePlaceholder,
     LeafName      = GcsPathUtils.GetFileName(obj.Name),
     ContentType   = obj.ContentType ?? DefaultContentType,
 };
예제 #3
0
        private async void OnRenameFileCommand()
        {
            var choosenName = NamePromptWindow.PromptUser(new NamePromptWindow.Options
            {
                InitialName = SelectedItem.LeafName,
                Title       = Resources.GcsFileBrowserRenameFileTitle
            });

            if (choosenName == null)
            {
                return;
            }

            try
            {
                IsLoading = true;

                var newName = GcsPathUtils.Combine(CurrentState.CurrentPath, choosenName);
                Debug.WriteLine($"Renaming {SelectedItem.BlobName} to {newName}");
                await ProgressDialogWindow.PromptUser(
                    _dataSource.MoveFileAsync(
                        bucket: Bucket.Name,
                        sourceName: SelectedItem.BlobName,
                        destName: newName),
                    new ProgressDialogWindow.Options
                {
                    Message       = Resources.GcsFileBrowserRenamingProgressMessage,
                    Title         = Resources.UiDefaultPromptTitle,
                    IsCancellable = false
                });

                EventsReporterWrapper.ReportEvent(GcsFileBrowserRenameFileEvent.Create(CommandStatus.Success));
            }
            catch (DataSourceException ex)
            {
                UserPromptUtils.ErrorPrompt(
                    message: string.Format(Resources.GcsFileBrowserRenameFailedMessage, SelectedItem.LeafName),
                    title: Resources.UiErrorCaption,
                    errorDetails: ex.Message);

                EventsReporterWrapper.ReportEvent(GcsFileBrowserRenameFileEvent.Create(CommandStatus.Failure));
            }
            finally
            {
                IsLoading = false;
            }

            UpdateCurrentState();
        }
 private void ParsePathSteps(string name)
 {
     if (String.IsNullOrEmpty(name))
     {
         PathSteps = Enumerable.Empty <PathStep>();
     }
     else
     {
         Debug.Assert(name.Last() == '/');
         var    stepNames   = GcsPathUtils.Parse(name);
         var    steps       = new List <PathStep>();
         string currentPath = "";
         foreach (var stepName in stepNames)
         {
             currentPath = currentPath + $"{stepName}/";
             steps.Add(new PathStep(name: stepName, path: currentPath));
         }
         PathSteps = steps;
     }
 }