Ejemplo n.º 1
0
Archivo: erl.c Proyecto: Airon2014/otp
static wchar_t *find_erlexec_dir2(wchar_t *install_dir) 
{
    /* List install dir and look for latest erts-vsn */

    HANDLE dir_handle;	        /* Handle to directory. */
    wchar_t wildcard[MAX_PATH];	/* Wildcard to search for. */
    WIN32_FIND_DATAW find_data;  /* Data found by FindFirstFile() or FindNext(). */
    wchar_t latest_vsn[MAX_PATH];

    /* Setup wildcard */
    int length = wcslen(install_dir);
    wchar_t *p;

    if (length+3 >= MAX_PATH) {
	error("Cannot find erlexec.exe");
    }

    wcscpy(wildcard, install_dir);
    p = wildcard+length-1;
    if (*p != L'/' && *p != L'\\')
	*++p = L'\\';
    wcscpy(++p, L"erts-*");

    /* Find first dir */
    dir_handle = FindFirstFileW(wildcard, &find_data);
    if (dir_handle == INVALID_HANDLE_VALUE) {
	/* No erts-vsn found*/
	return NULL;
    }	
    wcscpy(latest_vsn, find_data.cFileName);

    /* Find the rest */
    while(FindNextFileW(dir_handle, &find_data)) {
	copy_latest_vsn(latest_vsn, find_data.cFileName);
    }
    
    FindClose(dir_handle);

    p = (wchar_t *) malloc((wcslen(install_dir)+1+wcslen(latest_vsn)+4+1)*sizeof(wchar_t));

    wcscpy(p,install_dir);
    wcscat(p,L"\\");
    wcscat(p,latest_vsn);
    wcscat(p,L"\\bin");
    return p;
}
Ejemplo n.º 2
0
static char *
find_erts_vsn(char *erl_top)
{
    /* List install dir and look for latest erts-vsn */
    DIR *dp;                    /* Pointer to directory structure. */
    struct dirent* dirp;        /* Pointer to directory entry.     */
    char latest_vsn[PATH_MAX];  /* Latest erts-vsn directory name. */

    dp = opendir(erl_top);
    if (dp == NULL) {
        return NULL;
    }

    latest_vsn[0] = '\0';
    for (;;) {
        dirp = readdir(dp);
        if (dirp == NULL) {
            closedir(dp);
            break;
        }
        if (strncmp("erts-", dirp->d_name, 5) == 0) {
	    copy_latest_vsn(latest_vsn, dirp->d_name);
        }
    }

    if (latest_vsn[0] == '\0') {
        return NULL;
    } else {
	char *p = malloc((strlen(erl_top)+1+strlen(latest_vsn)+4+1)*sizeof(char));
        strcpy(p,erl_top);
        strcat(p,DIRSEP);
        strcat(p,latest_vsn);
        strcat(p,DIRSEP);
        strcat(p,"bin");
        return p;
    }
}