equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
25 #include "java.h" |
25 #include "java.h" |
26 |
26 |
27 /* |
27 /* |
28 * Find the last occurrence of a string |
28 * Find the last occurrence of a string |
29 */ |
29 */ |
30 char* findLastPathComponent(char *buffer, const char *comp) { |
30 static char* findLastPathComponent(char *buffer, const char *comp) { |
31 char* t = buffer; |
31 char* t = buffer; |
32 char* p = NULL; |
32 char* p = NULL; |
33 size_t l = JLI_StrLen(comp); |
33 size_t l = JLI_StrLen(comp); |
34 t = JLI_StrStr(t, comp); |
34 t = JLI_StrStr(t, comp); |
35 |
35 |
45 * Removes the trailing file name and any intermediate platform |
45 * Removes the trailing file name and any intermediate platform |
46 * directories, if any, and its enclosing directory. |
46 * directories, if any, and its enclosing directory. |
47 * Ex: if a buffer contains "/foo/bin/javac" or "/foo/bin/x64/javac", the |
47 * Ex: if a buffer contains "/foo/bin/javac" or "/foo/bin/x64/javac", the |
48 * truncated resulting buffer will contain "/foo". |
48 * truncated resulting buffer will contain "/foo". |
49 */ |
49 */ |
50 jboolean |
50 static jboolean |
51 TruncatePath(char *buf) |
51 TruncatePath(char *buf) |
52 { |
52 { |
53 // try bin directory, maybe an executable |
53 // try bin directory, maybe an executable |
54 char *p = findLastPathComponent(buf, "/bin/"); |
54 char *p = findLastPathComponent(buf, "/bin/"); |
55 if (p != NULL) { |
55 if (p != NULL) { |