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


C++ FileObject类代码示例

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


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

示例1: amx_fwrite

// native fwrite(file, data, mode);
static cell AMX_NATIVE_CALL amx_fwrite(AMX *amx, cell *params)
{
	FileObject* fp = reinterpret_cast<FileObject*>(params[1]);

	if (!fp)
	{
		return 0;
	}

	cell   data = params[2];
	size_t size = params[3];

	switch (size)
	{
		case BLOCK_CHAR:
		{
			char value = static_cast<char>(data);
			return fp->Write(&value, sizeof(value));
		}
		case BLOCK_SHORT:
		{
			short value = static_cast<short>(data);
			return fp->Write(&value, sizeof(value));
		}
		case BLOCK_INT:
		{
			int value = static_cast<int>(data);
			return fp->Write(&value, sizeof(value));
		}
	}

	return 0;
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:34,代码来源:file.cpp

示例2: ERROR_MSG

//-------------------------------------------------------------------------------------
bool FileDataDownload::process()
{
	ResourceObjectPtr fptr = Resmgr::getSingleton().openResource(path_.c_str(), "rb");
	if(fptr == NULL || !fptr->valid())
	{
		ERROR_MSG(fmt::format("FileDataDownload::process(): can't open {}.\n", 
			Resmgr::getSingleton().matchRes(path_).c_str()));
		
		error_ = true;
		return false;
	}

	FileObject* f = static_cast<FileObject*>(fptr.get());
	if(totalBytes_ == 0)
	{
		f->seek(0, SEEK_END);
		totalBytes_ = f->tell();
	}

	f->seek(totalSentBytes_, SEEK_SET);
	remainSent_ = f->read(stream_, 65535);
	currSent_ = 0;

	if(remainSent_ == 0)
		remainSent_ = totalBytes_ - totalSentBytes_;

	return false;
}
开发者ID:lmb0989,项目名称:kbengine,代码行数:29,代码来源:data_download.cpp

示例3: amx_fprintf

// native fprintf(file, const fmt[], any:...);
static cell AMX_NATIVE_CALL amx_fprintf(AMX *amx, cell *params)
{
	FileObject* fp = reinterpret_cast<FileObject*>(params[1]);

	if (!fp)
	{
		return 0;
	}

	int length;
	const char* string = format_amxstring(amx, params, 2, length);

	if (ValveFile *vfile = fp->AsValveFile())
	{
		return g_FileSystem->FPrintf(vfile->handle(), const_cast<char*>("%s"), string);
	}
	else if (SystemFile *sysfile = fp->AsSystemFile())
	{
		return fprintf(sysfile->handle(), "%s", string);
	}
	else
	{
		assert(false);
	}
	
	return 0;
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:28,代码来源:file.cpp

示例4: readColladaFile

domCOLLADA* ColladaShapeLoader::readColladaFile(const String& path)
{
   // Check if this file is already loaded into the database
   domCOLLADA* root = sDAE.getRoot(path.c_str());
   if (root)
      return root;

   // Load the Collada file into memory
   FileObject fo;
   if (!fo.readMemory(path))
   {
      daeErrorHandler::get()->handleError(avar("Could not read %s into memory", path.c_str()));
      return NULL;
   }

   root = sDAE.openFromMemory(path.c_str(), (const char*)fo.buffer());
   if (!root || !root->getLibrary_visual_scenes_array().getCount()) {
      daeErrorHandler::get()->handleError(avar("Could not parse %s", path.c_str()));
      return NULL;
   }

   // Fixup issues in the model
   ColladaUtils::applyConditioners(root);

   // Recursively load external DAE references
   TSShapeLoader::updateProgress(TSShapeLoader::Load_ExternalRefs, "Loading external references...");
   for (S32 iRef = 0; iRef < root->getDocument()->getReferencedDocuments().getCount(); iRef++) {
      String refPath = (daeString)root->getDocument()->getReferencedDocuments()[iRef];
      if (refPath.endsWith(".dae") && !readColladaFile(refPath))
         daeErrorHandler::get()->handleError(avar("Failed to load external reference: %s", refPath.c_str()));
   }
   return root;
}
开发者ID:mray,项目名称:terminal-overload,代码行数:33,代码来源:colladaShapeLoader.cpp

示例5: amx_fwrite_blocks

// native fwrite_blocks(file, const data[], blocks, mode);
static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params)
{
	FileObject* fp = reinterpret_cast<FileObject*>(params[1]);

	if (!fp)
	{
		return 0;
	}

	cell* data  = get_amxaddr(amx, params[2]);
	cell blocks = params[3];
	cell size   = params[4];

	size_t read = 0;

	switch (size)
	{
		case BLOCK_CHAR:
		{
			for (cell i = 0; i < blocks; ++i)
			{
				char value = data[i];

				if (fp->Write(&value, sizeof(value)) != sizeof(value))
				{
					break;
				}

				read += sizeof(value);
			}
			break;
		}
		case BLOCK_SHORT:
		{
			for (cell i = 0; i < blocks; ++i)
			{
				short value = data[i];

				if (fp->Write(&value, sizeof(value)) != sizeof(value))
				{
					break;
				}

				read += sizeof(value);
			}
			break;
		}
		case BLOCK_INT:
		{
			read = fp->Write(data, sizeof(cell) * blocks);
			break;
		}
		default:
		{
			return 0;
		}
	}

	return read / size;
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:61,代码来源:file.cpp

示例6: strcpy

FileObject* FTPSession::FindPathObject(const char * filepath) {
	if (!filepath)
		return NULL;

	char tempstr[MAX_PATH];
	strcpy(tempstr, filepath);

	FileObject * current = m_rootObject;

	char * curname = strtok (tempstr, "/");

	while(curname) {
		if (current->GetChildCount() == 0)	//search did not finish, but cannot find child
			return NULL;

		int i = 0;
		int count = current->GetChildCount();
		for(i = 0; i < count; i++) {
			if ( !strcmp( current->GetChild(i)->GetName(), curname ) ) {
				current = current->GetChild(i);
				curname = strtok (NULL, "/");
				break;
			}
		}

		if (i == count)	//none of the children match
			return NULL;
	}

	return current;
}
开发者ID:Praymundo,项目名称:NppFTP,代码行数:31,代码来源:FTPSession.cpp

示例7: edit

void FileCommands::edit(FileSystemUser* fileSystem, string fileName) {
	FileObject* fo = fileSystem->getFileObject();
	fileName += "$";
	int t = fo->getObject(fileName);
	if(t) {
		fo->setPos(t);
		string newContent;
		char buff[512];
		cout<<"enter new content: ";
		cin.getline(buff, 512);
		newContent = buff;
		int begPos = fo->getBeginPos();
		string sys = fileSystem->getSystem();
		fo->go(fileName);
		int beg = fo->getPos();
		fo->setEndPos();
		int end = fo->getPos();
		sys.erase(beg, end-beg + 1);
		sys.insert(beg, newContent);
		fileSystem->setNewSystem(sys);
		fo->setBeginPos(begPos);
		fo->setFileContent(fileName, newContent);
	}else {
		notFoundFile(fileName);
		return;
	}
	
}
开发者ID:ShinShil,项目名称:spovm,代码行数:28,代码来源:fileCommands.cpp

示例8: OnConnect

int FTPWindow::OnConnect(int code) {
	if (code != 0)	//automated connect
		return 0;



	FileObject * root = m_ftpSession->GetRootObject();
	m_treeview.AddRoot(root);

	FileObject * last = root;
	while(last->GetChildCount() > 0) {
		last = last->GetChild(0);
	}

	m_treeview.EnsureObjectVisible(last);
	TreeView_Select(m_treeview.GetHWND(), last->GetData(), TVGN_CARET);
	m_ftpSession->GetDirectory(last->GetPath());

	TCHAR * info = SU::TSprintfNB(TEXT("Connected to %T"), m_ftpSession->GetCurrentProfile()->GetName());
	SetInfo(info);
	delete [] info;

	SetToolbarState();

	return 0;
}
开发者ID:Praymundo,项目名称:NppFTP,代码行数:26,代码来源:FTPWindow.cpp

示例9: lsdir

void FileCommands::lsdir(FileSystemUser* fileSystem) {
	FileObject* fo = fileSystem->getFileObject();
	cout<<endl;
	vector<string> dirs = fo->getDirs();
	for(int i = 0; i<dirs.size(); ++i) {
		cout<<dirs[i]<<endl;
	}	
	cout<<endl;
}
开发者ID:ShinShil,项目名称:spovm,代码行数:9,代码来源:fileCommands.cpp

示例10: lsfile

void FileCommands::lsfile(FileSystemUser* fileSystem) {
	FileObject* fo = fileSystem->getFileObject();
	cout<<endl;
	vector<string> files = fo->getFiles();
	for(int i = 0; i<files.size(); ++i) {
		cout<<files[i]<<endl;
	}	
	cout<<endl;
}
开发者ID:ShinShil,项目名称:spovm,代码行数:9,代码来源:fileCommands.cpp

示例11: amx_ftell

// native ftell(file);
static cell AMX_NATIVE_CALL amx_ftell(AMX *amx, cell *params)
{
	FileObject* fp = reinterpret_cast<FileObject*>(params[1]);

	if (!fp)
	{
		return 0;
	}

	return fp->Tell();
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:12,代码来源:file.cpp

示例12: amx_fflush

// native fflush(file);
static cell AMX_NATIVE_CALL amx_fflush(AMX *amx, cell *params)
{
	FileObject* fp = reinterpret_cast<FileObject*>(params[1]);

	if (fp)
	{
		return fp->Flush();
	}

	return -1;
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:12,代码来源:file.cpp

示例13: amx_feof

// native feof(file);
static cell AMX_NATIVE_CALL amx_feof(AMX *amx, cell *params)
{
	FileObject* fp = reinterpret_cast<FileObject*>(params[1]);

	if (fp)
	{
		return fp->EndOfFile();
	}

	return 1;
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:12,代码来源:file.cpp

示例14: amx_fclose

// native fclose(file);
static cell AMX_NATIVE_CALL amx_fclose(AMX *amx, cell *params)
{
	FileObject* fp = reinterpret_cast<FileObject*>(params[1]);

	if (fp)
	{
		fp->Close();
	}

	return 1;
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:12,代码来源:file.cpp

示例15: amx_fseek

// native fseek(file, position, start);
static cell AMX_NATIVE_CALL amx_fseek(AMX *amx, cell *params)
{
	FileObject* fp = reinterpret_cast<FileObject*>(params[1]);

	if (!fp)
	{
		return 0;
	}

	return !fp->Seek(params[2], params[3]);
}
开发者ID:KamilBrown,项目名称:amxmodx,代码行数:12,代码来源:file.cpp


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