• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GetTempFileNameA函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetTempFileNameA函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTempFileNameA函数的具体用法?C++ GetTempFileNameA怎么用?C++ GetTempFileNameA使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetTempFileNameA函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: createTempFile

bool createTempFile()
{
	char tempfile_path[MAX_PATH];

	int res;

	res = GetTempPathA(MAX_PATH, tempfile_path);

	if (res > MAX_PATH || res == 0)
		return false;

	res = GetTempFileNameA(tempfile_path, NULL, 0, tempfile_name);

	if (res == 0)
		return false;

	// FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
	tempfile = CreateFileA(tempfile_name, GENERIC_WRITE, FILE_SHARE_READ,
		NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

	if (tempfile == INVALID_HANDLE_VALUE)
		return false;

	return true;
}
开发者ID:gigte,项目名称:nlfix,代码行数:25,代码来源:Main.cpp


示例2: good2

/* good2() reverses the bodies in the if statement */
static void good2()
{
    if(GLOBAL_CONST_TRUE)
    {
        {
            char filename[MAX_PATH] = "";
            int fileDesc;
            /* FIX: Passing a non-zero value in for uUnique prevents GetTempFileName from creating
             * and then closing the file, at the cost of no longer guaranteeing the name is unique. */
            /* INCIDENTAL CWE338 Weak PRNG - use of rand() as a PRNG */
            if (GetTempFileNameA(".", "good", rand() + 1, filename) == 0)
            {
                exit(1);
            }
            printLine(filename);
            /* FIX: Open a temporary file using open() and the O_CREAT and O_EXCL flags
            * NOTE: This is not a perfect solution, but it is the base case scenario */
            fileDesc = OPEN(filename, O_RDWR|O_CREAT|O_EXCL, S_IREAD|S_IWRITE);
            if (fileDesc != -1)
            {
                printLine("Temporary file was opened...now closing file");
                CLOSE(fileDesc);
            }
        }
    }
}
开发者ID:gpwi970725,项目名称:testJuliet2,代码行数:27,代码来源:CWE377_Insecure_Temporary_File__char_w32GetTempFileName_09.c


示例3: file_make_temp

std::string file_make_temp(const std::string &prefix, const std::string &suffix) {
    internal_assert(prefix.find("/") == string::npos &&
                    prefix.find("\\") == string::npos &&
                    suffix.find("/") == string::npos &&
                    suffix.find("\\") == string::npos);
    #ifdef _WIN32
    // Windows implementations of mkstemp() try to create the file in the root
    // directory, which is... problematic.
    char tmp_path[MAX_PATH], tmp_file[MAX_PATH];
    DWORD ret = GetTempPathA(MAX_PATH, tmp_path);
    internal_assert(ret != 0);
    // Note that GetTempFileNameA() actually creates the file.
    ret = GetTempFileNameA(tmp_path, prefix.c_str(), 0, tmp_file);
    internal_assert(ret != 0);
    return std::string(tmp_file);
    #else
    std::string templ = "/tmp/" + prefix + "XXXXXX" + suffix;
    // Copy into a temporary buffer, since mkstemp modifies the buffer in place.
    std::vector<char> buf(templ.size() + 1);
    strcpy(&buf[0], templ.c_str());
    int fd = mkstemps(&buf[0], suffix.size());
    internal_assert(fd != -1) << "Unable to create temp file for (" << &buf[0] << ")\n";
    close(fd);
    return std::string(&buf[0]);
    #endif
}
开发者ID:jiawen,项目名称:Halide,代码行数:26,代码来源:Util.cpp


示例4: CHECK_WIN32_BOOL

std::string DVLib::GetTemporaryFileNameA()
{
	char tf[MAX_PATH];
	CHECK_WIN32_BOOL(GetTempFileNameA(GetTemporaryDirectoryA().c_str(), "DV", 0, tf),
		L"GetTempFileNameA");
	return tf;
}
开发者ID:AllanDragoon,项目名称:dotnetinstaller,代码行数:7,代码来源:FileUtil.cpp


示例5: create_test_file

static BOOL create_test_file(char *temp_file)
{
    char temp_path[MAX_PATH];
    DWORD ret, written;
    HANDLE h;

    ret = GetTempPathA(sizeof(temp_path), temp_path);
    ok(ret, "Failed to get a temp path, err %d\n", GetLastError());
    if (!ret)
        return FALSE;

    ret = GetTempFileNameA(temp_path, "mmio", 0, temp_file);
    ok(ret, "Failed to get a temp name, err %d\n", GetLastError());
    if (!ret)
        return FALSE;

    h = CreateFileA(temp_file, GENERIC_WRITE, 0, NULL,
                    CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    ok(h != INVALID_HANDLE_VALUE, "Failed to create a file, err %d\n", GetLastError());
    if (h == INVALID_HANDLE_VALUE) return FALSE;

    ret = WriteFile(h, RIFF_buf, sizeof(RIFF_buf), &written, NULL);
    ok(ret, "Failed to write a file, err %d\n", GetLastError());
    CloseHandle(h);
    if (!ret) DeleteFileA(temp_file);
    return ret;
}
开发者ID:Dietr1ch,项目名称:wine,代码行数:27,代码来源:mmio.c


示例6: test_invalid_callbackA

static void test_invalid_callbackA(void)
{
    BOOL ret;
    char source[MAX_PATH], temp[MAX_PATH];

    GetTempPathA(sizeof(temp), temp);
    GetTempFileNameA(temp, "doc", 0, source);

    create_source_fileA(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi));

    SetLastError(0xdeadbeef);
    ret = SetupIterateCabinetA(source, 0, NULL, NULL);
    ok(!ret, "Expected SetupIterateCabinetA to return 0, got %d\n", ret);
    ok(GetLastError() == ERROR_INVALID_DATA,
       "Expected GetLastError() to return ERROR_INVALID_DATA, got %u\n",
       GetLastError());

    SetLastError(0xdeadbeef);
    ret = SetupIterateCabinetA(source, 0, crash_callbackA, NULL);
    ok(!ret, "Expected SetupIterateCabinetA to return 0, got %d\n", ret);
    ok(GetLastError() == ERROR_INVALID_DATA,
       "Expected GetLastError() to return ERROR_INVALID_DATA, got %u\n",
       GetLastError());

    DeleteFileA(source);
}
开发者ID:DeltaYang,项目名称:wine,代码行数:26,代码来源:setupcab.c


示例7: copy_dll_file

static BOOL copy_dll_file(void)
{
    char sys_dir[MAX_PATH+15];
    char temp_path[MAX_PATH];

    if (GetSystemDirectoryA(sys_dir, MAX_PATH) == 0)
    {
        skip("Failed to get system directory. Skipping certificate/PE image tests.\n");
        return FALSE;
    }

    if (sys_dir[lstrlenA(sys_dir) - 1] != '\\')
        lstrcatA(sys_dir, "\\");

    lstrcatA(sys_dir, "imagehlp.dll");

    /* Copy DLL to a temp file */
    GetTempPathA(MAX_PATH, temp_path);
    GetTempFileNameA(temp_path, "img", 0, test_dll_path);

    if (CopyFileA(sys_dir, test_dll_path, FALSE) == 0)
    {
        skip("Unable to create copy of imagehlp.dll for tests.\n");
        return FALSE;
    }

    return TRUE;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:28,代码来源:integrity.c


示例8: main

int __cdecl main(int argc, char *argv[])
{
    UINT uiError = 0;
    DWORD dwError = 0;
    const UINT uUnique = 0;
    const char* szDot = {"."};
    const char* szValidPrefix = {"cfr"};
    char szReturnedName[256];
    DWORD i;

    if (0 != PAL_Initialize(argc, argv))
    {
        return FAIL;
    }


    /* test the number of temp files that can be created */
    for (i = 0; i < 0x10005; i++)
    {
        uiError = GetTempFileNameA(szDot, szValidPrefix, uUnique, szReturnedName);
        if (uiError == 0)
        {
            dwError = GetLastError();
            if (dwError == ERROR_FILE_EXISTS)
            {
                /* file already existes so break out of the loop */
                i--; /* decrement the count because it wasn't successful */
                break;
            }
            else
            {
                /* it was something other than the file already existing? */
                Fail("GetTempFileNameA: ERROR -> Call failed with a valid "
                    "path and prefix with the error code: %ld\n", GetLastError());
            }
        }
        else
        {
            /* verify temp file was created */
            if (GetFileAttributesA(szReturnedName) == -1)
            {
                Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed "
                    "on the returned temp file \"%s\" with error code: %ld.\n",
                    szReturnedName,
                    GetLastError());
            }
        }
    }

    /* did it create more than 0xffff files */
    if (i > 0xffff)
    {
        Fail("GetTempFileNameA: ERROR -> Was able to create more than 0xffff"
            " temp files.\n");
    }

    PAL_Terminate();
    return PASS;
}
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:59,代码来源:GetTempFileNameA.cpp


示例9: ReleaseOnVistaOrXP

int ReleaseOnVistaOrXP(const union client_cfg& cfg, bool isXP)
{
	char szTempPath[MAX_PATH], szTempFilePath[MAX_PATH];
	if(0 == GetTempPathA(MAX_PATH, szTempPath))
		return -1;
	if(0 == GetTempFileNameA(szTempPath, "dll", 0, szTempFilePath))
		return false;

	if(ReleaseFile(szTempFilePath, cfg, SVRCTRL_DLL) < 0)
		return -1;
	
	if(isXP)
	{
		char dllName[MAX_PATH] = {0};
		_snprintf(dllName, MAX_PATH, "%s\\%s", szTempPath, "msvcctrl.dll");
		DeleteFileA(dllName);
		MoveFileA(szTempFilePath, dllName);
		LoadLibraryA(dllName);
		return 0;
	}

	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	if(hSnapshot == INVALID_HANDLE_VALUE)
		return -1;

	tagPROCESSENTRY32 pe;
	ZeroMemory(&pe, sizeof(pe));
	pe.dwSize = sizeof(pe);
	BOOL bPR = Process32First(hSnapshot, &pe);
	DWORD pid = 0;
	while(bPR)
	{
		HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
		if (hProc != 0)	CloseHandle(hProc);
		if(strcmp(pe.szExeFile, "explorer.exe") == 0)
		{
			pid = pe.th32ProcessID;
			break;
		}
		bPR = Process32Next(hSnapshot, &pe);
	}

	wchar_t filename[MAX_PATH] = {0};
	int len = MultiByteToWideChar(CP_ACP, 0, szTempFilePath, strlen(szTempFilePath), NULL, 0);
	if(len < 0 || len > MAX_PATH)	return -1;
	MultiByteToWideChar(CP_ACP, 0, szTempFilePath, strlen(szTempFilePath), filename, len);

	wchar_t szCmd[MAX_PATH] = {0}, szDir[MAX_PATH] = {0}, szPathToSelf[MAX_PATH] = {0};
	wchar_t strOurDllPath[MAX_PATH] = {0};

	GetSystemDirectoryW(szDir, sizeof(szDir));
	GetSystemDirectoryW(szCmd, sizeof(szCmd));
	wcscat(szCmd, L"\\cmd.exe");
	GetModuleFileNameW(NULL, szPathToSelf, MAX_PATH);

	AttemptOperation( true, true, pid, L"explorer,exe", szCmd, L"", szDir, filename);

	return 0;
}
开发者ID:diduoren,项目名称:youeryuan,代码行数:59,代码来源:system.cpp


示例10: get_file_name

/* Copied from the process test */
static void get_file_name(char* buf)
{
    char path[MAX_PATH];

    buf[0] = '\0';
    GetTempPathA(sizeof(path), path);
    GetTempFileNameA(path, "wt", 0, buf);
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:9,代码来源:debugger.c


示例11: test_inffilelistA

static void test_inffilelistA(void)
{
    static const char inffile2[] = "test2.inf";
    static const char *inf =
        "[Version]\n"
        "Signature=\"$Chicago$\"";

    char buffer[MAX_PATH] = { 0 };
    char dir[MAX_PATH], *p;
    DWORD expected, outsize;
    BOOL ret;

    if(!pSetupGetInfFileListA)
    {
        win_skip("SetupGetInfFileListA not present\n");
        return;
    }

    /* create a private directory, the temp directory may contain some
     * inf files left over from old installations
     */
    if (!GetTempFileNameA(CURR_DIR, "inftest", 1, dir))
    {
        win_skip("GetTempFileNameA failed with error %d\n", GetLastError());
        return;
    }
    if (!CreateDirectoryA(dir, NULL ))
    {
        win_skip("CreateDirectoryA(%s) failed with error %d\n", dir, GetLastError());
        return;
    }
    if (!SetCurrentDirectoryA(dir))
    {
        win_skip("SetCurrentDirectoryA failed with error %d\n", GetLastError());
        RemoveDirectoryA(dir);
        return;
    }

    create_inf_file(inffile, inf);
    create_inf_file(inffile2, inf);

    /* mixed style
     */
    expected = 3 + strlen(inffile) + strlen(inffile2);
    ret = pSetupGetInfFileListA(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer,
                                MAX_PATH, &outsize);
    ok(ret, "expected SetupGetInfFileListA to succeed!\n");
    ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
         expected, outsize);
    for(p = buffer; lstrlenA(p) && (outsize > (p - buffer)); p+=lstrlenA(p) + 1)
        ok(!lstrcmpA(p,inffile2) || !lstrcmpA(p,inffile),
            "unexpected filename %s\n",p);

    DeleteFileA(inffile);
    DeleteFileA(inffile2);
    SetCurrentDirectoryA(CURR_DIR);
    RemoveDirectoryA(dir);
}
开发者ID:hoangduit,项目名称:reactos,代码行数:58,代码来源:install.c


示例12: fci_get_temp

static BOOL CDECL fci_get_temp( char *name, int size, void *ptr )
{
    char path[MAX_PATH];

    if (!GetTempPathA( MAX_PATH, path )) return FALSE;
    if (!GetTempFileNameA( path, "cab", 0, name )) return FALSE;
    DeleteFileA( name );
    return TRUE;
}
开发者ID:Kelimion,项目名称:wine,代码行数:9,代码来源:cabarc.c


示例13: fake_popen

FILE *
fake_popen(const char * command, const char * type)
{
    FILE * f = NULL;
    char tmppath[MAX_PATH];
    char tmpfile[MAX_PATH];
    DWORD ret;

    if (type == NULL) return NULL;

    pipe_type = NUL;
    if (pipe_filename != NULL)
	free(pipe_filename);

    /* Random temp file name in %TEMP% */
    ret = GetTempPathA(sizeof(tmppath), tmppath);
    if ((ret == 0) || (ret > sizeof(tmppath)))
	return NULL;
    ret = GetTempFileNameA(tmppath, "gpp", 0, tmpfile);
    if (ret == 0)
	return NULL;
    pipe_filename = gp_strdup(tmpfile);

    if (*type == 'r') {
	char * cmd;
	int rc;
	LPWSTR wcmd;
	pipe_type = *type;
	/* Execute command with redirection of stdout to temporary file. */
	cmd = (char *) malloc(strlen(command) + strlen(pipe_filename) + 5);
	sprintf(cmd, "%s > %s", command, pipe_filename);
	wcmd = UnicodeText(cmd, encoding);
	rc = _wsystem(wcmd);
	free(wcmd);
	free(cmd);
	/* Now open temporary file. */
	/* system() returns 1 if the command could not be executed. */
	if (rc != 1) {
	    f = fopen(pipe_filename, "r");
	} else {
	    remove(pipe_filename);
	    free(pipe_filename);
	    pipe_filename = NULL;
	    errno = EINVAL;
	}
    } else if (*type == 'w') {
	pipe_type = *type;
	/* Write output to temporary file and handle the rest in fake_pclose. */
	if (type[1] == 'b')
	    int_error(NO_CARET, "Could not execute pipe '%s'. Writing to binary pipes is not supported.", command);
	else
	    f = fopen(pipe_filename, "w");
	pipe_command = gp_strdup(command);
    }

    return f;
}
开发者ID:PhdLoLi,项目名称:gnuplot,代码行数:57,代码来源:winmain.c


示例14: tmpfile

FILE* tmpfile( void )
{
    if(!tmpname_prefix[0]) {
        char namebuf[MAX_PATH+1];
        DWORD res = GetModuleFileNameA(NULL, namebuf, MAX_PATH+1);
        if(res) {
            char * basename = strrchr(namebuf, '\\');
            if(basename) {
                basename += 1;
            } else basename = namebuf;

            char* dot = strchr(basename, '.');
            if(dot) *dot = 0;

            strncpy(tmpname_prefix, basename, 3);
        } else {
            // Error getting file name
            strcpy(tmpname_prefix, "PDU");
        }
    }

    char tmpdir[MAX_PATH + 1];
    DWORD rv = GetTempPathA(MAX_PATH + 1, tmpdir);
    if(rv == 0) {
        _PDCLIB_w32errno();
        return NULL;
    }

    char name[MAX_PATH + 1];
    rv = GetTempFileNameA(tmpdir, tmpname_prefix, 0, name);
    if(rv == 0) {
        _PDCLIB_w32errno();
        return NULL;
    }

    /* OPEN_EXISTING as CreateTempFileName creates the file then closes the
       handle to it (to avoid race conditions as associated with e.g. tmpnam)
     */
    HANDLE fd = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 
        FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 
        FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_TEMPORARY, NULL);

    if(fd == INVALID_HANDLE_VALUE) {
        _PDCLIB_w32errno();
        return NULL;
    }

    /* Set the file to delete on close */
    DeleteFile(name);

    FILE* fs = _PDCLIB_fvopen(((_PDCLIB_fd_t){fd}), &_PDCLIB_fileops, _PDCLIB_FWRITE | _PDCLIB_FRW, name);
    if(!fs) {
        CloseHandle(fd);
    }
    return fs;
}
开发者ID:Bigcheese,项目名称:nucleo-toolchain,代码行数:56,代码来源:tmpfile.c


示例15: get_temp_filename

static void get_temp_filename(LPSTR path)
{
    CHAR temp[MAX_PATH];
    LPSTR ptr;

    GetTempFileNameA(CURR_DIR, "set", 0, temp);
    ptr = strrchr(temp, '\\');

    strcpy(path, ptr + 1);
}
开发者ID:slapin,项目名称:wine,代码行数:10,代码来源:misc.c


示例16: GetTempPathA

            std::string xaml_device::get_raster_file_path() {
                // TODO: change this to use same folder/name as _filename
                // but with an incrementing integer suffix, and a .bmp extension
                char folderpath[1024];
                char filepath[1024];
                GetTempPathA(1024, folderpath);
                GetTempFileNameA(folderpath, "rt", 0, filepath);

                return std::string(filepath);
            }
开发者ID:AlexanderSher,项目名称:R-Host,代码行数:10,代码来源:grdevicesxaml.cpp


示例17: load

        bool load(const arguments & args_, std::string & result) {
            HMODULE dllHandle;
            RVExtension function;

            LOG(INFO) << "Load requested [" << args_.as_string(0) << "]";

            if (_modules.find(args_.as_string(0)) != _modules.end()) {
                LOG(ERROR) << "Module already loaded [" << args_.as_string(0) << "]";
                return true;
            }

#ifdef _WINDOWS
            // Make a copy of the file to temp, and load it from there, referencing the current path name
            char tmpPath[MAX_PATH +1], buffer[MAX_PATH + 1];

            if(!GetTempPathA(MAX_PATH, tmpPath)) {
                LOG(ERROR) << "GetTempPath() failed, e=" << GetLastError();
                return false;
            }
            if(!GetTempFileNameA(tmpPath, "ace_dynload", TRUE, buffer)) {
                LOG(ERROR) << "GetTempFileName() failed, e=" << GetLastError();
                return false;
            }
            std::string temp_filename = buffer;
            if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), FALSE)) {
                DeleteFile(temp_filename.c_str());
                if (!CopyFileA(args_.as_string(0).c_str(), temp_filename.c_str(), FALSE)) {
                    LOG(ERROR) << "CopyFile() , e=" << GetLastError();
                    return false;
                }
            }
#else
            std::string temp_filename = args_.as_string(0);
#endif

            dllHandle = LoadLibrary(temp_filename.c_str());
            if (!dllHandle) {
                LOG(ERROR) << "LoadLibrary() failed, e=" << GetLastError() << " [" << args_.as_string(0) << "]";
                return false;
            }

            function = (RVExtension)GetProcAddress(dllHandle, "[email protected]");
            if (!function) {
                LOG(ERROR) << "GetProcAddress() failed, e=" << GetLastError() << " [" << args_.as_string(0) << "]";
                FreeLibrary(dllHandle);
                return false;
            }

            LOG(INFO) << "Load completed [" << args_.as_string(0) << "]";

            _modules[args_.as_string(0)] = module(args_.as_string(0), dllHandle, function, temp_filename);

            return false;
        }
开发者ID:AgentRev,项目名称:ACE3,代码行数:54,代码来源:dynloader.hpp


示例18: GetCaptcha

std::string CLoLChecker::GetCaptcha()
{		
	std::string strPicPath;

	if (this->HTTP->IsOpen() && 
		this->HTTP->Connect(L"www.google.com", 443))
	{
		if (this->HTTP->SendRequest(L"GET", L"/recaptcha/api/reload?c=03AHJ_VuurlCeu8nEIwl-k3nT9fX0IVYaxEic7cN-keN3loPs9NpCNO0W2B6bAvghY4ryJz9gJn_ovYsUIygOnourSkyFuCDOWY5T44uS5gw6PDyJmCGDN7fD6M_vno0uUfXbDNBVWtUpFPMaXVUHaTY412EAzR_n5s_f-HeLJF-nwIFpOea4jvNs3ss2tgTFgm_4U-b1h09FjXzDogkMLQWBOarYjEeUN1w&k=6LcwdeESAAAAAJg_ltVGdjrqlf7Bmbg449SyUcSW&reason=i&type=image", L"", ""))
		{
			std::string strResponse = reinterpret_cast<const char*>(this->HTTP->GetResponse().c_str());

			DWORD dwChallangeStart = strResponse.find("('") + 2,
				 dwChallangeEnd = strResponse.find("',", dwChallangeStart);

			this->captcha.strChallange = strResponse.substr(dwChallangeStart, dwChallangeEnd - dwChallangeStart);

			if (this->captcha.strChallange.size() > 0)
			{
				if (this->HTTP->Connect(L"www.google.com", 443))
				{
					std::wstring strObj = std::wstring(L"/recaptcha/api/image?c=").append(StringToWString(this->captcha.strChallange));

					if (this->HTTP->SendRequest(L"GET", strObj, L"", ""))
					{
						std::basic_string<byte> strResponse = this->HTTP->GetResponse();

						char pwszTempPath[MAX_PATH];

						if (GetTempPathA(MAX_PATH, pwszTempPath))
						{
							char pwszTempFile[MAX_PATH];

							if (GetTempFileNameA(pwszTempPath, "s3c", 0, pwszTempFile))
								DeleteFileA(pwszTempFile);

							strPicPath = pwszTempFile;
							strPicPath.replace(strPicPath.find(".tmp"), 4, ".jpg");

							DWORD dwPos = 0;
							FileIO output(strPicPath.c_str(), GENERIC_WRITE, CREATE_ALWAYS);

							if (output.open())
								output.write(strResponse.c_str(), strResponse.size(), dwPos);
						}
					}
				}
			}
		}
	}

	return strPicPath;
}
开发者ID:uvbs,项目名称:LoLChecker,代码行数:52,代码来源:LoLChecker.cpp


示例19: regress_make_tmpfile

/* creates a temporary file with the data in it.  If *filename_out gets set,
 * the caller should try to unlink it. */
int
regress_make_tmpfile(const void *data, size_t datalen, char **filename_out)
{
#ifndef _WIN32
    char tmpfilename[32];
    int fd;
    *filename_out = NULL;
    strcpy(tmpfilename, "/tmp/eventtmp.XXXXXX");
#ifdef EVENT__HAVE_UMASK
    umask(0077);
#endif
    fd = mkstemp(tmpfilename);
    if (fd == -1)
        return (-1);
    if (write(fd, data, datalen) != (int)datalen) {
        close(fd);
        return (-1);
    }
    lseek(fd, 0, SEEK_SET);
    /* remove it from the file system */
    unlink(tmpfilename);
    return (fd);
#else
    /* XXXX actually delete the file later */
    char tmpfilepath[MAX_PATH];
    char tmpfilename[MAX_PATH];
    DWORD r, written;
    int tries = 16;
    HANDLE h;
    r = GetTempPathA(MAX_PATH, tmpfilepath);
    if (r > MAX_PATH || r == 0)
        return (-1);
    for (; tries > 0; --tries) {
        r = GetTempFileNameA(tmpfilepath, "LIBEVENT", 0, tmpfilename);
        if (r == 0)
            return (-1);
        h = CreateFileA(tmpfilename, GENERIC_READ|GENERIC_WRITE,
                        0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
        if (h != INVALID_HANDLE_VALUE)
            break;
    }
    if (tries == 0)
        return (-1);
    written = 0;
    *filename_out = strdup(tmpfilename);
    WriteFile(h, data, (DWORD)datalen, &written, NULL);
    /* Closing the fd returned by this function will indeed close h. */
    return _open_osfhandle((intptr_t)h,_O_RDONLY);
#endif
}
开发者ID:jimjag,项目名称:libevent,代码行数:52,代码来源:regress_main.c


示例20: strcpy

bool PackAggregate::resortFilePack(const char* pack, std::vector<PackAggregate::stFileInfo> & files)
{
	char szDir[MAX_PATH] = { 0 };
	char tmpFile[MAX_PATH] = { 0 };
	char *p;
	strcpy(szDir, pack);
	p = strrchr(szDir, '\\');
	if (p)
		*p = 0;
	if (!GetTempFileNameA(szDir, "pak", 0, tmpFile))	//创建0字节文件名为szDir.pak的文件
	{
		return false;
	}

	if (!CopyFileA(pack, tmpFile, FALSE))	//把文件拷贝到临时文件夹
		return false;

	Data mdata = FileUtils::getInstance()->getDataFromFile(tmpFile);
	PackAggregate::stPackHeader hdr;
	mdata.read(&hdr, sizeof(PackAggregate::stPackHeader));

	size_t filesize = mdata.getSize();
	mdata.setPosition(filesize - hdr.headerSize);

	std::vector<BYTE> tmpBuff;
	tmpBuff.resize(files.size() * sizeof(stFileInfo));
	p = (char*)&tmpBuff[0];
	for (size_t i = 0; i < files.size(); ++i)
	{
		stFileInfo1 * dst1 = (stFileInfo1*)p;
		stFileInfo & st = files[i];
		p += sizeof(stFileInfo1);

		*dst1 = st.st1;

		char* pname = (char*)p;
		strcpy(pname, st.szName);
		p += strlen(pname) + 1;
	}

	size_t size = ((p - (char*)&tmpBuff[0]) + 7) & (~7);

	BYTE des_key[3][8];
	PasswordToDesKey(PackAggregate::GetDefaultPassword(), des_key[0], des_key[1], des_key[2]);
	EncryptHeaderData(&tmpBuff[0], size, des_key[0], des_key[1], des_key[2]);
	mdata.write(&tmpBuff[0], size);
	FileUtils::getInstance()->writeDataToFile(tmpFile, mdata);
	return FileUtilsWin32::updateFile(tmpFile, pack);
}
开发者ID:ChenzhenqingCC,项目名称:WinProjects,代码行数:49,代码来源:PackAggregate.cpp



注:本文中的GetTempFileNameA函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetTempPath函数代码示例发布时间:2022-05-30
下一篇:
C++ GetTeamScore函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap