示例#1
0
文件: regproc.c 项目: bdidemus/wine
/******************************************************************************
 * Open file in binary mode for export.
 */
static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
{
    FILE *file;
    WCHAR dash = '-';

    if (strncmpW(file_name,&dash,1)==0) {
        file=stdout;
        _setmode(_fileno(file), _O_BINARY);
    } else
    {
        WCHAR wb_mode[] = {'w','b',0};
        WCHAR regedit[] = {'r','e','g','e','d','i','t',0};

        file = _wfopen(file_name, wb_mode);
        if (!file) {
            _wperror(regedit);
            output_message(STRING_CANNOT_OPEN_FILE, file_name);
            exit(1);
        }
    }
    if(unicode)
    {
        const BYTE unicode_seq[] = {0xff,0xfe};
        const WCHAR header[] = {'W','i','n','d','o','w','s',' ','R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ','V','e','r','s','i','o','n',' ','5','.','0','0','\r','\n'};
        fwrite(unicode_seq, sizeof(BYTE), sizeof(unicode_seq)/sizeof(unicode_seq[0]), file);
        fwrite(header, sizeof(WCHAR), sizeof(header)/sizeof(header[0]), file);
    } else
    {
        fputs("REGEDIT4\r\n", file);
    }

    return file;
}
示例#2
0
MarFile *mar_wopen(const wchar_t *path) {
  FILE *fp;

  _wfopen_s(&fp, path, L"rb");
  if (!fp) {
    fprintf(stderr, "ERROR: could not open file in mar_wopen()\n");
    _wperror(path);
    return NULL;
  }

  return mar_fpopen(fp);
}
示例#3
0
void platformInit(int*, char***)
{
    // Set stdout/stderr binary mode.
    _setmode(_fileno(stdout), _O_BINARY);
    _setmode(_fileno(stderr), _O_BINARY);

    // Set theme engine.
    webkit_support::SetThemeEngine(&themeEngine);

    // Load Ahem font.
    // AHEM____.TTF is copied to the directory of DumpRenderTree.exe by WebKit.gyp.
    WCHAR path[_MAX_PATH];
    if (!::GetModuleFileName(0, path, _MAX_PATH)) {
        fprintf(stderr, "Can't get the module path.\n");
        exit(1);
    }
    ::PathRemoveFileSpec(path);
    wcscat_s(path, _MAX_PATH, L"/AHEM____.TTF");
    struct _stat ahemStat;
    if (_wstat(path, &ahemStat) == -1) {
        fprintf(stderr, "Can't access: '%S'\n", path);
        exit(1);
    }

    FILE* fp = _wfopen(path, L"rb");
    if (!fp) {
        _wperror(path);
        exit(1);
    }
    size_t size = ahemStat.st_size;
    char* fontBuffer = new char[size];
    if (fread(fontBuffer, 1, size, fp) != size) {
        fprintf(stderr, "Can't read the font: '%S'\n", path);
        fclose(fp);
        exit(1);
    }
    fclose(fp);
    DWORD numFonts = 1;
    HANDLE fontHandle = ::AddFontMemResourceEx(fontBuffer, size, 0, &numFonts);
    delete[] fontBuffer; // OS owns a copy of the buffer.
    if (!fontHandle) {
        fprintf(stderr, "Failed to register Ahem font: '%S'\n", path);
        exit(1);
    }
    // We don't need to release the font explicitly.
}
示例#4
0
ForceInline Void main2(Int argc, WChar **argv)
{
    FILE *fp;
    LPVoid lpBuffer, lpEndOfBuffer;
    UInt32 BufferSize, FileSize;

    ConvertScriptToUnicode(argc, argv);
    return;

    BufferSize = 0x1000;
    lpBuffer = malloc(BufferSize);
    _wsetlocale(LC_CTYPE, L"");
    for (Int32 i = 1; i != argc; ++i)
    {
        fp = _wfopen(*++argv, L"rb+");
        if (!fp)
        {
            _wperror(*argv);
            continue;
        }

        FileSize = fsize(fp);
        if (FileSize > BufferSize)
        {
            BufferSize = FileSize;
            lpBuffer = realloc(lpBuffer, BufferSize);
        }

        fread(lpBuffer, FileSize, 1, fp);
        fclose(fp);
        if (*(PUInt16)lpBuffer != 0xFEFF)
        {
            wprintf(L"%s\nsupport unicode only\n\n", *argv);
            fclose(fp);
            continue;
        }

        lpEndOfBuffer = (PByte)lpBuffer + FileSize;
        ProcessFile((PByte)lpBuffer + 2, lpEndOfBuffer, *argv);
    }

    free(lpBuffer);
}