Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions Files/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
using System.Threading;
using System.Threading.Tasks;
using Windows.ApplicationModel.DataTransfer;
using Windows.Graphics.Imaging;
using Windows.Storage;
using Windows.Storage.Streams;
using static Files.Helpers.NativeFindStorageItemHelper;
using FileAttributes = System.IO.FileAttributes;
using Microsoft.Toolkit.Uwp.Extensions;
using static Files.Helpers.NativeFindStorageItemHelper;

namespace Files.Filesystem
{
Expand Down Expand Up @@ -709,8 +708,8 @@ public async Task<ReturnResult> MoveItemsFromClipboard(DataPackageView packageVi

public async Task<ReturnResult> RenameAsync(IStorageItem source, string newName, NameCollisionOption collision, bool registerHistory)
{
FileSystemStatusCode returnCode = FileSystemStatusCode.InProgress;
Progress<FileSystemStatusCode> errorCode = new Progress<FileSystemStatusCode>();
var returnCode = FileSystemStatusCode.InProgress;
var errorCode = new Progress<FileSystemStatusCode>();
errorCode.ProgressChanged += (s, e) => returnCode = e;

IStorageHistory history = await filesystemOperations.RenameAsync(source, newName, collision, errorCode, cancellationToken);
Expand All @@ -729,7 +728,33 @@ public async Task<ReturnResult> RenameAsync(IStorageItemWithPath source, string
Progress<FileSystemStatusCode> errorCode = new Progress<FileSystemStatusCode>();
errorCode.ProgressChanged += (s, e) => returnCode = e;

IStorageHistory history = await filesystemOperations.RenameAsync(source, newName, collision, errorCode, cancellationToken);
IStorageHistory history = null;

switch (source.ItemType)
{
case FilesystemItemType.Directory:
history = await filesystemOperations.RenameAsync(source, newName, collision, errorCode, cancellationToken);
break;
case FilesystemItemType.File:
// Handle Shortcut renaming
if (Path.HasExtension(source.Path) && !Path.HasExtension(newName))
{
newName = newName + Path.GetExtension(source.Path);
}

var renameDialogText = "RenameFileDialog/Text".GetLocalized();

var yesSelected = await DialogDisplayHelper.ShowDialogAsync("Rename", renameDialogText, "Yes", "No");
if (yesSelected)
{
history = await filesystemOperations.RenameAsync(source, newName, collision, errorCode, cancellationToken);
break;
}
break;
default:
history = await filesystemOperations.RenameAsync(source, newName, collision, errorCode, cancellationToken);
break;
}

if (registerHistory && !string.IsNullOrWhiteSpace(source.Path))
{
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.ar.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.cs-CZ.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.da-DK.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.da.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
6 changes: 5 additions & 1 deletion Files/MultilingualResources/Files.de-DE.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,11 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
</xliff>
</xliff>
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.es-ES.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
8 changes: 6 additions & 2 deletions Files/MultilingualResources/Files.fr-FR.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en-US" target-language="fr-FR" original="FILES/STRINGS/EN-US/RESOURCES.RESW" tool-id="MultilingualAppToolkit" product-name="n/a" product-version="n/a" build-num="n/a">
<header>
Expand Down Expand Up @@ -2277,7 +2277,11 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
</xliff>
</xliff>
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.he-IL.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.hi-IN.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
6 changes: 5 additions & 1 deletion Files/MultilingualResources/Files.hu-HU.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,11 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
</xliff>
</xliff>
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.it-IT.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.ja-JP.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.nl-NL.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2289,6 +2289,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.or-IN.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.pl-PL.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.ru-RU.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.ta.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.tr-TR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.uk-UA.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2274,6 +2274,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
4 changes: 4 additions & 0 deletions Files/MultilingualResources/Files.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,10 @@
<source>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</source>
<target state="new">Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</target>
</trans-unit>
<trans-unit id="RenameFileDialog.Text" translate="yes" xml:space="preserve">
<source>If you change a file extension, the file might become unusable. Are you sure you want to change it?</source>
<target state="new">If you change a file extension, the file might become unusable. Are you sure you want to change it?</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
3 changes: 3 additions & 0 deletions Files/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1818,4 +1818,7 @@
<data name="SettingsShowMultiselectOption.Header" xml:space="preserve">
<value>Enable multiselect options (currently only abailable in the tiles and grid view layout modes)</value>
</data>
<data name="RenameFileDialog.Text" xml:space="preserve">
<value>If you change a file extension, the file might become unusable. Are you sure you want to change it?</value>
</data>
</root>