Skip to content

Commit

Permalink
Merge pull request #191 from DineshSolanki/fix-icon-name-for-unicode-…
Browse files Browse the repository at this point in the history
…characters

Use "folicon.ico" instead of folder name for icons
  • Loading branch information
DineshSolanki authored Feb 14, 2024
2 parents 2961930 + 2ca1d64 commit 1920e54
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion FoliCon/Modules/IGDB/IgdbDataTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void ResultPicked(Game game, string fullFolderPath, string rating = "")
{
ValidateGamePoster(game);
var folderName = Path.GetFileName(fullFolderPath);
var localPosterPath = $@"{fullFolderPath}\{folderName}.png";
var localPosterPath = $@"{fullFolderPath}\{IconUtils.GetImageName()}.png";
HandleGamePosterPath(game, fullFolderPath, localPosterPath, rating, folderName);
}

Expand Down
2 changes: 1 addition & 1 deletion FoliCon/Modules/TMDB/TmdbDataTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat
}

var folderName = Path.GetFileName(fullFolderPath);
var localPosterPath = fullFolderPath + @"\" + folderName + ".png";
var localPosterPath = $@"{fullFolderPath}\{IconUtils.GetImageName()}.png";

string posterUrl = string.Concat(PosterBase, result.PosterPath.Replace("http://image.tmdb.org/t/p/w500",""));

Expand Down
6 changes: 3 additions & 3 deletions FoliCon/Modules/utils/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static void DeleteIconsFromSubfolders(string folderPath)
public static void DeleteIconsFromFolder(string folderPath)
{
Logger.Debug("Deleting Icons from: {FolderPath}", folderPath);
var folderName = Path.GetFileName(folderPath);
var icoFile = Path.Combine(folderPath, $"{folderName}.ico");

var icoFile = Path.Combine(folderPath, $"{IconUtils.GetImageName()}.ico");
var iniFile = Path.Combine(folderPath, "desktop.ini");
try
{
Expand Down Expand Up @@ -94,7 +94,7 @@ public static List<string> GetFolderNames(string folderPath)
if (!string.IsNullOrEmpty(folderPath))
{
folderNames.AddRange(from folder in Directory.GetDirectories(folderPath)
where !File.Exists(folder + @"\" + Path.GetFileName(folder) + ".ico")
where !File.Exists($@"{folder}\{IconUtils.GetImageName()}.ico")
select Path.GetFileName(folder));
}

Expand Down
13 changes: 9 additions & 4 deletions FoliCon/Modules/utils/IconUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ namespace FoliCon.Modules.utils;
public static class IconUtils
{
private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger();

private const string ImageName = "folicon";

public static string GetImageName()
{
return ImageName;
}
/// <summary>
/// Creates Icons from PNG
/// </summary>
Expand All @@ -28,8 +33,8 @@ public static int MakeIco(string iconMode, string selectedFolder, List<PickedLis
foreach (var item in pickedListDataTable)
{
var folderName = item.FolderName;
var targetFile = $@"{selectedFolder}\{folderName}\{folderName}.ico";
var pngFilePath = $@"{selectedFolder}\{folderName}\{folderName}.png";
var targetFile = $@"{selectedFolder}\{folderName}\{ImageName}.ico";
var pngFilePath = $@"{selectedFolder}\{folderName}\{ImageName}.png";
if (File.Exists(pngFilePath) && !File.Exists(targetFile))
{
var rating = item.Rating;
Expand All @@ -46,7 +51,7 @@ public static int MakeIco(string iconMode, string selectedFolder, List<PickedLis
}
if (!File.Exists(targetFile)) continue;
FileUtils.HideFile(targetFile);
FileUtils.SetFolderIcon($"{folderName}.ico", $@"{selectedFolder}\{folderName}");
FileUtils.SetFolderIcon($"{ImageName}.ico", $@"{selectedFolder}\{folderName}");
}

FileUtils.ApplyChanges(selectedFolder);
Expand Down
2 changes: 1 addition & 1 deletion FoliCon/ViewModels/ProSearchResultViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private void PickMethod(object parameter)
var currentPath = $@"{_folderPath}\{Fnames[_i]}";
var tempImage = new ImageToDownload
{
LocalPath = $"{currentPath}\\{Fnames[_i]}.png",
LocalPath = $"{currentPath}\\{IconUtils.GetImageName()}.png",
RemotePath = new Uri(link)
};
Logger.Debug("Adding Image to Download List {@Image}", tempImage);
Expand Down

0 comments on commit 1920e54

Please sign in to comment.