예제 #1
0
파일: files.c 프로젝트: howard5888/wineT
/* downloads a remote cabinet and extracts it if it exists */
static UINT msi_extract_remote_cabinet( MSIPACKAGE *package, struct media_info *mi )
{
    FDICABINETINFO cabinfo;
    WCHAR temppath[MAX_PATH];
    WCHAR src[MAX_PATH];
    LPSTR cabpath;
    LPCWSTR file;
    LPWSTR ptr;
    HFDI hfdi;
    ERF erf;
    int hf;

    /* the URL is the path prefix of the package URL and the filename
     * of the file to download
     */
    ptr = strrchrW(package->PackagePath, '/');
    lstrcpynW(src, package->PackagePath, ptr - package->PackagePath + 2);
    ptr = strrchrW(mi->source, '\\');
    lstrcatW(src, ptr + 1);

    file = msi_download_file( src, temppath );
    lstrcpyW(mi->source, file);

    /* check if the remote cabinet still exists, ignore if it doesn't */
    hfdi = FDICreate(cabinet_alloc, cabinet_free, cabinet_open, cabinet_read,
                     cabinet_write, cabinet_close, cabinet_seek, 0, &erf);
    if (!hfdi)
    {
        ERR("FDICreate failed\n");
        return ERROR_FUNCTION_FAILED;
    }

    cabpath = strdupWtoA(mi->source);
    hf = cabinet_open(cabpath, _O_RDONLY, 0);
    if (!FDIIsCabinet(hfdi, hf, &cabinfo))
    {
        WARN("Remote cabinet %s does not exist.\n", debugstr_w(mi->source));
        msi_free(cabpath);
        return ERROR_SUCCESS;
    }

    msi_free(cabpath);
    return !extract_cabinet_file(package, mi->source, mi->last_path);
}
예제 #2
0
파일: files.c 프로젝트: NVIDIA/winex_lgpl
static UINT ready_media(MSIPACKAGE *package, MSIFILE *file, struct media_info *mi)
{
    UINT rc = ERROR_SUCCESS;

    /* media info for continuous cabinet is already loaded */
    if (mi->is_continuous)
        return ERROR_SUCCESS;

    rc = load_media_info(package, file, mi);
    if (rc != ERROR_SUCCESS)
    {
        ERR("Unable to load media info\n");
        return ERROR_FUNCTION_FAILED;
    }

    /* cabinet is internal, no checks needed */
    if (!mi->cabinet || mi->cabinet[0] == '#')
        return ERROR_SUCCESS;

    /* package should be downloaded */
    if (file->IsCompressed &&
        GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES &&
        package->BaseURL && UrlIsW(package->BaseURL, URLIS_URL))
    {
        WCHAR temppath[MAX_PATH];

        msi_download_file(mi->source, temppath);
        lstrcpyW(mi->source, temppath);
        return ERROR_SUCCESS;
    }

    /* check volume matches, change media if not */
    if (mi->volume_label && mi->disk_id > 1 &&
        lstrcmpW(mi->first_volume, mi->volume_label))
    {
        LPWSTR source = msi_dup_property(package, cszSourceDir);
        BOOL matches;

        matches = source_matches_volume(mi, source);
        msi_free(source);

        if ((mi->type == DRIVE_CDROM || mi->type == DRIVE_REMOVABLE) && !matches)
        {
            rc = msi_change_media(package, mi);
            if (rc != ERROR_SUCCESS)
                return rc;
        }
    }

    if (file->IsCompressed &&
        GetFileAttributesW(mi->source) == INVALID_FILE_ATTRIBUTES)
    {
        /* FIXME: this might be done earlier in the install process */
        rc = find_published_source(package, mi);
        if (rc != ERROR_SUCCESS)
        {
            ERR("Cabinet not found: %s\n", debugstr_w(mi->source));
            return ERROR_INSTALL_FAILURE;
        }
    }

    return ERROR_SUCCESS;
}