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


C++ FileInputStream类代码示例

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


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

示例1: YUVPixelDataGenerator

bool YUVPixelDataGenerator (uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride) {
#define SRC_FRAME_WIDTH (160)
#define SRC_FRAME_HEIGHT (96)

  if (SRC_FRAME_WIDTH - iWidth <= 0 || SRC_FRAME_HEIGHT - iHeight <= 0) {
    return false;
  }

  const int32_t kiFrameSize = SRC_FRAME_WIDTH * SRC_FRAME_HEIGHT;
  BufferedData sBuf;
  sBuf.SetLength (kiFrameSize);
  if (sBuf.Length() != (size_t)kiFrameSize) {
    return false;
  }

  FileInputStream fileStream;
  if (!fileStream.Open ("res/CiscoVT2people_160x96_6fps.yuv")) {
    return false;
  }
  if (fileStream.read (sBuf.data(), kiFrameSize) == kiFrameSize) {
    int32_t iStartPosX = rand() % (SRC_FRAME_WIDTH - iWidth);
    int32_t iStartPosY = rand() % (SRC_FRAME_HEIGHT - iHeight);
    uint8_t* pSrcPointer = sBuf.data() + iStartPosX + iStartPosY * SRC_FRAME_WIDTH;
    uint8_t* pLocalPointer = pPointer;

    for (int j = 0; j < iHeight; j++) {
      memcpy (pLocalPointer, pSrcPointer, iWidth * sizeof (uint8_t));
      pLocalPointer += iStride;
      pSrcPointer += SRC_FRAME_WIDTH;
    }
    return true;
  }
  return false;
}
开发者ID:EaSonic,项目名称:openh264,代码行数:34,代码来源:DataGenerator.cpp

示例2: resolveXDGFolder

//==============================================================================
static File resolveXDGFolder (const char* const type, const char* const fallbackFolder)
{
    File userDirs ("~/.config/user-dirs.dirs");
    StringArray confLines;

    if (userDirs.existsAsFile())
    {
        FileInputStream in (userDirs);

        if (in.openedOk())
            confLines.addLines (in.readEntireStreamAsString());
    }

    for (int i = 0; i < confLines.size(); ++i)
    {
        const String line (confLines[i].trimStart());

        if (line.startsWith (type))
        {
            // eg. resolve XDG_MUSIC_DIR="$HOME/Music" to /home/user/Music
            const File f (line.replace ("$HOME", File ("~").getFullPathName())
                          .fromFirstOccurrenceOf ("=", false, false)
                          .trim().unquoted());

            if (f.isDirectory())
                return f;
        }
    }

    return File (fallbackFolder);
}
开发者ID:alexandrev,项目名称:rippled,代码行数:32,代码来源:linux_Files.cpp

示例3: TEST

TEST(TestCommand, testShownamespacesCommand) {
	cout << "testShownamespacesCommand" << endl;
	FileOutputStream* fos = new FileOutputStream("test.dat", "wb");

	CommandWriter* writer = new CommandWriter(fos);
	ShownamespacesCommand cmd;
	cmd.setDB("testdb");
	writer->writeCommand(&cmd);

	fos->close();
	delete fos;
	delete writer;

	FileInputStream* fis = new FileInputStream("test.dat", "rb");
	CommandReader* reader = new CommandReader(fis);

	Command* resCmd = reader->readCommand();
	EXPECT_TRUE(resCmd->commandType() == SHOWNAMESPACES);
	ShownamespacesCommand* sw = (ShownamespacesCommand*)resCmd;
	EXPECT_TRUE(sw->DB()->compare("testdb") == 0);

	fis->close();

	delete resCmd;
	delete fis;
	delete reader;
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:27,代码来源:main.cpp

示例4: LoadTGAForRes

void CImageLabel::LoadImage(const char * pImageName)
{
	if ( m_pTGA )
		delete m_pTGA;

	// Load the Image
	m_pTGA = LoadTGAForRes(pImageName);

	if ( m_pTGA == NULL )
	{
		// we didn't find a matching image file for this resolution
		// try to load file resolution independent

		char sz[256];
		sprintf(sz, "%s/%s",gEngfuncs.pfnGetGameDirectory(), pImageName );
		FileInputStream* fis = new FileInputStream( sz, false );
		m_pTGA = new BitmapTGA(fis,true);
		fis->close();
	}

	if ( m_pTGA == NULL )
		return;	// unable to load image
	 	
	int w,t;

	m_pTGA->getSize( w, t );

	setSize( XRES (w),YRES (t) );
	setImage( m_pTGA );
}
开发者ID:Hammermaps-DEV,项目名称:Spirit-of-Half-Life-1.8--VC2010,代码行数:30,代码来源:vgui_CustomObjects.cpp

示例5: fin

// protected
void 
FileInputStreamTestCase::getFileName (void)
{
	FileInputStream fin (TEST_FILE_NAME);
	CPPUNIT_ASSERT (fin.getFileName () == String (TEST_FILE_NAME));
	
	fin.close ();
}
开发者ID:hanxin1987216,项目名称:DTL,代码行数:9,代码来源:fileinputtc.cpp

示例6: fin

MD5::MD5 (const File& file)
{
    FileInputStream fin (file);

    if (fin.getStatus().wasOk())
        processStream (fin, -1);
    else
        zerostruct (result);
}
开发者ID:randi2kewl,项目名称:ShoutOut,代码行数:9,代码来源:juce_MD5.cpp

示例7: in

OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const File& fileToRead)
{
    FileInputStream in (fileToRead);

    if (in.openedOk())
        return stream << in;

    return stream;
}
开发者ID:Frongo,项目名称:JUCE,代码行数:9,代码来源:juce_OutputStream.cpp

示例8: ReadAllText

HRESULT CFileHelper::ReadAllText(LPCTSTR path, String & text)
{
	FileInputStream ifs;

	ifs.imbue(locale("chs"));

	ifs.open(path,ifs.in);

	if(!ifs.is_open()) return E_FAIL;

	ifs.seekg(0,ifs.end);

	int size=ifs.tellg();

	ifs.seekg(0);	

	TCHAR * s=(TCHAR *)malloc(sizeof(TCHAR) * (size+1));

	memset(s,0,sizeof(TCHAR)*(size+1));

	ifs._Read_s(s,size ,sizeof(TCHAR) * size);

	ifs.close();

	text = s;

	free(s);

	return S_OK;
}
开发者ID:bestustc,项目名称:MyTutorial,代码行数:30,代码来源:FileHelper.cpp

示例9: stream

Image ImageFileFormat::loadFrom (const File& file)
{
    FileInputStream stream (file);

    if (stream.openedOk())
    {
        BufferedInputStream b (stream, 8192);
        return loadFrom (b);
    }

    return Image::null;
}
开发者ID:AGenews,项目名称:GUI,代码行数:12,代码来源:juce_ImageFileFormat.cpp

示例10: headerGuard

Result ResourceFile::writeHeader (MemoryOutputStream& header)
{
    const String headerGuard ("BINARYDATA_H_" + String (project.getProjectUID().hashCode() & 0x7ffffff) + "_INCLUDED");

    header << "/* ========================================================================================="
           << getComment()
           << "#ifndef " << headerGuard << newLine
           << "#define " << headerGuard << newLine
           << newLine
           << "namespace " << className << newLine
           << "{" << newLine;

    bool containsAnyImages = false;

    for (int i = 0; i < files.size(); ++i)
    {
        const File& file = files.getReference(i);

        if (! file.existsAsFile())
            return Result::fail ("Can't open resource file: " + file.getFullPathName());

        const int64 dataSize = file.getSize();

        const String variableName (variableNames[i]);

        FileInputStream fileStream (file);

        if (fileStream.openedOk())
        {
            containsAnyImages = containsAnyImages
                                 || (ImageFileFormat::findImageFormatForStream (fileStream) != nullptr);

            header << "    extern const char*   " << variableName << ";" << newLine;
            header << "    const int            " << variableName << "Size = " << (int) dataSize << ";" << newLine << newLine;
        }
    }

    header << "    // Points to the start of a list of resource names." << newLine
           << "    extern const char* namedResourceList[];" << newLine
           << newLine
           << "    // Number of elements in the namedResourceList array." << newLine
           << "    const int namedResourceListSize = " << files.size() <<  ";" << newLine
           << newLine
           << "    // If you provide the name of one of the binary resource variables above, this function will" << newLine
           << "    // return the corresponding data and its size (or a null pointer if the name isn't found)." << newLine
           << "    const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw();" << newLine
           << "}" << newLine
           << newLine
           << "#endif" << newLine;

    return Result::ok();
}
开发者ID:gmhendler,项目名称:PluginDev,代码行数:52,代码来源:jucer_ResourceFile.cpp

示例11: file

std::istream* FileStreamFactory::open(const Path& path)
{
	File file(path);
	if (!file.exists()) throw FileNotFoundException(path.toString());
	
	FileInputStream* istr = new FileInputStream(path.toString(), std::ios::binary);
	if (!istr->good())
	{
		delete istr;
		throw OpenFileException(path.toString());
	}	
	return istr;
}
开发者ID:12307,项目名称:poco,代码行数:13,代码来源:FileStreamFactory.cpp

示例12: TEST

TEST(testIndexP, testRecoverNames) {
	Logger* log = getLogger(NULL);
	std::set<std::string> keys;
	keys.insert("_id");

	BPlusIndexP* index = new BPlusIndexP("testIndexNames");
	index->setKeys(keys);

	FileInputStream* fis = new FileInputStream("names.txt", "r");

	cout << "Adding names to the index" << endl;
	std::vector<std::string> names;
	int x = 0;
	while (true) {
		if (fis->eof()) {
			cout << "No more names" << endl;
			break;
		}
		if (x >= 100) {
			break;
		}
		x++;
		BSONObj o;
		std::string* name = fis->readString();
		o.add("_id", name->c_str());
		char* temp = strcpy(const_cast<char*>(name->c_str()), name->length());
		index->add(o, djondb::string(temp, name->length()), 100);
		index->debug();
		if (log->isDebug()) log->debug("===============================================================================");
		names.push_back(*name);
		delete name;
	}

	index->debug();
	delete index;
	cout << "Finding names from the index" << endl;

	index = new BPlusIndexP("testIndexNames");
	index->setKeys(keys);
	index->debug();
	for (std::vector<std::string>::iterator i = names.begin(); i != names.end(); i++) {
		std::string name = *i;
		BSONObj o;
		o.add("_id", name.c_str());
		Index* idx = index->find(&o);
		ASSERT_TRUE(idx != NULL) << "_id " << name.c_str() << " not found";
		ASSERT_TRUE(idx->key->has("_id")) << "Retrieved index for _id " << name.c_str() << " does not returned the _id";
		EXPECT_TRUE(idx->key->getString("_id").compare(name) == 0) << "Recovered a wrong key, expected: " << name.c_str() << " and retrived: " << idx->key->getString("_id").c_str();
	}
	delete index;
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:51,代码来源:testIndexP.cpp

示例13: sprintf

//-----------------------------------------------------------------------------
// Purpose: Loads a .tga file and returns a pointer to the VGUI tga object
//-----------------------------------------------------------------------------
BitmapTGA *LoadTGA( const char* pImageName )
{
	BitmapTGA	*pTGA;

	char sz[256];
	sprintf(sz, "%%d_%s", pImageName);

	// Load the Image
	FileInputStream* fis = new FileInputStream( GetVGUITGAName(sz), false );
	pTGA = new BitmapTGA(fis,true);
	fis->close();

	return pTGA;
}
开发者ID:Skumek,项目名称:hlsdk,代码行数:17,代码来源:vgui_CustomObjects.cpp

示例14: open

bool WavStream::open(const char *file_name)
{
   FileInputStream *in;

   this->close();

   in = new FileInputStream;
   if (!in->open(file_name) || !this->open(in))
   {
      delete in;
      return false;
   }

   return true;
}
开发者ID:112212,项目名称:7k2,代码行数:15,代码来源:wav_stream.cpp

示例15: jojo_read

void jojo_read (t_jojo *x, const File& aFile)
{
    FileInputStream zipped (aFile);
    
    if (zipped.openedOk()) {
    //
    GZIPDecompressorInputStream unzipper (&zipped, false);
    StringArray myText (StringArray::fromLines (unzipper.readEntireStreamAsString()));
    
    for (int i = 0; i < myText.size(); ++i) {
        post ("%s", myText.getReference (i).toRawUTF8());
    }
    //
    }
}
开发者ID:frantic0,项目名称:Jojo,代码行数:15,代码来源:jojoZip.cpp


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