(linenum→info "unix/slp.c:2238")

gauche/0.8.12/src/getdir_win.c

    1: /*
    2:  * getdir_win.c - get the library directory at runtime (fow windows)
    3:  *  included from paths.c
    4:  *
    5:  * $Id: getdir_win.c,v 1.6 2007/10/05 20:35:13 shirok Exp $
    6:  */
    7: 
    8: #include <string.h>
    9: 
   10: static int get_install_dir(char *buf, int buflen,
   11:                            void (*errfn)(const char *msg, ...))
   12: {
   13:     HMODULE mod;
   14:     DWORD r;
   15:     int len;
   16:     const char *mbpath;
   17:     TCHAR path[MAX_PATH];
   18:     const TCHAR *libname = _T("libgauche.dll");
   19: 
   20:     if ((mod = GetModuleHandle(libname)) == NULL) {
   21:         errfn("GetModuleHandle failed");
   22:     }
   23:     if ((r = GetModuleFileName(mod, path, MAX_PATH)) == 0) {
   24:         errfn("GetModuleFileName failed");
   25:     }
   26:     /* remove \libgauche.dll */
   27:     if (!PathRemoveFileSpec(path)) {
   28:         errfn("PathRemoveFileSpec failed on %s", SCM_WCS2MBS(path));
   29:     }
   30:     /* remove \bin */
   31:     if (!PathRemoveFileSpec(path)) {
   32:         errfn("PathRemoveFileSpec failed on %s", SCM_WCS2MBS(path));
   33:     }
   34:     mbpath = SCM_WCS2MBS(path);
   35:     len = (int)strlen(mbpath);
   36:     if (len >= buflen-1) {
   37:         errfn("Pathname too long: %s", mbpath);
   38:     }
   39:     strcpy(buf, mbpath);
   40:     return len;
   41: }
Syntax (Markdown)