当前位置: 首页>>代码示例>>C++>>正文


C++ KData::getData方法代码示例

本文整理汇总了C++中KData::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ KData::getData方法的具体用法?C++ KData::getData怎么用?C++ KData::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KData的用法示例。


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

示例1: rename

bool KDirectory::rename(const KData& from, const KData& to)
{
	if (rename(from.getData(), to.getData()) == 0)
		return true;
	else
		return false;
}
开发者ID:korman,项目名称:Temp,代码行数:7,代码来源:KDirectory.cpp

示例2: deleteFile

bool KFile::deleteFile(const KData& fullFilePath)
{
	if (remove(fullFilePath.getData()) == 0)
		return true;
	else
		return false;
}
开发者ID:korman,项目名称:Temp,代码行数:7,代码来源:KFile.cpp

示例3: chDir

bool KDirectory::chDir(const KData& dir)
{
	if (chdir(dir.getData()) == 0)
		return true;
	else
		return false;
}
开发者ID:korman,项目名称:Temp,代码行数:7,代码来源:KDirectory.cpp

示例4: createDir

bool KDirectory::createDir(const KData& dir)
{
	int pos = 0;
	while (true)
	{
		if ((pos = dir.find("/", pos)) == -1)
			pos = dir.length();
		KData dtDir = dir.substr(0, pos);
		pos++;
		if (!dtDir.isEmpty())
		{
			if (!isDirectoryExist(dtDir))
			{
				/*
				 if ( -1 == mkdir(dtDir.getData(),S_IRWXU|S_IRWXG|S_IRWXO) )
				 {
				 return false;
				 }
				 */
				if (MKDIR(dtDir.getData()) != 0)
				{
					return false;
				}

			}
		}
		if (pos >= (int) dir.length())
			break;
	}
	return true;
}
开发者ID:korman,项目名称:Temp,代码行数:31,代码来源:KDirectory.cpp

示例5: isDirectoryExist

bool KDirectory::isDirectoryExist(const KData& dir)
{
	struct stat statbuf;
	if (stat(dir.getData(), &statbuf) == -1)
		return false;
	if (S_ISDIR(statbuf.st_mode))
		return true;
	else
		return false;
}
开发者ID:korman,项目名称:Temp,代码行数:10,代码来源:KDirectory.cpp

示例6: createFileDir

bool KDirectory::createFileDir(const KData& dir)
{
	int pos = 0;
	while (true)
	{
		if ((pos = dir.find("/", pos)) == -1)
			break;
		KData dtDir = dir.substr(0, pos);
		pos++;
		if (!dtDir.isEmpty())
		{
			if (!isDirectoryExist(dtDir))
			{
				if (MKDIR(dtDir.getData()) != 0)
				{
					return false;
				}
			}
		}
	}
	return true;
}
开发者ID:korman,项目名称:Temp,代码行数:22,代码来源:KDirectory.cpp

示例7: atoi

void
KNetworkAddress::setHostName( const KData& theAddress )
{
    const char* cstrAddress;
    KData sAddress, sPort;
    unsigned int length = theAddress.length();
    unsigned int colonPos = length;
    cstrAddress = theAddress.getData();
    for ( int i = 0; *cstrAddress != '\0'; cstrAddress++, i++ )
    {
        if ( *cstrAddress == ':' )
        {
            colonPos = i;
            break;
        }
    }
    if ( colonPos != length )
    {
        sAddress = theAddress.substr( 0, colonPos );
        sPort = theAddress.substr( colonPos+1, length-colonPos-1 );
        colonPos = atoi( sPort.getData() );
        if ( colonPos )
        {
            aPort = colonPos;
        }
        else
        {
        }
    }
    else // No ':' in input string;
    {
        sAddress = theAddress;
    }
    rawHostName = sAddress;
    ipAddressSet = false;
}
开发者ID:chaosren,项目名称:HHHH,代码行数:36,代码来源:KNetworkAddress.cpp

示例8: strtoul

bool
KNetworkAddress::is_valid_ip_addr( const KData& addr, char* retaddr )
{
	unsigned long maskcheck = ~255;
	const char *advancer = addr.getData();
	unsigned long octet;
	char *nextchar;
	char ipAddr[ IPV4_LENGTH ];
	if ( ( *(advancer) == 0 ) || (*(advancer) == ' ') || (*(advancer) == '\t') )
	{	
		return false;
	}
	octet = strtoul( advancer, &nextchar, 10 );
	if( (*nextchar != '.') || (octet & maskcheck) || (octet == 0) )
	{
		return false;
	}
	assert( octet < 256 );
	ipAddr[0] = (char)octet;
	
	advancer = nextchar + 1;
	if( (*(advancer) == 0) || (*(advancer) == ' ') || (*(advancer) == '\t') )
	{
     	return false;
	}
	octet = strtoul( advancer, &nextchar, 10 );
	if( (*nextchar != '.') || (octet & maskcheck) )
	{
		return false;
	}
	assert( octet < 256 );
	ipAddr[1] = (char)octet;
	advancer = nextchar+1;
	if( (*(advancer) == 0) || (*(advancer) == ' ') || (*(advancer) == '\t') )
	{
		return false;
	}
	octet = strtoul(advancer, &nextchar, 10);
	if((*nextchar != '.') || (octet & maskcheck))
	{
		return false;
	}
	assert( octet < 256 );
	ipAddr[2] = (char)octet;
    advancer = nextchar+1;
    if ((*(advancer) == 0) || (*(advancer) == ' ') || (*(advancer) == '\t'))
    {
        return false;
    }
    octet = strtoul(advancer, &nextchar, 10);
    if ( (*nextchar) || (octet & maskcheck) || (octet == 0) )
    {	
        return false;
    }
	assert( octet < 256 );
    ipAddr[3] = (char)octet;
	
	if ( NULL != retaddr )
	{
		memcpy( retaddr, ipAddr, IPV4_LENGTH );
	}
    return true;
}
开发者ID:chaosren,项目名称:HHHH,代码行数:63,代码来源:KNetworkAddress.cpp

示例9: renameFile

bool KFile::renameFile(const KData& from, const KData& to, bool replace)
{
	return rename(from.getData(), to.getData());
}
开发者ID:korman,项目名称:Temp,代码行数:4,代码来源:KFile.cpp

示例10: getHttpFileMemory

int KHttp::getHttpFileMemory(const KData& server, const KData& httpfile,
		char** ppKData)
{
	char* pKData = NULL;
	KData httpRequest = "GET ";
	httpRequest += httpfile;
	httpRequest += " HTTP/1.1";
	httpRequest += CRLF;
	httpRequest += "Host: ";
	httpRequest += server;
	httpRequest += CRLF;
	httpRequest += CRLF;
	unsigned char buff[MTU];
	KTcpClientSocket clientSock(server, 80);
	clientSock.connect();
	KConnection &conn = clientSock.getConn();
	string stringTmp = httpRequest.getData();
	conn.writeData(stringTmp);
	int iRead = 0;
	bool bFound = false;
	KData dtHead;
	int iLength = 0;
	int iWrite = 0;
	int m_iStatusCode = 0;
	bool bRun = true;
	while ((iRead = conn.readn(buff, MTU)) > 0 && bRun)
	{
		if (!bFound)
		{
			for (int i = 0; i < iRead - 4; i++)
			{
				if (buff[i] == 0x0d && buff[i + 1] == 0x0a
						&& buff[i + 2] == 0x0d && buff[i + 3] == 0x0a)
				{
					KData dtLine;
					dtHead = KData((char*) buff, i + 4);
					KData dtRequestLine, dtCode;

					if (NOT_FOUND == dtHead.match(CRLF, &dtRequestLine, false))
					{
						return -1;
					}
					if (NOT_FOUND == dtRequestLine.match("HTTP/1.1", NULL, true)
							&& NOT_FOUND
									== dtRequestLine.match("HTTP/1.0", NULL,
											true))
					{
						return -1;
					}
					if (NOT_FOUND == dtRequestLine.match(SP, NULL, true))
					{
						return -1;
					}
					if (NOT_FOUND == dtRequestLine.match(SP, &dtCode, true))
					{
						return -1;
					}
					if ((int) dtCode == 0 && (int) dtCode != 200)
					{
						return -1;
					}

					while (NOT_FOUND != dtHead.match(CRLF, &dtLine, true))
					{
						KData dtBefVal;
						if (FOUND == dtLine.match(":", &dtBefVal, true))
						{
							dtBefVal.removeSpaces();
							if (isEqualNoCase(dtBefVal, "Content-Length"))
							{
								dtLine.removeSpaces();
								iLength = (int) dtLine;
							}
						}
						else if (NOT_FOUND
								!= dtLine.match("HTTP/1.1", NULL, true))
						{
							dtLine.removeSpaces();
							dtLine.match(" ", &dtBefVal, true);
							m_iStatusCode = (int) dtBefVal;
						}

					}
					if (iLength <= 0)
					{
						return -1;
					}
					else if (m_iStatusCode != 200)
					{
						return -1;
					}
					else
					{
						pKData = new char[iLength];
					}

					memcpy(pKData, &buff[i + 4], iRead - i - 4);
					iWrite += (iRead - i - 4);
					bFound = true;

//.........这里部分代码省略.........
开发者ID:korman,项目名称:Temp,代码行数:101,代码来源:KHttp.cpp

示例11: getHttpFile

int KHttp::getHttpFile(const KData& kServer, const KData& kHttpFile,
		const KData& kSaveFile, int nStartPos)
{
	LOGD("Entry getHttpFile");
	m_dtHttpServer = kServer;
	m_dtHttpFile = kHttpFile;
	m_bChunked = false;
	m_iWriteLen = nStartPos;
	m_iLength = 0;
	m_clientSock.close();
	m_kCnnect.close();

	_respHeadMap.clear();
	m_iNotifyPos = 0;
	m_iNotifyGap = 0;
	m_iContentLength = 0;
	m_iStatusCode = 0;
	bool bGet = (_paramMap.size() == 0);

	KFile kFile;
	KData kHttpRequest;
	KData kDataPost;

	if (bGet)
	{
		kHttpRequest = "GET ";
	}
	else
	{
		kHttpRequest = "POST ";
		map<KData, KData>::iterator iter;
		for (iter = _paramMap.begin(); iter != _paramMap.end(); iter++)
		{
			if (iter != _paramMap.begin())
				kDataPost += "&";
			kDataPost += iter->first;
			kDataPost += "=";
			kDataPost += iter->second;
		}
	}

	kHttpRequest += kHttpFile;
	kHttpRequest += " HTTP/1.1";
	kHttpRequest += CRLF;
	kHttpRequest += "Host: ";
	kHttpRequest += kServer;
	kHttpRequest += CRLF;
	kHttpRequest += "Accept: */*";
	kHttpRequest += CRLF;
	if (!m_dtUserAgent.isEmpty())
	{
		kHttpRequest += "User-Agent: ";
		kHttpRequest += m_dtUserAgent;
		kHttpRequest += CRLF;
	}

	if (nStartPos > 0)
	{
		kHttpRequest += "RANGE: bytes=";
		kHttpRequest += nStartPos;
		kHttpRequest += "-";
		kHttpRequest += CRLF;
	}

	kHttpRequest += "Pragma: no-cache";
	kHttpRequest += CRLF;
	kHttpRequest += "Cache-Control: no-cache";
	kHttpRequest += CRLF;
	kHttpRequest += "Connection: close";
	kHttpRequest += CRLF;

	if (!bGet)
	{
		kHttpRequest += "Content-Type: application/x-www-form-urlencoded";
		kHttpRequest += CRLF;
		kHttpRequest += "Content-Length: ";
		kHttpRequest += KData((int) kDataPost.length());
		kHttpRequest += CRLF;
	}

	kHttpRequest += CRLF;

	char szBuffer[MTU] = {0};

	if (m_dtHttpProxy.isEmpty())
	{
		LOGD("Connect to Server:  %s", kServer.getData() );
		m_clientSock.setServer(kServer, 80);
	}
	else
	{
		LOGD("Connect to Server:  %s", m_dtHttpProxy.getData() );
		m_clientSock.setServer(m_dtHttpProxy, 80);
	}
	m_clientSock.initSocket();
	if (!m_clientSock.connect())
	{
		LOGERROR("m_clientSock.connect() failed");
		return -1;
	}
//.........这里部分代码省略.........
开发者ID:korman,项目名称:Temp,代码行数:101,代码来源:KHttp.cpp


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