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


C++ Directory::Read方法代码示例

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


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

示例1: read

std::string FileSystem::read(const std::string & saveFile)
{
	int r = mMemblockDevice.LoadFromFile(saveFile);
	if (r == -1)
		return "File not found.\n";
	Directory* temp = new Directory;
	temp->Read(&mMemblockDevice, r);
	if (r == -1)
		return "Error";
	delete mCurrDir;
	mCurrDir = temp;

	system("cls");

	return "State loaded.\n";
}
开发者ID:dastyk,项目名称:FileSystem,代码行数:16,代码来源:filesystem.cpp

示例2: rename

std::string FileSystem::rename(const std::string & source, const std::string & newName)
{
	int r = mCurrDir->GetChildFile(&mMemblockDevice, source);
	if (r != -1)
	{
		File file;
		file.Read(&mMemblockDevice, r);
		file.SetName(&mMemblockDevice, newName);
		return "";
	}

	r = mCurrDir->GetChildDir(&mMemblockDevice, source);
	if (r != -1)
	{
		Directory dir;
		dir.Read(&mMemblockDevice, r);
		dir.SetName(&mMemblockDevice, newName);
		return "";
	}

	return "No such file or directory.\n";
}
开发者ID:dastyk,项目名称:FileSystem,代码行数:22,代码来源:filesystem.cpp

示例3: Read

bool Directory::Read ( istream &input )
{
    // 
    // Start marker

    char marker[DIRECTORY_MARKERSIZE];
    input.read( marker, DIRECTORY_MARKERSIZE );
    if( strncmp( marker, DIRECTORY_MARKERSTART, DIRECTORY_MARKERSIZE ) != 0 )
    {
        return false;
    }

    
    //
    // Our own information

    if ( m_name )
    {
        delete[] m_name;
        m_name = NULL;
    }
	m_name = ReadDynamicString( input, DIRECTORY_MAXSTRINGLENGTH, DIRECTORY_SAFESTRING );
    
    //
    // Our data
    // Indexes are not important and can be forgotten

    int numUsed = ReadPackedInt(input);
    
    if( numUsed < 0 || numUsed > DIRECTORY_MAXDIRSIZE )
    {
        return false;
    }

    for ( int d = 0; d < numUsed; ++d )
    {
        DirectoryData *data = new DirectoryData();        
        if (!data->Read( input )) 
		{
			AppDebugOut("Warning: failed to read directory data from stream\n");
			delete data;
			return false;
		}
        m_data.PutData( data );
    }

       
    // 
    // Our subdirectories

    int numSubdirs = ReadPackedInt( input );

    if( numUsed < 0 || numUsed > DIRECTORY_MAXDIRSIZE )
    {
        return false;
    }
    
    for ( int s = 0; s < numSubdirs; ++s )
    {
        Directory *newDir = new Directory();
        if( !newDir->Read( input ) ) 
		{
			AppDebugOut("Warning failed to read directory from stream\n");
			delete newDir;
			return false;
		}
        m_subDirectories.PutData( newDir );
    }

    //
    // End marker

    input.read( marker, DIRECTORY_MARKERSIZE );
    if( strncmp( marker, DIRECTORY_MARKEREND, DIRECTORY_MARKERSIZE ) != 0 )
    {
        return false;
    }


    return true;
}
开发者ID:gene9,项目名称:Darwinia-and-Multiwinia-Source-Code,代码行数:81,代码来源:directory.cpp


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