Skip to content

Commit

Permalink
Fix "Open" manga by external program
Browse files Browse the repository at this point in the history
  • Loading branch information
riderkick committed Apr 23, 2015
1 parent 6fa34a6 commit dec4025
Showing 1 changed file with 46 additions and 43 deletions.
89 changes: 46 additions & 43 deletions mangadownloader/forms/frmMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2603,27 +2603,30 @@ procedure TMainForm.miOpenWith2Click(Sender: TObject);
Exit;
l := TStringList.Create;
Process := TProcessUTF8.Create(nil);
s := StringReplace(Favorites.favoriteInfo[vtFavorites.FocusedNode^.Index].SaveTo,
'/', '\', [rfReplaceAll]);

if s[Length(s)] <> '\' then
s := s + '\';
if FindFirstUTF8(s + '*', faAnyFile and faDirectory, Info) = 0 then
repeat
l.Add(Info.Name);
until FindNextUTF8(Info) <> 0;
if l.Count >= 3 then
f := l.Strings[2]
else
f := '';
FindClose(Info);
l.Free;
try
s := StringReplace(Favorites.favoriteInfo[vtFavorites.FocusedNode^.Index].SaveTo,
'/', '\', [rfReplaceAll]);

if s[Length(s)] <> '\' then
s := s + '\';
if FindFirstUTF8(s + '*', faAnyFile and faDirectory, Info) = 0 then
repeat
l.Add(Info.Name);
until FindNextUTF8(Info) <> 0;
if l.Count >= 3 then
f := l.Strings[2]
else
f := '';
FindClose(Info);

s := StringReplace(edOptionExternal.Text, '%PATH%', s, [rfReplaceAll]);
s := StringReplace(s, '%FCHAPTER%', f, [rfReplaceAll]);
Process.CommandLine := s;
Process.Execute;
Process.Free;
s := StringReplace(edOptionExternal.Text, '%PATH%', s, [rfReplaceAll]);
s := StringReplace(s, '%FCHAPTER%', f, [rfReplaceAll]);
Process.CommandLine := s;
Process.Execute;
finally
l.Free;
Process.Free;
end;
end;

procedure TMainForm.miOpenWithClick(Sender: TObject);
Expand All @@ -2635,32 +2638,32 @@ procedure TMainForm.miOpenWithClick(Sender: TObject);
begin
if (not Assigned(vtDownload.FocusedNode)) or (edOptionExternal.Text = '') then
Exit;
if (not FileExists(ExtractWord(1, edOptionExternal.Text, [' ']))) then
Exit;

l := TStringList.Create;
Process := TProcessUTF8.Create(nil);
s := StringReplace(DLManager.containers.Items[
vtDownload.FocusedNode^.Index].DownloadInfo.SaveTo, '/', '\', [rfReplaceAll]);

if s[Length(s)] <> '\' then
s := s + '\';
if FindFirstUTF8(s + '*', faAnyFile and faDirectory, Info) = 0 then
repeat
l.Add(Info.Name);
until FindNextUTF8(Info) <> 0;
if l.Count >= 3 then
f := l.Strings[2]
else
f := '';
FindClose(Info);
l.Free;
try
s := StringReplace(DLManager.containers.Items[
vtDownload.FocusedNode^.Index].DownloadInfo.SaveTo, '/', '\', [rfReplaceAll]);

if s[Length(s)] <> '\' then
s := s + '\';
if FindFirstUTF8(s + '*', faAnyFile and faDirectory, Info) = 0 then
repeat
l.Add(Info.Name);
until FindNextUTF8(Info) <> 0;
if l.Count >= 3 then
f := l.Strings[2]
else
f := '';
FindClose(Info);

s := StringReplace(edOptionExternal.Text, '%PATH%', s, [rfReplaceAll]);
s := StringReplace(s, '%FCHAPTER%', f, [rfReplaceAll]);
Process.CommandLine := s;
Process.Execute;
Process.Free;
s := StringReplace(edOptionExternal.Text, '%PATH%', s, [rfReplaceAll]);
s := StringReplace(s, '%FCHAPTER%', f, [rfReplaceAll]);
Process.CommandLine := s;
Process.Execute;
finally
l.Free;
Process.Free;
end;
end;

procedure TMainForm.pcMainChange(Sender: TObject);
Expand Down

0 comments on commit dec4025

Please sign in to comment.