Exemplo n.º 1
0
	string& string::operator= (string&& str)
	{
		if (this != &str)
		{
			moveData(str);
		}
		return *this;
	}
Exemplo n.º 2
0
// inserts data into file
// 
// args:	offset in this file to start inserting data at
//			size of data to insert into this file
//			file descriptor of file to insert data from
// returns:	size of data inserted from input file
//			ERROR_RETURN if error
u32  GenericFile::insertData(u32 insertOffset, u32 insertSize, FILE* in_fd)
{
	// make sure file is open
	if(!isOpen())
		return ERROR_RETURN;
	
	// move existing data to create a space for adding new data into
	if(!moveData(insertOffset, insertSize))
		return ERROR_RETURN;
	
	// insert data at insert offset
	if(readInData(insertOffset, insertSize, in_fd) != insertSize)
		return ERROR_RETURN;
	
	return insertSize;
}
Exemplo n.º 3
0
bool IOBuffer::ensureSize(rx_uint32 expectedSize) {
	
	// 1. we have enough space
	if(published + expectedSize <= size) {
		return true;
	}
	
	// 2. not enough space, try to move it.
	moveData();
	
	// 3. check if we have enough space after moving..
	if(published + expectedSize <= size) {
		return true;
	}
	
	// 4. not enough space. 
	// first allocate at least 1/3 of what we have and no less then min_chunk_size
	if( (published + expectedSize - size) < (size / 3)) {
		expectedSize = size + size / 3 - published;
	}
	if(expectedSize < min_chunk_size) {
		expectedSize = min_chunk_size;
	}
	
	// 5. create a new buffer.
	rx_uint8* tmp_buffer = new rx_uint8[published + expectedSize];
	
	// 6. copy exising data to tmp buffer
	if(buffer != NULL) {
		memcpy(tmp_buffer, buffer, published);
		delete[] buffer;
	}
	buffer = tmp_buffer;
	
	// 7. update our size.
	size = published + expectedSize;
	return true;
}
Exemplo n.º 4
0
// remove data from file
// (updates section headers to point to correct offsets)
// 
// args:	offset in this file to start removing data from
//			size of data to remove from this file
// returns:	size of data removed from input file
//			ERROR_RETURN if error
u32  GenericFile::removeData(u32 removeOffset, u32 removeSize)
{
	// make sure file is open
	if(!isOpen())
		return ERROR_RETURN;
	
	// move existing data to 'cover up' the old info
	if(!moveData(removeOffset, -(s32)removeSize))
		return ERROR_RETURN;
	
	// set new end of file marker
	fseek(fd, 0, SEEK_END);
	u32 eofOffset = ftell(fd) - removeSize;
	char filename[256];
	strcpy(filename, getFilename());
	close();
	if(!SetNewEndOfFile(filename, eofOffset))
		return ERROR_RETURN;
	if(!open(filename))
		return ERROR_RETURN;
	
	return removeSize;
}
Exemplo n.º 5
0
	Answer& Answer::operator=(Answer &&rhs) {
		moveData(static_cast<Answer&&>(rhs));
		return *this;
	}
Exemplo n.º 6
0
	Answer::Answer(Answer&& rhs) {
		moveData(static_cast<Answer&&>(rhs));
	}
Exemplo n.º 7
0
 string::string(string&& str){
     moveData(str);
 }