Skip to content

Commit 2c4f6dd

Browse files
committed
remove unnecessary FindDir/DirectoryInfo scan #54
1 parent 15c1cad commit 2c4f6dd

File tree

1 file changed

+6
-29
lines changed

1 file changed

+6
-29
lines changed

UnityLauncherPro/Tools.cs

+6-29
Original file line numberDiff line numberDiff line change
@@ -1015,10 +1015,10 @@ public static void RemoveContextMenuRegistry(string contextRegRoot)
10151015
public static string ReadGitBranchInfo(string projectPath)
10161016
{
10171017
string results = null;
1018-
DirectoryInfo dirName = FindDir(".git", projectPath);
1019-
if (dirName != null)
1018+
string dirName = Path.Combine(projectPath, ".git");
1019+
if (Directory.Exists(dirName))
10201020
{
1021-
string branchFile = Path.Combine(dirName.FullName, "HEAD");
1021+
string branchFile = Path.Combine(dirName, "HEAD");
10221022
if (File.Exists(branchFile))
10231023
{
10241024
// removes extra end of line
@@ -1034,10 +1034,10 @@ public static string ReadGitBranchInfo(string projectPath)
10341034
public static string ReadPlasticBranchInfo(string projectPath)
10351035
{
10361036
string results = null;
1037-
DirectoryInfo dirName = FindDir(".plastic", projectPath);
1038-
if (dirName != null)
1037+
string dirName = Path.Combine(projectPath, ".plastic");
1038+
if (Directory.Exists(dirName))
10391039
{
1040-
string branchFile = Path.Combine(dirName.FullName, "plastic.selector");
1040+
string branchFile = Path.Combine(dirName, "plastic.selector");
10411041
if (File.Exists(branchFile))
10421042
{
10431043
// removes extra end of line
@@ -1107,29 +1107,6 @@ public static string GetTargetPlatform(string projectPath)
11071107
}
11081108
}
11091109

1110-
/// <summary>
1111-
/// Searches for a directory beginning with "startPath".
1112-
/// If the directory is not found, then parent folders are searched until
1113-
/// either it is found or the root folder has been reached.
1114-
/// Null is returned if the directory was not found.
1115-
/// </summary>
1116-
/// <param name="dirName"></param>
1117-
/// <param name="startPath"></param>
1118-
/// <returns></returns>
1119-
public static DirectoryInfo FindDir(string dirName, string startPath)
1120-
{
1121-
DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(startPath, dirName));
1122-
while (!dirInfo.Exists)
1123-
{
1124-
if (dirInfo.Parent.Parent == null)
1125-
{
1126-
return null;
1127-
}
1128-
dirInfo = new DirectoryInfo(Path.Combine(dirInfo.Parent.Parent.FullName, dirName));
1129-
}
1130-
return dirInfo;
1131-
}
1132-
11331110
public static string ReadCustomProjectData(string projectPath, string customFile)
11341111
{
11351112
string results = null;

0 commit comments

Comments
 (0)