52 using namespace cacao;
65 #if defined(_DIRENT_HAVE_D_NAMLEN)
68 namlen = strlen(a->d_name);
71 if ((strncasecmp(a->d_name + namlen - 4,
".zip", 4) == 0) ||
72 (strncasecmp(a->d_name + namlen - 4,
".jar", 4) == 0))
91 for (start = classpath; (*start) !=
'\0'; ) {
94 for (end = start; ((*end) !=
'\0') && ((*end) !=
':'); end++);
98 size_t filenamelen = end - start;
100 if (filenamelen > 4) {
101 if ((strncasecmp(end - 4,
".zip", 4) == 0) ||
102 (strncasecmp(end - 4,
".jar", 4) == 0)) {
114 cwdlen = strlen(cwd) + strlen(
"/");
119 char *filename =
MNEW(
char, filenamelen + cwdlen + strlen(
"/") + strlen(
"0"));
122 strcpy(filename, cwd);
123 strcat(filename,
"/");
124 strncat(filename, start, filenamelen);
127 filenamelen += cwdlen;
130 strncpy(filename, start, filenamelen);
131 filename[filenamelen] =
'\0';
135 #if defined(ENABLE_ZLIB)
141 lce->
path = filename;
147 printf(
"[Opened %s]\n", filename);
152 os::abort(
"suck_add: zip/jar files not supported");
156 if (filename[filenamelen - 1] !=
'/') {
157 filename[filenamelen] =
'/';
158 filename[filenamelen + 1] =
'\0';
165 lce->
path = filename;
192 struct dirent **namelist;
197 char* boot_class_path = NULL;
201 value = properties.
get(key);
208 for (start = value; (*start) !=
'\0'; ) {
212 for (end = start; ((*end) !=
'\0') && ((*end) !=
':'); end++);
219 pathlen = end - start;
220 char* path =
MNEW(
char, pathlen + strlen(
"0"));
224 strncpy(path, start, pathlen);
225 path[pathlen] =
'\0';
239 for (i = 0; i < n; i++) {
240 #if defined(_DIRENT_HAVE_D_NAMLEN)
241 namlen = namelist[
i]->d_namlen;
243 namlen = strlen(namelist[i]->d_name);
246 if (boot_class_path == NULL) {
249 pathlen + strlen(
"/") + namlen +
254 strcat(p, namelist[i]->d_name);
259 pathlen + strlen(
"/") + namlen +
261 strlen(boot_class_path) +
266 strcpy(p, boot_class_path);
270 strcat(p, namelist[i]->d_name);
272 MFREE(boot_class_path,
char, strlen(boot_class_path));
289 if (namelist != NULL)
292 MFREE(path,
char, pathlen + strlen(
"0"));
303 if (boot_class_path != NULL) {
307 char* old_boot_class_path = (
char*) properties.
get(
"sun.boot.class.path");
310 strlen(boot_class_path) +
312 strlen(old_boot_class_path) +
317 strcpy(p, boot_class_path);
319 strcat(p, old_boot_class_path);
321 MFREE(boot_class_path,
char, strlen(boot_class_path));
322 MFREE(old_boot_class_path,
char, strlen(old_boot_class_path));
325 properties.
put(
"sun.boot.class.path", p);
326 properties.
put(
"java.boot.class.path", p);
336 this->
end = data + sz;
341 init(clazz, data, sz, path);
352 init(NULL, NULL, 0, NULL);
357 size_t filenamelen = c->
name.
size() + strlen(
".class") + strlen(
"0");
370 for (SuckClasspath::iterator it = suckclasspath.begin(); it != suckclasspath.end(); it++) {
373 #if defined(ENABLE_ZLIB)
382 size_t size = zip->uncompressedsize;
383 uint8_t *
data =
MNEW(uint8_t, size);
398 struct stat stat_buffer;
403 size_t size = stat_buffer.st_size;
407 size_t bytes_read =
os::fread(data, 1, size, classfile);
410 if (bytes_read != size) {
418 #if defined(ENABLE_ZLIB)
425 dolog(
"Warning: Can not open class file '%s'", filename.
c_str());
static FILE * fopen(const char *path, const char *mode)
void init(classinfo *, uint8_t *, size_t, const char *)
static size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
ClassBuffer(Utf8String classname)
Locate and load class file for class.
static int scandir_filter(const struct dirent *a)
void reset()
Reset buffer position to start of buffer.
const char * c_str()
get contents of buffer as zero-terminated c-style-string This strings lifetime is tied to it's buffer...
static int stat(const char *path, struct stat *buf)
void add_from_property(const char *key)
Adds a classpath form a property entry to the global classpath entries list.
JNIEnv jthread jobject jclass jlong size
ClassFileVersion version() const
cacao::ClassFileVersion version
A version of the Java class file format.
static int fclose(FILE *fp)
Properties & get_properties()
static char * getcwd(void)
Return the current working directory.
EntryRef find(Utf8String filename)
Find file in zip archive.
Helper class used to implicitly acquire and release a mutex within a method scope.
void free()
Free memory held by this classbuffer.
void add(char *classpath)
Adds a classpath to the global classpath entries list.
SuckClasspath & get_suckclasspath()
static ZipFile * open(const char *path)
Load zip archive.
static int scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *))
#define MFREE(ptr, type, num)
static void put(java_handle_t *p, const char *key, const char *value)
Add the given property to the given Java system properties.
const char * get(const char *key)
Get a property entry from the internal property map.
static VM * get_current()