Skip to content

Commit 0976187

Browse files
committed
#26 상대 경로 기능이 정상 동작하지 않는 문제 수정
1 parent 40f1663 commit 0976187

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

DaramRenamer.Commands/Commands/FilePath/RelativeGoToCommand.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ namespace DaramRenamer.Commands.FilePath
77
[Serializable, LocalizationKey("Command_Name_RelativeGoTo")]
88
public class RelativeGoToCommand : ICommand
99
{
10+
private const string CurrentDirectory = ".";
11+
private const string PreviousDirectory = "..";
12+
1013
public bool ParallelProcessable => true;
1114
public CommandCategory Category => CommandCategory.Path;
1215

@@ -15,7 +18,19 @@ public class RelativeGoToCommand : ICommand
1518

1619
public bool DoCommand(FileInfo file)
1720
{
18-
file.ChangedPath = System.IO.Path.Combine(file.ChangedPath, Path);
21+
var temp = new List<string>(System.IO.Path.Combine(file.ChangedPath, Path).Split('/', '\\'));
22+
temp.RemoveAll(dir => dir == CurrentDirectory || string.IsNullOrEmpty(dir));
23+
24+
var indexOf = -1;
25+
while ((indexOf = temp.IndexOf(PreviousDirectory)) >= 0)
26+
{
27+
if (indexOf == 0 || indexOf == 1)
28+
return false;
29+
temp.RemoveAt(indexOf);
30+
temp.RemoveAt(indexOf - 1);
31+
}
32+
33+
file.ChangedPath = string.Join(System.IO.Path.DirectorySeparatorChar, temp);
1934
return true;
2035
}
2136
}

DaramRenamer.Windows/DaramRenamer.Windows.csproj

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>WinExe</OutputType>
4-
<TargetFramework>net5.0-windows</TargetFramework>
5-
<PublishTrimmed>true</PublishTrimmed>
4+
<TargetFramework>net6.0-windows</TargetFramework>
65
<TrimMode>Link</TrimMode>
76
<UseWPF>true</UseWPF>
87
<RootNamespace>DaramRenamer</RootNamespace>
@@ -13,7 +12,7 @@
1312
<ApplicationIcon>Resources\ProgramIcon.ico</ApplicationIcon>
1413
<AssemblyName>DaramRenamer</AssemblyName>
1514
<Copyright>Copyright ⓒ 2013-2021 Jin Jae-yeon</Copyright>
16-
<Version>2021.7.2</Version>
15+
<Version>2021.11.1</Version>
1716
<SignAssembly>true</SignAssembly>
1817
<AssemblyOriginatorKeyFile>../Modules/StrongNameKey/Daelumgi.snk</AssemblyOriginatorKeyFile>
1918
<ApplicationManifest>DaramRenamer.manifest</ApplicationManifest>

0 commit comments

Comments
 (0)