本文整理汇总了C++中arguments::at方法的典型用法代码示例。如果您正苦于以下问题:C++ arguments::at方法的具体用法?C++ arguments::at怎么用?C++ arguments::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arguments
的用法示例。
在下文中一共展示了arguments::at方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFile
void FileSystem::createFile(arguments str, outputStream out)
{
checkArgumentsCount(str, 2);
std::ofstream::pos_type size = std::stoll(str.at(1)); // 1234asd321 -> 1234, its ok?
if(_fsFile->create(str.at(0), size)) {
out << "File created";
} else {
out << "file not created";
}
out << "\n";
}
示例2: filestat
void FileSystem::filestat(arguments arg, outputStream out)
{
checkArgumentsCount(arg, 1);
uint64_t descriptorId = std::stoll(arg.at(0));
FSDescriptor descriptor;
try {
descriptor = _descriptors.getDescriptor(descriptorId);
} catch(const std::invalid_argument &) {
out << "Bad descriptor\n";
return;
}
if(descriptor.type == DescriptorVariant::None) {
out << "Descriptor does not exist\n";
return;
}
using std::to_string;
out << "File statistic: \n\tid: " << descriptorId;
if(descriptor.type == DescriptorVariant::File) {
out << descriptor.fileSize;
}
out << "\n\tType: " << to_string(descriptor.type) <<
"\n\tReferences: " << descriptor.referencesCount <<
"\n\tHas extended blocks: " << (descriptor.nextDataSegment == Constants::HEADER_ADDRESS() ? "false" : "true") << "\n";
}
示例3: create
void FileSystem::create(arguments arg)
{
checkArgumentsCount(arg, 1);
FSDescriptor fileDescriptor;
fileDescriptor.initFile();
allocAndAppendDescriptorToCurrentFolder(fileDescriptor, arg.at(0));
}
示例4: cd
void FileSystem::cd(arguments arg)
{
checkArgumentsCount(arg, 1);
_currentFolder = getLastPathElementHandle(arg.at(0))
.descriptorHandle();
// auto v = p.getParsedPath();
}
示例5: mkdir
void FileSystem::mkdir(arguments arg)
{
checkArgumentsCount(arg, 1);
FSDescriptor fileDescriptor;
fileDescriptor.initDirectory(currentDirectory());
string name = arg.at(0);
allocAndAppendDescriptorToCurrentFolder(fileDescriptor, name);
}
示例6: mount
void FileSystem::mount(arguments str)
{
checkArgumentsCount(str, 1);
_fsFile->open(str.at(0));
if(_fsFile->isFormatedFS()) {
fileFormatChanged();
} else {
}
}
示例7: rmdir
void FileSystem::rmdir(arguments arg, outputStream out)
{
checkArgumentsCount(arg, 1);
string name = arg.at(0);
if(removeDescriptorFromDirectory(currentDirectory(), DescriptorVariant::Directory, name)) {
out << "Directory deleted\n";
} else {
out << "Directory not found\n";
}
}
示例8: unlink
void FileSystem::unlink(arguments arg, outputStream out)
{
checkArgumentsCount(arg, 1);
string name = arg.at(0);
descriptorIndex_tp dir = currentDirectory();
if(removeDescriptorFromDirectory(dir, DescriptorVariant::File | DescriptorVariant::SymLink, name)) {
out << "Descriptor deleted\n";
} else {
out << "Descriptor not found\n";
}
}
示例9: close
void FileSystem::close(arguments arg)
{
checkArgumentsCount(arg, 1);
uint64_t openedDescriptor = std::stoull(arg.at(1));
auto findResult = _opennedFiles.find(openedDescriptor);
if(findResult == _opennedFiles.end()) {
throw file_system_exception("Descriptor currently not open.");
} else {
_opennedFiles.erase(findResult);
}
}
示例10: link
void FileSystem::link(arguments arg)
{
checkArgumentsCount(arg, 2);
string srcName = arg.at(0);
string destName = arg.at(1);
descriptorIndex_tp destDir = currentDirectory();
descriptorIndex_tp srcDir = currentDirectory();
auto it = getDirectoryDescriptorIterator(srcDir);
while(it.hasNext()) {
++it;
if(it->name(header().filenameLength) == srcName) {
addDescriptorToDirectory(destDir, it->descriptor, destName);
}
}
}