Пример #1
0
// ********** File IO **************** //
bool cStringList::FromFile(const cString & fname) {
	if(fname.Contains('*')) return false;
	#ifndef WIN32
	if(!FileExists(fname)) return false;
	struct stat buf;
	stat(fname,&buf);
	ifstream infile(fname);
	
	if(fname.Contains("/proc") || buf.st_size==0) {
		if(!FromFile(infile)) { infile.close(); return false; }
	} else {
		if(!FromFile(infile,buf.st_size)) { infile.close(); return false; }
	}
	infile.close();
	
	
	if((*this)[-1]=="" && Length()!=0) used--;
	#else
	FILE* fptr=fopen(fname,"r");
	FromFile(fptr);
	fclose(fptr);
	#endif
	
	return true;
}
Пример #2
0
AutoPtr<IGestureLibrary> GestureLibraries::FromFile(
    /* [in] */ const String& path)
{
    AutoPtr<IFile> file;
    CFile::New(path, (IFile**)&file);
    return FromFile(file);
}
bool IPlatformFile::CopyFile(const TCHAR* To, const TCHAR* From)
{
	const int64 MaxBufferSize = 1024*1024;

	TAutoPtr<IFileHandle> FromFile(OpenRead(From));
	if (!FromFile.IsValid())
	{
		return false;
	}
	TAutoPtr<IFileHandle> ToFile(OpenWrite(To));
	if (!ToFile.IsValid())
	{
		return false;
	}
	int64 Size = FromFile->Size();
	if (Size < 1)
	{
		check(Size == 0);
		return true;
	}
	int64 AllocSize = FMath::Min<int64>(MaxBufferSize, Size);
	check(AllocSize);
	uint8* Buffer = (uint8*)FMemory::Malloc(int32(AllocSize));
	check(Buffer);
	while (Size)
	{
		int64 ThisSize = FMath::Min<int64>(AllocSize, Size);
		FromFile->Read(Buffer, ThisSize);
		ToFile->Write(Buffer, ThisSize);
		Size -= ThisSize;
		check(Size >= 0);
	}
	FMemory::Free(Buffer);
	return true;
}
Пример #4
0
AutoPtr<IGestureLibrary> GestureLibraries::FromPrivateFile(
    /* [in] */ IContext *context,
    /* [in] */ const String& name)
{
    AutoPtr<IFile> file;
    context->GetFileStreamPath(name, (IFile**)&file);
    return FromFile(file);
}
Пример #5
0
CXMLElement* CXMLElement::FromFile(LPCTSTR pszPath, BOOL bHeader)
{
	HANDLE hFile = CreateFile( pszPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );

	if ( hFile == INVALID_HANDLE_VALUE ) return NULL;

	CXMLElement* pXML = FromFile( hFile, bHeader );

	CloseHandle( hFile );

	return pXML;
}
Пример #6
0
CVersionInfo::CVersionInfo(const CString& strModulePath, LPCTSTR lpszResourceId, WORD wLangId):
m_strModulePath(strModulePath), m_lpszResourceId((LPTSTR)lpszResourceId), m_wLangId(wLangId), m_bRegularInfoOrder(TRUE)
{
	// LPCTSTR lpszResourceId may contain integer value pointer to string, in case it's a string make a local copy of it
	if (IS_INTRESOURCE(lpszResourceId)) 
    { 
        m_strStringResourceId = lpszResourceId; 
    } 
	
	ZeroMemory(&m_vsFixedFileInfo, sizeof VS_VERSION_INFO);

	FromFile(strModulePath, lpszResourceId, wLangId);
}
Пример #7
0
void cStringList::FromPopen(cString cmdline) {
	ClearAll();
	FILE* fileptr=NULL;
	fileptr=popen(cmdline, "r" );
	if(fileptr!=NULL) {
		FromFile(fileptr);
		pclose(fileptr);
	}
	
	Compact();
	if(Length()>1)
		if((*this)[-1]==(*this)[-2]) {
			(*this)[-1]="";
		}
	Compact();
}
Пример #8
0
bool cFileList::GetList(cString starting_path, cString pattern) {
	cString cmdline;
	if(cis) cmdline="find "+starting_path+" -iname \""+pattern+"\"";
	else cmdline="find "+starting_path+" -name \""+pattern+"\"";
	
	if(!rec) cmdline+=" -maxdepth 1";
//	cout<<"about to execute:"<<cmdline<<endl;
//	pclose(FromFile(popen(cmdline+" -type f","r")));
	pclose(FromFile(popen(cmdline,"r")));
	cout<<endl;
	
//	cerr<<"found "<<Length()<<" entries"<<endl;
	
	if(Length()==0) return false;
	
//	for(int j=0; j<Length(); j++) cerr<<j+1<<"/"<<Length()<<":"<<Array[j]<<endl;
//	cout<<endl;
	
	Array[Length()-1]="";
	//UCompact();
	cFile *temp;
	if(starting_path[0]!='/') {
		for(int i=0; i<Length(); i++) {
			Array[i]=Array[i].ChopLf('/');
			if(Array[i]!="") {
				temp=new cFile(Array[i],false,false,false);
				if(temp->IsDirectory()) Array[i]="";
				delete temp;
			}
		}
	}
//	cout<<endl;
//	for(int j=0; j<Length(); j++) cerr<<j+1<<"/"<<Length()<<":"<<Array[j]<<endl;
//	cout<<endl;
	Compact();
//	cout<<endl;
//	for(int j=0; j<Length(); j++) cerr<<j+1<<"/"<<Length()<<":"<<Array[j]<<endl;
//	cout<<endl;
	return true;
}
Пример #9
0
const MockFile* FileMock::FromFile(const File* file, const char* filename, int line)
{
    return FromFile(const_cast<File*>(file), filename, line);
}
Пример #10
0
Component *ComponentOp2::Copy()
{
  std::stringstream t;
  ToFile(t);
  return FromFile(t);
}
Пример #11
0
	inline rapidjson::Document FromFile(const std::string& name)
	{
		return FromFile(name.c_str());
	}
Пример #12
0
void GameRendering::InitBuffers() {

    XBO * obj;

    // Spheres

    obj = FromFile("models/sphere.xbo");

    this->sphereHighVAO = Global::CreateVertexArray(obj, 0);

    this->sphereHighVAO->enableVertexAttribute(0);
    this->sphereHighVAO->enableVertexAttribute(1);
    this->sphereHighVAO->enableVertexAttribute(2);

    delete obj;

    obj = FromFile("models/sphereLow.xbo");

    this->sphereLowVAO = Global::CreateVertexArray(obj, 0);

    this->sphereLowVAO->enableVertexAttribute(0);
    this->sphereLowVAO->enableVertexAttribute(1);
    this->sphereLowVAO->enableVertexAttribute(2);

    delete obj;

    // Rings

    obj = FromFile("models/ring.xbo");
    this->ringVAO = Global::CreateVertexArray(obj, 0);

    this->ringVAO->enableVertexAttribute(0);
    this->ringVAO->enableVertexAttribute(1);
    this->ringVAO->enableVertexAttribute(2);

    delete obj;

    // Emerald

    obj = FromFile("models/emerald.xbo");
    this->emeraldVAO = Global::CreateVertexArray(obj, 0);

    this->emeraldVAO->enableVertexAttribute(0);
    this->emeraldVAO->enableVertexAttribute(1);
    this->emeraldVAO->enableVertexAttribute(2);

    delete obj;

    // World plane
    this->worldVAOHigh = new WorldVertexArray(10, 4);
    this->worldVAOLow = new WorldVertexArray(10, 2);

    // Sky
    this->skyVAO = new SkyVertexArray(2500, vec2(15, 60), vec2(5, 10), 10);

    // Sonic

    vector<string> runFrames, jumpFrames, standFrames;

    runFrames.push_back("models/sonic0.xbo");
    runFrames.push_back("models/sonic1.xbo");
    runFrames.push_back("models/sonic2.xbo");
    runFrames.push_back("models/sonic3.xbo");
    runFrames.push_back("models/sonic4.xbo");
    runFrames.push_back("models/sonic5.xbo");
    runFrames.push_back("models/sonic6.xbo");
    runFrames.push_back("models/sonic7.xbo");
    runFrames.push_back("models/sonic8.xbo");
    runFrames.push_back("models/sonic9.xbo");
    runFrames.push_back("models/sonic10.xbo");
    runFrames.push_back("models/sonic11.xbo");

    jumpFrames.push_back("models/sonicJump.xbo");

    standFrames.push_back("models/sonicStand.xbo");

    this->sonicRun = new Sonic(runFrames);
    this->sonicJump = new Sonic(jumpFrames);
    this->sonicStand = new Sonic(standFrames);
}
Пример #13
0
bool cStringList::FromFile(int fd) {
	FILE* fptr=fdopen(fd,"r");
	bool r=FromFile(fptr);
	fclose(fptr);
	return r;
}