本文整理汇总了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";
}
示例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";
}
示例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;
}