version 1.36, 2017/06/12 06:22:50 |
version 1.37, 2017/09/02 04:04:41 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/file.c,v 1.35 2017/06/10 05:32:24 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/file.c,v 1.36 2017/06/12 06:22:50 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
#include "ox.h" |
#include "ox.h" |
#include "base.h" |
#include "base.h" |
|
#include <stdlib.h> |
#if !defined(VISUAL) && !defined(__MINGW32__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
#include "unistd.h" |
#include "unistd.h" |
#endif |
#endif |
Line 515 void Pbload_cmo(NODE arg,Obj *rp) |
|
Line 516 void Pbload_cmo(NODE arg,Obj *rp) |
|
static struct oSTRING rootdir; |
static struct oSTRING rootdir; |
|
|
#if defined(VISUAL) || defined(__MINGW32__) |
#if defined(VISUAL) || defined(__MINGW32__) |
|
static void chop_delim(char *s) |
|
{ |
|
int n=strlen(s); |
|
if(n>1 && s[n-1]=='\\') { |
|
s[n-1]=0; |
|
} |
|
} |
|
|
void get_rootdir(char *name,int len) |
void get_rootdir(char *name,int len) |
{ |
{ |
LONG ret; |
LONG ret; |
HKEY hOpenKey; |
HKEY hOpenKey; |
DWORD Type; |
DWORD Type; |
char *slash; |
char drive[_MAX_DRIVE], dir0[_MAX_DIR], dir[_MAX_DIR]; |
|
char fullname[_MAX_PATH]; |
|
|
if ( rootdir.body ) { |
if ( rootdir.body ) { |
strcpy(name,rootdir.body); |
strcpy_s(name,len,rootdir.body); |
return; |
return; |
} |
} |
if ( GetModuleFileName(NULL,name,BUFSIZ) ) { |
if ( GetModuleFileName(NULL,fullname,_MAX_PATH) ) { |
slash = strrchr(name,'\\'); |
_splitpath(fullname,drive,dir0,NULL,NULL); |
*slash = 0; |
chop_delim(dir0); |
slash = strrchr(name,'\\'); |
_splitpath(dir0,NULL,dir,NULL,NULL); |
if ( slash ) |
chop_delim(dir); |
*slash = 0; |
strcpy_s(name,len,drive); |
|
strcat_s(name,len,dir); |
return; |
return; |
} |
} |
name[0] = 0; |
name[0] = 0; |
Line 544 void get_rootdir(char *name,int len) |
|
Line 555 void get_rootdir(char *name,int len) |
|
RegQueryValueEx(hOpenKey, "Directory", NULL, &Type, name, &len); |
RegQueryValueEx(hOpenKey, "Directory", NULL, &Type, name, &len); |
RegCloseKey(hOpenKey); |
RegCloseKey(hOpenKey); |
} else { |
} else { |
GetCurrentDirectory(len,name); |
GetCurrentDirectory(_MAX_PATH,fullname); |
slash = strrchr(name,'\\'); |
_splitpath(fullname,drive,dir,NULL,NULL); |
if ( slash ) |
chop_delim(dir); |
*slash = 0; |
strcpy_s(name,len,drive); |
|
strcat_s(name,len,dir); |
} |
} |
} |
} |
|
|