Exemplo n.º 1
0
void CRIFFChunkTreeDlg::OnSave() 
{
	OPENFILENAME ofn;

	PrepareSimpleDialog(&ofn, *this, "*.txt");
	ofn.lpstrFilter = "Text files (*.txt)|*.txt||";
	ofn.Flags |= OFN_OVERWRITEPROMPT;
	if (!GetOpenSaveFileNameUTF8(&ofn, false)) 
		return;

	CFileStream* destFile = new CFileStream();
	if (STREAM_OK == destFile->Open(ofn.lpstrFile, StreamMode::Write))
	{
		CACHE* cache = new CACHE(4, 1<<18);
		cache->Open(destFile, CACHE_OPEN_WRITE);
		cache->Write(cUTF8Hdr, 3);

		RenderItem(cache, m_Tree.GetRootItem(), 0);

		cache->Close();
		delete cache;
		destFile->Close();
		delete destFile;
	}
	else
	{
		MessageBoxHelper::CouldNotOpenFileForWrite(ofn.lpstrFile);
	}
}
Exemplo n.º 2
0
//////////////////////////////////////////////////////////////////////
// CShader
//////////////////////////////////////////////////////////////////////
bool CShader::LoadSource(const std::string& filename, const std::string& prefix)
{
  if(filename.empty())
    return true;

  CFileStream file;

  std::string path = "special://xbmc/system/shaders/";
  path += CServiceBroker::GetRenderSystem()->GetShaderPath(filename);
  path += filename;
  if(!file.Open(path))
  {
    CLog::Log(LOGERROR, "CYUVShaderGLSL::CYUVShaderGLSL - failed to open file %s", filename.c_str());
    return false;
  }
  getline(file, m_source, '\0');

  size_t pos = 0;
  size_t versionPos = m_source.find("#version");
  if (versionPos != std::string::npos)
  {
    versionPos = m_source.find("\n", versionPos);
    if (versionPos != std::string::npos)
      pos = versionPos + 1;
  }
  m_source.insert(pos, prefix);
  return true;
}
Exemplo n.º 3
0
bool CDungeonConfig::Load(CFileStream&file)
{
    file.ReadUInt( m_nDungeonID );

    short nCount = 0;
    file.ReadShort(nCount) ;
    file.ReadString(m_strDungeonName, nCount);

    file.ReadShort(nCount) ;
    file.ReadString(m_strIconName, nCount);

    file.ReadShort(nCount) ;
    file.ReadString(m_strIconAtlas, nCount);

    file.ReadUInt(m_nStoryID);
    unsigned short nParcloseCount = 0;
    file.ReadUShort( nParcloseCount );
    for ( unsigned int i  = 0 ;i <  nParcloseCount; ++i )
    {
        unsigned int nParcloseID = 0;
        file.ReadUInt( nParcloseID );
        m_ParcloseList.push_back( nParcloseID );
    }

    return true;
}
Exemplo n.º 4
0
bool CShader::InsertSource(const std::string& filename, const std::string& loc)
{
  if(filename.empty())
    return true;

  CFileStream file;
  std::string temp;

  std::string path = "special://xbmc/system/shaders/";
  path += CServiceBroker::GetRenderSystem()->GetShaderPath(filename);
  path += filename;
  if(!file.Open(path))
  {
    CLog::Log(LOGERROR, "CShader::InsertSource - failed to open file %s", filename.c_str());
    return false;
  }
  getline(file, temp, '\0');

  size_t locPos = m_source.find(loc);
  if (locPos == std::string::npos)
  {
    CLog::Log(LOGERROR, "CShader::InsertSource - could not find location %s", loc.c_str());
    return false;
  }

  m_source.insert(locPos, temp);

  return true;
}
Exemplo n.º 5
0
CFileStream* CFileStream::NewL(TDesC& aFileName, TBool aIsWrite) 
	{
	CFileStream* r = new(ELeave) CFileStream(aIsWrite);
	CleanupStack::PushL(r);
	r->ConstructL(aFileName);
	CleanupStack::Pop();
	return r;
	}
Exemplo n.º 6
0
//???remove from here? make user use readers/writers directly?
void CDataServer::SavePRM(const nString& FileName, PParams Content)
{
	if (!Content.isvalid()) return;

	CFileStream File;
	if (!File.Open(FileName, SAM_WRITE)) return;
	CBinaryWriter Writer(File);
	Writer.WriteParams(*Content);
}
Exemplo n.º 7
0
void CGlobalMshLoader::SaveMeshToFile(const CMesh::TMeshContainer &mesh, const nstring &file)
{
	CFileStream sfile;

	sfile.Open(file, true, false);
	SaveMeshToStream(mesh, &sfile);

	sfile.Close();
}
Exemplo n.º 8
0
int main(int argc, char* argv[])
{
	
	CFileStream stream;
	stream.open("./test.txt","wb+");
	stream.write("aaa", 3);
	stream.close();

	return 0;
}
Exemplo n.º 9
0
bool CTargetConfig::Load(CFileStream&file)
{
    file.ReadUInt( m_nTargetID );

    short nCount = 0;
    file.ReadShort(nCount) ;
    file.ReadString(m_strDesc, nCount);

    file.ReadUInt( m_nFlag );

    nCount = 0;
    file.ReadShort(nCount) ;
    file.ReadString(m_strValue, nCount);

    unsigned short nStarValueCount = 0;
    file.ReadUShort(nStarValueCount);
    for (unsigned short i = 0 ; i < nStarValueCount; ++i)
    {
        unsigned short nStarCount = 0;
        unsigned int nStarValue = 0;

        file.ReadUShort(nStarCount);
        file.ReadUInt(nStarValue);

        m_mapStarValue[nStarCount] = nStarValue;
    }

    return true;
}
Exemplo n.º 10
0
void CLuckDrawPrizeBase::LoadFromFile(CFileStream &file)
{
    // Factory loads m_nType outside.
    file.ReadUChar(m_nLevel);
    file.ReadUChar(m_nSexNeed);
    file.ReadBool(m_bAnnounce);

    ASSERT(m_nType < ELuckDrawPrizeType_Max);
    ASSERT(m_nLevel < ELuckDrawPrizeLevel_Max);
    ASSERT(m_nSexNeed < ESexType_Max);
}
Exemplo n.º 11
0
CMesh::TMeshContainer &CGlobalMshLoader::LoadMeshFromFile(const nstring &file)
{
	CFileStream sfile;
	
	sfile.Open(file);
	LoadMeshFromStream(&sfile);

	sfile.Close();

	return gMeshBuffer;
}
Exemplo n.º 12
0
void CMedalCfgMgr::LoadConfigFromFile()
{
    std::string strFileName( g_sPath );
    strFileName.append( MEDAL_FILE_NAME );

    CFileStream file;
    file.open( strFileName.c_str(), "rb" );

    LoadMedalConfigFromFile( file );
    LoadProgressConfigFromFile( file );

    file.close();
}
Exemplo n.º 13
0
    bool CDocument::SaveToFile(const std::wstring& wsPath)
	{
		CFileStream* pStream = new CFileStream();
		if (!pStream || !pStream->OpenFile(wsPath, true))
			return false;

		if (m_pJbig2)
			m_pJbig2->FlushStreams();

		SaveToStream((CStream*)pStream);
		delete pStream;

		return true;
	}
Exemplo n.º 14
0
bool CThemeDropConfig::Load(CFileStream&file)
{
    file.ReadUInt( m_nThemeID );
    CMainlineDropConfig::Load( file );

    return true;
}
Exemplo n.º 15
0
bool CThemeParcloseConfig::Load(CFileStream & file)
{
    file.ReadUInt(m_nThemeID);
    CParcloseConfig::Load(file);

    return true;
}
Exemplo n.º 16
0
bool CThemeParcloseConfig::Save(CFileStream & file)
{
    file.WriteUInt(m_nThemeID);
    CParcloseConfig::Save(file);

    return true;
}
Exemplo n.º 17
0
bool CThemeDropConfig::Save(CFileStream&file)
{
    file.WriteUInt( m_nThemeID );
    CMainlineDropConfig::Save( file );

    return true;
}
Exemplo n.º 18
0
//////////////////////////////////////////////////////////////////////
// CShader
//////////////////////////////////////////////////////////////////////
bool CShader::LoadSource(const string& filename, const string& prefix)
{
  if(filename.empty())
    return true;

  CFileStream file;

  if(!file.Open("special://xbmc/system/shaders/" + filename))
  {
    CLog::Log(LOGERROR, "CYUVShaderGLSL::CYUVShaderGLSL - failed to open file %s", filename.c_str());
    return false;
  }
  getline(file, m_source, '\0');
  m_source.insert(0, prefix);
  return true;
}
Exemplo n.º 19
0
bool CShader::AppendSource(const string& filename)
{
  if(filename.empty())
    return true;

  CFileStream file;
  string temp;

  if(!file.Open("special://xbmc/system/shaders/" + filename))
  {
    CLog::Log(LOGERROR, "CShader::AppendSource - failed to open file %s", filename.c_str());
    return false;
  }
  getline(file, temp, '\0');
  m_source.append(temp);
  return true;
}
Exemplo n.º 20
0
	void CMemoryStream::LoadFrom( const char* lpszFileName )
	{
		CFileStream* pStream = new CFileStream();
#ifdef SCUT_UPHONE
		if (pStream->Open(lpszFileName, PO_CREAT | PO_RDWR | PO_BINARY, PS_IREAD | PS_IWRITE) == 0)
		{
			this->LoadFrom(pStream);
			delete pStream;
		}
#else
		if (pStream->Open(lpszFileName, 0, 0, "rb") == 0)
		{
			this->LoadFrom(pStream);
			delete pStream;
		}
#endif
	}
Exemplo n.º 21
0
	void CBaseMemoryStream::SaveTo( const char* lpszFileName )
	{
		CFileStream* fs = new CFileStream();
#ifdef SCUT_UPHONE
		if (fs->Open(lpszFileName, PO_CREAT | PO_RDWR | PO_BINARY, PS_IREAD | PS_IWRITE) == 0)
		{
			this->SaveTo(fs);
			delete fs;
		}
#else
		if (fs->Open(lpszFileName, 0, 0, "wb+") == 0)
		{
			this->SaveTo(fs);
			delete fs;
		}
#endif
	}
Exemplo n.º 22
0
bool CPlayList::Load(const std::string& strFileName)
{
  Clear();
  m_strBasePath = URIUtils::GetDirectory(strFileName);

  CFileStream file;
  if (!file.Open(strFileName))
    return false;

  if (file.GetLength() > 1024*1024)
  {
    CLog::Log(LOGWARNING, "%s - File is larger than 1 MB, most likely not a playlist", __FUNCTION__);
    return false;
  }

  return LoadData(file);
}
Exemplo n.º 23
0
TiXmlElement *CSmartPlaylist::OpenAndReadName(const CStdString &path)
{
  CFileStream file;
  if (!file.Open(path))
  {
    CLog::Log(LOGERROR, "Error loading Smart playlist %s (failed to read file)", path.c_str());
    return NULL;
  }

  m_xmlDoc.Clear();
  file >> m_xmlDoc;

  if (m_xmlDoc.Error())
  {
    CLog::Log(LOGERROR, "Error loading Smart playlist (failed to parse xml: %s)", m_xmlDoc.ErrorDesc());
    return NULL;
  }

  TiXmlElement *root = m_xmlDoc.RootElement();
  if (!root || strcmpi(root->Value(),"smartplaylist") != 0)
  {
    CLog::Log(LOGERROR, "Error loading Smart playlist %s", path.c_str());
    return NULL;
  }
  // load the playlist type
  const char* type = root->Attribute("type");
  if (type)
    m_playlistType = type;
  // backward compatibility:
  if (m_playlistType == "music")
    m_playlistType = "songs";
  if (m_playlistType == "video")
    m_playlistType = "musicvideos";

  // load the playlist name
  TiXmlHandle name = ((TiXmlHandle)root->FirstChild("name")).FirstChild();
  if (name.Node())
    m_playlistName = name.Node()->Value();
  else
  {
    m_playlistName = CUtil::GetTitleFromPath(path);
    if (URIUtils::GetExtension(m_playlistName) == ".xsp")
      URIUtils::RemoveExtension(m_playlistName);
  }
  return root;
}
Exemplo n.º 24
0
HRESULT CPkcs7::SaveIntoJavaClassFile(FILEHANDLE hFile,LPCOLESTR wszFileName,BOOL fClearDirty)
// Save this signed data (presumably already signed) into the right place in the class file
	{
	HRESULT hr = S_OK;
	CFileStream stm;
	if (stm.OpenFileForWriting(hFile, wszFileName, FALSE))
		{
		IPersistStream* pPerStream;
		hr = CJavaClassFile::CreateInstance(NULL, IID_IPersistStream, (LPVOID*)&pPerStream);
		if (hr == S_OK)
			{
			hr = pPerStream->Load(&stm);						// load the class file
			if (hr == S_OK)
				{
				BLOB b;
				hr = CPersistMemoryHelper2::Save(&b, FALSE);	// get our bits
				if (hr == S_OK)
					{
					IInsertSig* pSig;
					hr = pPerStream->QueryInterface(IID_IInsertSig, (LPVOID*)&pSig);
					if (hr == S_OK)
						{
						hr = pSig->SaveSig(&b);					// stuff our bits in
						pSig->Release();
						}
					FreeTaskMem(b);
					}
				if (hr == S_OK)
					{
					stm.Reset();
					stm.Truncate();
					hr = pPerStream->Save(&stm, FALSE);			// save the class file
					}
				}
			pPerStream->Release();
			}
		}
	else
		hr = HError();

	if (hr == S_OK && fClearDirty)
		m_isDirty = FALSE;

	return hr;
	}
Exemplo n.º 25
0
bool CStoryConfig::Load(CFileStream&file)
{
    file.ReadUInt( m_nStoryID );

    unsigned short nNPCListCount = 0;
    file.ReadUShort( nNPCListCount );
    for ( unsigned int i  = 0 ;i <  nNPCListCount; ++i )
    {
        unsigned int nNPCID = 0;
        file.ReadUInt( nNPCID );
        m_NPCList.push_back( nNPCID );
    }

    unsigned short nContentCount = 0;
    file.ReadUShort( nContentCount );
    for ( unsigned int i  = 0 ;i <  nContentCount; ++i )
    {
        CStoryContent content;
        file.ReadUInt( content.m_nNPCID );

        short nCount = 0;
        file.ReadShort(nCount) ;
        file.ReadString(content.m_strContent, nCount);

        m_ContentList.push_back( content );
    }

    return true;
}
Exemplo n.º 26
0
int ExtractThread(EXTRACT_THREAD_VIDEO_DATA*	lpETD)
{
	lpETD->dlg->SetDialogState_Muxing();
	lpETD->dlg->ButtonState_START();

	lpETD->dlg->AddProtocolLine("started extracting binary", 4);

	VIDEOSOURCE* v = lpETD->v;
	v->Enable(1);
	CFileStream* f = lpETD->file;
	char cTime[20];
	char* lpBuffer = new char[2<<20];
	int iLastTime = GetTickCount();
	v->ReInit();

	while (!v->IsEndOfStream() && !DoStop()) {
		__int64 iTimecode;
		__int64 iNS = 0;
		DWORD dwSize;
		v->GetFrame(lpBuffer,&dwSize,&iTimecode);
		f->Write(lpBuffer,dwSize);
		if (GetTickCount()-iLastTime>100 || v->IsEndOfStream()) {
			Millisec2Str((iTimecode * v->GetTimecodeScale() + iNS)/ 1000000,cTime);
			
			CUTF8 utf8Time(cTime);
			lpETD->dlg->m_Prg_Frames.SetWindowText(utf8Time.TStr());
			iLastTime+=100;
		}
	}

	lpETD->dlg->SetDialogState_Config();
	lpETD->dlg->ButtonState_STOP();
	delete lpBuffer;
	StopMuxing(false);
	lpETD->file->Close();
	lpETD->dlg->AddProtocol_Separator();
	delete lpETD;

	v->Enable(0);

	return 1;
}
Exemplo n.º 27
0
void CMedalCfgMgr::LoadProgressConfigFromFile( CFileStream &rFileStream )
{
    if ( !rFileStream.IsOpen() )
        return;

    m_mapMedalProgressCfg.clear();

    unsigned short nCount = 0;
    rFileStream.ReadUShort( nCount );

    for ( unsigned short i = 0; i < nCount; ++i )
    {
        CMedalProgressCfg processInfo;

        if ( processInfo.LoadInfoFromFile( rFileStream ) )
        {
            m_mapMedalProgressCfg.insert( std::make_pair( processInfo.GetId(), processInfo ) );
        }
    }
}
Exemplo n.º 28
0
bool CShader::AppendSource(const std::string& filename)
{
  if(filename.empty())
    return true;

  CFileStream file;
  std::string temp;

  std::string path = "special://xbmc/system/shaders/";
  path += CServiceBroker::GetRenderSystem()->GetShaderPath(filename);
  path += filename;
  if(!file.Open(path))
  {
    CLog::Log(LOGERROR, "CShader::AppendSource - failed to open file %s", filename.c_str());
    return false;
  }
  getline(file, temp, '\0');
  m_source.append(temp);
  return true;
}
Exemplo n.º 29
0
DWORD CDataServer::LoadFileToBuffer(const nString& FileName, char*& Buffer)
{
	CFileStream File;

	int BytesRead;

	if (File.Open(FileName, SAM_READ, SAP_SEQUENTIAL))
	{
		int FileSize = File.GetSize();
		Buffer = (char*)n_malloc(FileSize);
		BytesRead = File.Read(Buffer, FileSize);
		File.Close();
	}
	else
	{
		Buffer = NULL;
		BytesRead = 0;
	}

	return BytesRead;
}
Exemplo n.º 30
0
PParams CDataServer::ReloadPRM(const nString& FileName, bool Cache)
{
	CFileStream File;
	if (!File.Open(FileName, SAM_READ)) return NULL;
	CBinaryReader Reader(File);

	PParams Params;
	Params.Create();
	if (Reader.ReadParams(*Params))
	{
		if (Cache) HRDCache.Add(FileName.Get(), Params); //!!!???mangle path to avoid duplicates?
		n_printf("FileIO: PRM \"%s\" successfully loaded from HDD\n", FileName.Get());
	}
	else
	{
		Params = NULL;
		n_printf("FileIO: PRM loading from \"%s\" failed\n", FileName.Get());
	}

	return Params;
}