-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSetupHelper.cs
99 lines (83 loc) · 3.21 KB
/
SetupHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
namespace ESPEDfGK
{
//*****************************************************************************************
internal class FileListGetter
{
//*****************************************************************************************
public string[] filelist(string path, string pattern)
{
try
{
return Directory.GetFiles(path, pattern, SearchOption.AllDirectories);
}
catch
{
return new string[0];
}
}
//*****************************************************************************************
public string[] filelistNewAtTop(string[] fl)
{
if (fl.Length > 1) // eine einfache suche, erstes element austauschen
{
int i = 0;
DateTime md = File.GetLastWriteTime(fl[0]);
for (int j = 1; j < fl.Length; j++)
{
DateTime nmd = File.GetLastWriteTime(fl[j]);
if (nmd > md)
{
i = j;
md = nmd;
}
}
if (i > 0)
{
string s = fl[0];
fl[0] = fl[i];
fl[i] = s;
}
}
return fl;
}
}
//*****************************************************************************************
internal class Addr2LineInfo
{
public string filepath { get; set; }
public string fileinfo { get; set; }
}
//*****************************************************************************************
internal class Addr2LineList : ObservableCollection<Addr2LineInfo> { }
//*****************************************************************************************
internal class SetupHelper
{
//*****************************************************************************************
public Addr2LineList findAddr2LineExe()
{
string pArduino = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
Path.DirectorySeparatorChar + StringContent.arduino15;
string pPlatformIO = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) +
Path.DirectorySeparatorChar + StringContent.platformio;
FileListGetter flg = new();
string[] res = flg.filelist(pArduino, StringContent.xtensaaddr2line);
string[] resPIO = flg.filelist(pPlatformIO, StringContent.xtensaaddr2line);
res = res.Union(resPIO).ToArray();
// Build list
Addr2LineList reslist = new();
foreach (string f in res)
{
Addr2LineInfo info = new();
info.filepath = f;
info.fileinfo = File.GetCreationTime(f).ToString() + " " +
(new System.IO.FileInfo(f).Length).ToString()+" B";
reslist.Add(info);
}
return reslist;
}
}
}