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

C++ LastError函数代码示例

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

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



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

示例1: EmbedSend

/* The send embedded callback
 *  return : nb bytes sended
 *           -1 : other errors (unexpected)
 *           -2 : want write
 *           -3 : connexion reset
 *           -4 : interrupt
 *           -5 : pipe error / connection closed
 */
int EmbedSend(char *buf, int sz, void *ctx)
{
    int socket = *(int*)ctx;
    int sent;
    int len = sz;

    sent = SEND_FUNCTION(socket, &buf[sz - len], len, 0);

    if (sent == -1) {
        if (LastError() == SOCKET_EWOULDBLOCK || 
            LastError() == SOCKET_EAGAIN)
            return -2;

        else if (LastError() == SOCKET_ECONNRESET)
            return -3;

        else if (LastError() == SOCKET_EINTR)
            return -4;

        else if (LastError() == SOCKET_EPIPE)
            return -5;

        else
            return -1;
    }
 
    return sent;
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:36,代码来源:cyassl_io.c


示例2: GetStdHandle

result_t console_base::clear()
{
    HANDLE hd = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = { 0, 0 };
    DWORD cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    DWORD dwConSize;

    if (!GetConsoleScreenBufferInfo(hd, &csbi))
        return CHECK_ERROR(LastError());

    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

    FillConsoleOutputCharacter(hd, ' ', dwConSize,
                               coordScreen, &cCharsWritten);

    if (!GetConsoleScreenBufferInfo(hd, &csbi))
        return CHECK_ERROR(LastError());

    FillConsoleOutputAttribute(hd, csbi.wAttributes, dwConSize,
                               coordScreen, &cCharsWritten);

    SetConsoleCursorPosition(hd, coordScreen);
    return 0;
}
开发者ID:ngot,项目名称:fibjs,代码行数:25,代码来源:console.cpp


示例3: CHECK_ERROR

result_t os_base::networkInfo(v8::Local<v8::Object> &retVal)
{
    unsigned long size = 0;
    IP_ADAPTER_ADDRESSES *adapter_addresses;
    IP_ADAPTER_ADDRESSES *adapter_address;
    IP_ADAPTER_UNICAST_ADDRESS_XP *unicast_address;

    if (GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size)
            != ERROR_BUFFER_OVERFLOW)
        return CHECK_ERROR(LastError());

    adapter_addresses = (IP_ADAPTER_ADDRESSES *) malloc(size);
    if (!adapter_addresses)
        return CHECK_ERROR(LastError());

    if (GetAdaptersAddresses(AF_UNSPEC, 0, NULL, adapter_addresses, &size)
            != ERROR_SUCCESS)
        return CHECK_ERROR(LastError());

    retVal = v8::Object::New(isolate);

    for (adapter_address = adapter_addresses; adapter_address != NULL;
            adapter_address = adapter_address->Next)
    {
        v8::Local<v8::Array> ret;
        v8::Local<v8::Object> o;
        v8::Local<v8::String> name, ipaddr, family;

        if (adapter_address->OperStatus != IfOperStatusUp)
            continue;

        name = v8::String::NewFromUtf8(isolate, UTF8_A(adapter_address->FriendlyName));

        ret = v8::Array::New(isolate);
        retVal->Set(name, ret);

        unicast_address =
            (IP_ADAPTER_UNICAST_ADDRESS_XP *) adapter_address->FirstUnicastAddress;
        while (unicast_address)
        {
            inetAddr *sock_addr = (inetAddr *) unicast_address->Address.lpSockaddr;

            o = v8::Object::New(isolate);
            o->Set(v8::String::NewFromUtf8(isolate, "address"), v8::String::NewFromUtf8(isolate, sock_addr->str().c_str()));
            o->Set(v8::String::NewFromUtf8(isolate, "family"), sock_addr->family() == net_base::_AF_INET6 ?
                   v8::String::NewFromUtf8(isolate, "IPv6") : v8::String::NewFromUtf8(isolate, "IPv4"));
            o->Set(v8::String::NewFromUtf8(isolate, "internal"),
                   adapter_address->IfType == IF_TYPE_SOFTWARE_LOOPBACK ?
                   v8::True(isolate) : v8::False(isolate));

            ret->Set(ret->Length(), o);

            unicast_address = unicast_address->Next;
        }
    }

    free(adapter_addresses);

    return 0;
}
开发者ID:CYCOK,项目名称:fibjs,代码行数:60,代码来源:os_win.cpp


示例4: create_name_pipe

result_t create_name_pipe(HANDLE* hd1, HANDLE* hd2, bool in)
{
	HANDLE hMine, hChild;
	char fname[128];

	do
	{
		sprintf(fname, "\\\\.\\pipe\\fibs.namedpipe.%d", rand());
		hMine = CreateNamedPipe(fname, (in ? PIPE_ACCESS_OUTBOUND : PIPE_ACCESS_INBOUND) | FILE_FLAG_OVERLAPPED,
		                        PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
		                        1, 4096, 4096, 0, NULL);
	} while ((hMine == INVALID_HANDLE_VALUE) && (GetLastError() == ERROR_PIPE_BUSY));
	if (hMine == INVALID_HANDLE_VALUE)
		return CHECK_ERROR(LastError());

	SECURITY_ATTRIBUTES sa;
	sa.nLength = sizeof(SECURITY_ATTRIBUTES);
	sa.bInheritHandle = TRUE;
	sa.lpSecurityDescriptor = NULL;

	hChild = CreateFile( fname, in ? GENERIC_READ : GENERIC_WRITE, 0, &sa, OPEN_EXISTING,
	                     FILE_ATTRIBUTE_NORMAL, 0);
	if (hChild == INVALID_HANDLE_VALUE)
	{
		CloseHandle(hMine);
		return CHECK_ERROR(LastError());
	}

	*hd1 = hMine;
	*hd2 = hChild;

	return 0;
}
开发者ID:yeyuguo,项目名称:fibjs,代码行数:33,代码来源:SubProcess_win.cpp


示例5: sysconf

result_t os_base::CPUInfo(v8::Local<v8::Array> &retVal)
{
    retVal = v8::Array::New(isolate);

    v8::Local<v8::Object> cpuinfo;
    v8::Local<v8::Object> cputimes;
    unsigned int ticks = (unsigned int) sysconf(_SC_CLK_TCK), multiplier =
                             ((uint64_t) 1000L / ticks);
    char model[512];
    uint64_t cpuspeed;
    size_t size;

    size = sizeof(model);
    if (sysctlbyname("hw.model", &model, &size, NULL, 0) < 0)
        return CHECK_ERROR(LastError());

    size = sizeof(cpuspeed);
    if (sysctlbyname("hw.cpufrequency", &cpuspeed, &size, NULL, 0) < 0)
        return CHECK_ERROR(LastError());

    natural_t numcpus;
    mach_msg_type_number_t count;
    processor_cpu_load_info_data_t *info;
    if (host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numcpus,
                            reinterpret_cast<processor_info_array_t *>(&info),
                            &count) != KERN_SUCCESS)
        return CHECK_ERROR(LastError());

    retVal = v8::Array::New(isolate, numcpus);
    for (unsigned int i = 0; i < numcpus; i++)
    {
        cpuinfo = v8::Object::New(isolate);
        cputimes = v8::Object::New(isolate);
        cputimes->Set(v8::String::NewFromUtf8(isolate, "user"),
                      v8::Number::New(isolate, (uint64_t)(info[i].cpu_ticks[0]) * multiplier));
        cputimes->Set(v8::String::NewFromUtf8(isolate, "nice"),
                      v8::Number::New(isolate, (uint64_t)(info[i].cpu_ticks[3]) * multiplier));
        cputimes->Set(v8::String::NewFromUtf8(isolate, "sys"),
                      v8::Number::New(isolate, (uint64_t)(info[i].cpu_ticks[1]) * multiplier));
        cputimes->Set(v8::String::NewFromUtf8(isolate, "idle"),
                      v8::Number::New(isolate, (uint64_t)(info[i].cpu_ticks[2]) * multiplier));
        cputimes->Set(v8::String::NewFromUtf8(isolate, "irq"), v8::Number::New(isolate, 0));

        cpuinfo->Set(v8::String::NewFromUtf8(isolate, "model"), v8::String::NewFromUtf8(isolate, model));
        cpuinfo->Set(v8::String::NewFromUtf8(isolate, "speed"),
                     v8::Number::New(isolate, cpuspeed / 1000000));

        cpuinfo->Set(v8::String::NewFromUtf8(isolate, "times"), cputimes);
        retVal->Set(i, cpuinfo);
    }
    vm_deallocate(mach_task_self(), (vm_address_t) info, count);

    return 0;
}
开发者ID:CYCOK,项目名称:fibjs,代码行数:54,代码来源:os_osx.cpp


示例6: CHECK_ERROR

result_t File::readAll(obj_ptr<Buffer_base> &retVal, AsyncEvent *ac)
{
    if (m_fd == -1)
        return CHECK_ERROR(CALL_E_INVALID_CALL);

    if (!ac)
        return CHECK_ERROR(CALL_E_NOSYNC);

    qstring strBuf;

    int32_t bytes;
    int64_t p = _lseeki64(m_fd, 0, SEEK_CUR);
    if (p < 0)
        return CHECK_ERROR(LastError());

    int64_t sz = _lseeki64(m_fd, 0, SEEK_END);
    if (sz < 0)
        return CHECK_ERROR(LastError());

    if (_lseeki64(m_fd, p, SEEK_SET) < 0)
        return CHECK_ERROR(LastError());

    sz -= p;

    bytes = (int32_t) sz;

    if (bytes > 0)
    {
        strBuf.resize(bytes);
        int32_t sz = bytes;
        char *p = &strBuf[0];

        while (sz)
        {
            int32_t n = (int32_t) ::_read(m_fd, p, sz > STREAM_BUFF_SIZE ? STREAM_BUFF_SIZE : sz);
            if (n < 0)
                return CHECK_ERROR(LastError());
            if (n == 0)
                break;

            sz -= n;
            p += n;
        }

        strBuf.resize(bytes - sz);
    }

    if (strBuf.length() == 0)
        return CALL_RETURN_NULL;

    retVal = new Buffer(strBuf);

    return 0;
}
开发者ID:zhangyinglong,项目名称:fibjs,代码行数:54,代码来源:File.cpp


示例7: CHECK_ERROR

result_t fs_base::read(int32_t fd, Buffer_base* buffer, int32_t offset, int32_t length,
    int32_t position, int32_t& retVal, AsyncEvent* ac)
{
    if (fd < 0)
        return CHECK_ERROR(CALL_E_INVALID_CALL);

    if (ac->isSync())
        return CHECK_ERROR(CALL_E_NOSYNC);

    int32_t bufLength;
    buffer->get_length(bufLength);

    if (offset < 0 || offset >= bufLength)
        return Runtime::setError("Offset is out of bounds");

    exlib::string strBuf;

    if (length < 0 || (offset + length > bufLength)) {
        return Runtime::setError("Length extends beyond buffer");
    }

    if (position > -1) {
        if (_lseeki64(fd, position, SEEK_SET) < 0)
            return CHECK_ERROR(LastError());
    }

    if (length > 0) {
        strBuf.resize(length);
        int32_t sz = length;
        char* p = &strBuf[0];

        while (sz) {
            int32_t n = (int32_t)::_read(fd, p, sz > STREAM_BUFF_SIZE ? STREAM_BUFF_SIZE : sz);
            if (n < 0)
                return CHECK_ERROR(LastError());
            if (n == 0)
                break;

            sz -= n;
            p += n;
        }

        strBuf.resize(length - sz);
    }

    if (strBuf.length() == 0) {
        retVal = 0;
        return 0;
    }

    return buffer->write(strBuf, offset, (int32_t)strBuf.length(), "utf8", retVal);
}
开发者ID:asionius,项目名称:fibjs,代码行数:52,代码来源:fs.cpp


示例8: CopyOut

exp bool CopyOut(const char* source, const char* dest) {
    // Convert the filename into DOS8.3 format
    char* dosName = new char[12];
    ToDos83Name(source, dosName);

    // Find the file on the disk
    DirectoryEntry* entry = FindEntry(dosName, &directory);
    if (!entry) {
        LastError("CopyOut", "File doesn't exist");
        return false;
    }

    if (!(entry->attrib & ATTRIB_ARCHIVE)) {
        LastError("CopyOut", "This is not a file");
        return false;
    }

    // Update the entry
    UpdateEntry(entry, 0, 0);

    std::ofstream outHandle(dest, std::ios::out | std::ios::binary);
    if (!outHandle.is_open())
        return false;

    // Set up a FatEntry
    FatEntry fatEntry;
    fatEntry.cluster = GetClusterFromEntry(entry);
    fatEntry.sector = GetFATSector(fatEntry.cluster);
    fatEntry.buffer = new char[bpb->bytesPerSector];
    ReadSector(fatEntry.buffer, fatEntry.sector);

    char* sectorData = new char[bpb->bytesPerSector];

    // Read Data
    while (ReadCluster(&fatEntry, sectorData))
        outHandle.write(sectorData, 512);

    if (!(entry->size % bpb->bytesPerSector))
        outHandle.write(sectorData, 512);
    else
        outHandle.write(sectorData, entry->size % bpb->bytesPerSector);

    delete[] fatEntry.buffer;
    delete[] sectorData;
    delete[] dosName;

    outHandle.close();

    return true;
}
开发者ID:Rohansi,项目名称:LoonyOS,代码行数:50,代码来源:main.cpp


示例9: LogMessage

int CRealControlSocket::ContinueConnect(const wxIPV4address *address)
{
	LogMessage(__TFILE__, __LINE__, this, Debug_Verbose, _T("CRealControlSocket::ContinueConnect(%p) m_pEngine=%p"), address, m_pEngine);
	if (GetCurrentCommandId() != cmd_connect ||
		!m_pCurrentServer)
	{
		LogMessage(Debug_Warning, _T("Invalid context for call to ContinueConnect(), cmd=%d, m_pCurrentServer=%p"), GetCurrentCommandId(), m_pCurrentServer);
		return DoClose(FZ_REPLY_INTERNALERROR);
	}
	
	if (!address)
	{
		LogMessage(::Error, _("Invalid hostname or host not found"));
		return DoClose(FZ_REPLY_ERROR | FZ_REPLY_CRITICALERROR);
	}

	CConnectOpData* pData;
	if (!m_pCurOpData || m_pCurOpData->opId != cmd_connect)
		pData = 0;
	else
		pData = static_cast<CConnectOpData *>(m_pCurOpData);

	const unsigned int port = pData ? pData->port : m_pCurrentServer->GetPort();
	LogMessage(Status, _("Connecting to %s:%d..."), address->IPAddress().c_str(), port);

	wxIPV4address addr = *address;
	addr.Service(port);

	bool res = wxSocketClient::Connect(addr, false);

	if (!res && LastError() != wxSOCKET_WOULDBLOCK)
		return DoClose();

	return FZ_REPLY_WOULDBLOCK;
}
开发者ID:idgaf,项目名称:FileZilla3,代码行数:35,代码来源:ControlSocket.cpp


示例10: utf8to16String

result_t path_base::fullpath(exlib::string path, exlib::string &retVal)
{
#ifdef _WIN32
    exlib::wstring str = utf8to16String(path);
    exlib::wchar utf16_buffer[MAX_PATH];

    DWORD utf16_len = GetFullPathNameW(str.c_str(), MAX_PATH, utf16_buffer, NULL);
    if (!utf16_len)
        return CHECK_ERROR(LastError());

    retVal = utf16to8String(utf16_buffer, (int32_t)utf16_len);
    return 0;
#else
    if (isPathSlash(path.c_str()[0]))
        return normalize(path, retVal);

    exlib::string str;

    process_base::cwd(str);
    str.append(1, PATH_SLASH);
    str.append(path);

    return normalize(str, retVal);
#endif
}
开发者ID:anlebcoder,项目名称:fibjs,代码行数:25,代码来源:path.cpp


示例11: CHECK_ERROR

result_t os_base::memoryUsage(v8::Local<v8::Object> &retVal)
{
    size_t rss = 0;

    struct task_basic_info t_info;
    mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;

    if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t) &t_info,
                  &t_info_count) != KERN_SUCCESS)
        return CHECK_ERROR(LastError());

    rss = t_info.resident_size;

    v8::Local<v8::Object> info = v8::Object::New(isolate);

    v8::HeapStatistics v8_heap_stats;
    isolate->GetHeapStatistics(&v8_heap_stats);
    info->Set(v8::String::NewFromUtf8(isolate, "rss"), v8::Integer::New(isolate, (int32_t)rss));
    info->Set(v8::String::NewFromUtf8(isolate, "heapTotal"),
              v8::Integer::New(isolate, (int32_t)v8_heap_stats.total_heap_size()));
    info->Set(v8::String::NewFromUtf8(isolate, "heapUsed"),
              v8::Integer::New(isolate, (int32_t)v8_heap_stats.used_heap_size()));
    info->Set(v8::String::NewFromUtf8(isolate, "nativeObjects"),
              v8::Integer::New(isolate, (int32_t)g_obj_refs));

    retVal = info;

    return 0;
}
开发者ID:CYCOK,项目名称:fibjs,代码行数:29,代码来源:os_osx.cpp


示例12: Exception

void PEFile::Dump(LPCTSTR filename)
{
    FileMapping mapping;
    if (!mapping.Create(filename, GENERIC_READ, FILE_SHARE_READ,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, PAGE_READONLY)) {
        throw Exception(LastError());
    }

    LPVOID pBase;
    if ((pBase = mapping.MapView(FILE_MAP_READ, 0, 0)) == NULL) {
        throw Exception(_T("Unable to map view of file."));
    }

    PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)pBase;
    PIMAGE_FILE_HEADER pImgFileHdr = (PIMAGE_FILE_HEADER)pBase;

    if (pDosHeader->e_magic == IMAGE_DOS_SIGNATURE) {
        throw Exception(_T(".EXE format not supported."));
    } else if (PECommon::IsValidMachineType(pImgFileHdr->Machine)) {
        if (pImgFileHdr->SizeOfOptionalHeader == 0)	{	// 0 optional header
            ObjectFile::Dump(pImgFileHdr);				// means it's an OBJ
        } else {
            throw Exception(_T("Unrecognized file format."));
        }
    } else if (memcmp(pBase, IMAGE_ARCHIVE_START,
                      IMAGE_ARCHIVE_START_SIZE) == 0) {
        LibraryFile archive;
        archive.Dump(pBase);
    } else {
        throw Exception(_T("Unrecognized file format."));
    }
}
开发者ID:trieck,项目名称:source,代码行数:32,代码来源:pefile.cpp


示例13: DirCreate

exp bool DirCreate(const char* dirName) {
    // Convert the filename into DOS8.3 format
    char* dosName = new char[12];
    ToDos83Name(dirName, dosName);

    DirectoryEntry* entry = MakeEntry(dosName, ATTRIB_DIRECTORY, 0, &directory);
    if (!entry) {
        LastError("DirCreate", "Failed to create a directory");
        delete[] dosName;
        return false;
    }

    // Write FAT entry
    FatEntry fatEntry;
    fatEntry.buffer = new char[bpb->bytesPerSector];
    fatEntry.cluster = GetClusterFromEntry(entry);
    fatEntry.sector = GetFATSector(fatEntry.cluster);

    UpdateFAT(&fatEntry, GetClusterFromEntry(entry));

    // Write entry to disk
    DirectoryWrite(&directory);
    //WriteSector(directoryBuffer + ((((char*)entry - directoryBuffer) / 512) * 512),directorySector + (((char*)entry - directoryBuffer) / 512));

    delete[] dosName;
    delete[] fatEntry.buffer;

    return true;
}
开发者ID:Rohansi,项目名称:LoonyOS,代码行数:29,代码来源:main.cpp


示例14: sizeof

result_t os_base::get_execPath(std::string &retVal)
{
    char exeName[1024] = "";
    size_t size = sizeof(exeName);

    int32_t mib[4];

#ifdef __DragonFly__
    mib[0] = CTL_KERN;
    mib[1] = KERN_PROC;
    mib[2] = KERN_PROC_ARGS;
    mib[3] = getpid();
#else
    mib[0] = CTL_KERN;
    mib[1] = KERN_PROC;
    mib[2] = KERN_PROC_PATHNAME;
    mib[3] = -1;
#endif

    if (sysctl(mib, 4, exeName, &size, NULL, 0) < 0)
        return CHECK_ERROR(LastError());

    retVal = exeName;
    return 0;
}
开发者ID:540513310,项目名称:fibjs,代码行数:25,代码来源:os_freebsd.cpp


示例15: fopen

result_t os_base::CPUs(int32_t &retVal)
{
    static int cpus = 0;

    if (cpus > 0)
    {
        retVal = cpus;
        return 0;
    }

    int numcpus = 0;
    char line[512];
    FILE *fpModel = fopen("/proc/cpuinfo", "r");

    if (fpModel)
    {
        while (fgets(line, 511, fpModel) != NULL)
            if (strncmp(line, "processor", 9) == 0)
                numcpus++;
        fclose(fpModel);

        retVal = cpus = numcpus;
    }
    else
        return CHECK_ERROR(LastError());

    return 0;
}
开发者ID:Andrew-Zhang,项目名称:fibjs,代码行数:28,代码来源:os_linux.cpp


示例16: EmbedReceive

/* The receive embedded callback
 *  return : nb bytes read
 *           -1 : other errors (unexpected)
 *           -2 : WANT_READ
 *           -3 : Connexion reset
 *           -4 : interrupt
 *           -5 : connexion close
 */
int EmbedReceive(char *buf, int sz, void *ctx)
{
    int recvd;
    int err;
    int socket = *(int*)ctx;

    recvd = RECV_FUNCTION(socket, (char *)buf, sz, 0);

    if (recvd == -1) {
        err = LastError();
        if (err == SOCKET_EWOULDBLOCK ||
            err == SOCKET_EAGAIN)
            return -2;

        else if (err == SOCKET_ECONNRESET)
            return -3;

        else if (err == SOCKET_EINTR)
            return -4;

        else
            return -1;
    }
    else if (recvd == 0)
        return -5;

    return recvd;
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:36,代码来源:cyassl_io.c


示例17: CHECK_ERROR

result_t fs_base::readdir(const char *path, obj_ptr<List_base> &retVal, AsyncEvent *ac)
{
    if (!ac)
        return CHECK_ERROR(CALL_E_NOSYNC);

    WIN32_FIND_DATAW fd;
    HANDLE hFind;
    wstring fpath;
    obj_ptr<List> oa;

    fpath = utf8to16String(path);
    fpath.append(L"\\*", 2);

    hFind = FindFirstFileW(fpath.c_str(), &fd);
    if (hFind == INVALID_HANDLE_VALUE)
        return CHECK_ERROR(LastError());

    oa = new List();

    do
    {
        obj_ptr<Stat> pStat = new Stat();
        pStat->fill(fd);
        oa->append(pStat);
    }
    while (FindNextFileW(hFind, &fd));

    FindClose(hFind);

    retVal = oa;

    return 0;
}
开发者ID:icodingforfood,项目名称:fibjs,代码行数:33,代码来源:fs.cpp


示例18: paths_GetLongPath

/**
 * @brief Get file status into member variables
 *
 * Reads file's status (size and full path).
 * @return true on success, false on failure.
 * @note Function sets filesize member to zero, and status as read
 * also when failing. That is needed so caller doesn't need to waste
 * time checking if file already exists (and ignores return value).
 */
bool UniLocalFile::DoGetFileStatus()
{
	struct _stati64 fstats = {0};
	m_statusFetched = -1;
	m_lastError.ClearError();

	m_filepath = paths_GetLongPath(m_filepath.c_str());

	if (_tstati64(m_filepath.c_str(), &fstats) == 0)
	{
		m_filesize = fstats.st_size;
		if (m_filesize == 0)
		{
			// if m_filesize equals zero, the file size is really zero or the file is a symbolic link.
			// use GetCompressedFileSize() to get the file size of the symbolic link target whether the file is symbolic link or not.
			// if the file is not symbolic link, GetCompressedFileSize() will return zero.
			// NOTE: GetCompressedFileSize() returns error for pre-W2K windows versions
			DWORD dwFileSizeLow, dwFileSizeHigh;
			dwFileSizeLow = GetCompressedFileSize(m_filepath.c_str(), &dwFileSizeHigh);
			if (GetLastError() == 0)
				m_filesize = ((__int64)dwFileSizeHigh << 32) + dwFileSizeLow;
		}
		m_statusFetched = 1;

		return true;
	}
	else
	{
		m_filesize = 0;
		m_statusFetched = 1; // Yep, done for this file still
		LastError(_T("_tstati64"), 0);
		return false;
	}
}
开发者ID:YueLinHo,项目名称:WinMerge,代码行数:43,代码来源:UniFile.cpp


示例19: GetCurrentProcess

result_t os_base::memoryUsage(v8::Local<v8::Object> &retVal)
{
    size_t rss = 0;

    HANDLE current_process;
    PROCESS_MEMORY_COUNTERS pmc;

    current_process = GetCurrentProcess();

    if (!GetProcessMemoryInfo(current_process, &pmc, sizeof(pmc)))
        return CHECK_ERROR(LastError());

    rss = pmc.WorkingSetSize;

    v8::Local<v8::Object> info = v8::Object::New(isolate);

    v8::HeapStatistics v8_heap_stats;
    isolate->GetHeapStatistics(&v8_heap_stats);
    info->Set(v8::String::NewFromUtf8(isolate, "rss"), v8::Integer::New(isolate, (int32_t)rss));
    info->Set(v8::String::NewFromUtf8(isolate, "heapTotal"),
              v8::Integer::New(isolate, (int32_t)v8_heap_stats.total_heap_size()));
    info->Set(v8::String::NewFromUtf8(isolate, "heapUsed"),
              v8::Integer::New(isolate, (int32_t)v8_heap_stats.used_heap_size()));
    info->Set(v8::String::NewFromUtf8(isolate, "nativeObjects"),
              v8::Integer::New(isolate, (int32_t)g_obj_refs));

    retVal = info;

    return 0;
}
开发者ID:CYCOK,项目名称:fibjs,代码行数:30,代码来源:os_win.cpp


示例20: CHECK_ERROR

result_t SubProcess::kill(int32_t signal)
{
	if (!TerminateProcess((HANDLE)m_pid, -1))
		return CHECK_ERROR(LastError());

	return 0;
}
开发者ID:yeyuguo,项目名称:fibjs,代码行数:7,代码来源:SubProcess_win.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ LastNtStatus函数代码示例发布时间:2022-05-30
下一篇:
C++ Last函数代码示例发布时间: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