Browse Source

kernel: search in `pwd`/kernel/ for kernels.

Closes https://github.com/veox/sgminer/issues/49.
nfactor-troky
Noel Maersk 11 years ago
parent
commit
e123cc20c3
  1. 13
      ocl.c
  2. 3
      sgminer.c

13
ocl.c

@ -41,10 +41,9 @@ char *file_contents(const char *filename, int *length) @@ -41,10 +41,9 @@ char *file_contents(const char *filename, int *length)
void *buffer;
FILE *f;
/* Try in the optional kernel path first, defaults to PREFIX */
strcpy(fullpath, opt_kernel_path);
strcat(fullpath, filename);
/* Try in the optional kernel path or installed prefix first */
f = fopen(fullpath, "rb");
if (!f) {
/* Then try from the path sgminer was called */
@ -52,12 +51,20 @@ char *file_contents(const char *filename, int *length) @@ -52,12 +51,20 @@ char *file_contents(const char *filename, int *length)
strcat(fullpath, filename);
f = fopen(fullpath, "rb");
}
if (!f) {
/* Then from `pwd`/kernel/ */
strcpy(fullpath, sgminer_path);
strcat(fullpath, "kernel/");
strcat(fullpath, filename);
f = fopen(fullpath, "rb");
}
/* Finally try opening it directly */
if (!f)
f = fopen(filename, "rb");
if (!f) {
applog(LOG_ERR, "Unable to open %s or %s for reading", filename, fullpath);
applog(LOG_ERR, "Unable to open %s or %s for reading",
filename, fullpath);
return NULL;
}

3
sgminer.c

@ -7695,8 +7695,11 @@ int main(int argc, char *argv[]) @@ -7695,8 +7695,11 @@ int main(int argc, char *argv[])
#else
timeBeginPeriod(1);
#endif
/* opt_kernel_path defaults to SGMINER_PREFIX */
opt_kernel_path = alloca(PATH_MAX);
strcpy(opt_kernel_path, SGMINER_PREFIX);
/* sgminer_path is current dir */
sgminer_path = alloca(PATH_MAX);
s = strdup(argv[0]);
strcpy(sgminer_path, dirname(s));

Loading…
Cancel
Save