-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
sf100linux.rb
62 lines (55 loc) 路 1.77 KB
/
sf100linux.rb
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
class Sf100linux < Formula
desc "Linux software for Dediprog SF100 and SF600 SPI flash programmers"
homepage "https://github.com/DediProgSW/SF100Linux"
url "https://github.com/DediProgSW/SF100Linux/archive/refs/tags/V1.14.20.x.tar.gz"
sha256 "d3e710c2a4361b7a82e1fee6189e88a6a6ea149738c9cb95409f0a683e90366e"
license "GPL-2.0-or-later"
depends_on "libusb"
depends_on :macos
depends_on "pkg-config"
patch :DATA
def install
system "make"
bin.install "dpcmd"
include.install "ChipInfoDb.dedicfg"
end
test do
system "#{bin}/dpcmd", "--check"
end
end
__END__
diff --git a/parse.c b/parse.c
index c9fe9db..462c2e8 100755
--- a/parse.c
+++ b/parse.c
@@ -19,27 +19,22 @@ FILE* openChipInfoDb(void)
{
FILE* fp = NULL;
char Path[linebufsize];
+ uint32_t size = sizeof(Path);
memset(Path, 0, linebufsize);
- if (readlink("/proc/self/exe", Path, 512) != -1) {
- dirname(Path);
+ if (_NSGetExecutablePath(Path, &size) == 0) {
+ strcpy(Path, dirname(Path));
strcat(Path, "/ChipInfoDb.dedicfg");
- // printf("%s\n",Path);
if ((fp = fopen(Path, "rt")) == NULL) {
// ChipInfoDb.dedicfg not in program directory
- dirname(Path);
- dirname(Path);
- strcat(Path, "/share/DediProg/ChipInfoDb.dedicfg");
- // printf("%s\n",Path);
+ strcpy(Path, dirname(Path));
+ strcpy(Path, dirname(Path));
+ strcat(Path, "/include/ChipInfoDb.dedicfg");
if ((fp = fopen(Path, "rt")) == NULL)
fprintf(stderr, "Error opening file: %s\n", Path);
}
}
- //xml_parse_result result = doc.load_file( Path );
- //if ( result.status != xml_parse_status::status_ok )
- // return;
-
return fp;
}