本文整理汇总了C++中Disk::ToBlockRun方法的典型用法代码示例。如果您正苦于以下问题:C++ Disk::ToBlockRun方法的具体用法?C++ Disk::ToBlockRun怎么用?C++ Disk::ToBlockRun使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Disk
的用法示例。
在下文中一共展示了Disk::ToBlockRun方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
block_run
parseBlockRun(Disk &disk, char *first, char *last)
{
char *comma;
if (last) {
return block_run::Run(atol(first), atol(last), 1);
} else if ((comma = strchr(first, ',')) != NULL) {
*comma++ = '\0';
return block_run::Run(atol(first), atol(comma));
}
return disk.ToBlockRun(atoll(first));
}
示例2: at
void
checkIndexForNonExistingFiles(Disk &disk,BPlusTree &tree)
{
char name[B_FILE_NAME_LENGTH];
uint16 length;
off_t offset;
while (tree.GetNextEntry(name,&length,B_FILE_NAME_LENGTH,&offset) == B_OK)
{
name[length] = 0;
block_run run = disk.ToBlockRun(offset);
if (!gHashtable.Contains(&run))
{
printf(" inode at (%ld, %d), offset %Ld, doesn't exist!",run.allocation_group,run.start,offset);
switch (tree.Type())
{
case BPLUSTREE_STRING_TYPE:
printf(" (string = \"%s\")",name);
break;
case BPLUSTREE_INT32_TYPE:
printf(" (int32 = %ld)",*(int32 *)&name);
break;
case BPLUSTREE_UINT32_TYPE:
printf(" (uint32 = %lu)",*(uint32 *)&name);
break;
case BPLUSTREE_INT64_TYPE:
printf(" (int64 = %Ld)",*(int64 *)&name);
break;
case BPLUSTREE_UINT64_TYPE:
printf(" (uint64 = %Lu)",*(uint64 *)&name);
break;
case BPLUSTREE_FLOAT_TYPE:
printf(" (float = %g)",*(float *)&name);
break;
case BPLUSTREE_DOUBLE_TYPE:
printf(" (double = %g)",*(double *)&name);
break;
}
putchar('\n');
}
}
}
示例3: if
//.........这里部分代码省略.........
while (inode->GetNextAttribute(name,&type,&data,&length) == B_OK)
{
if (!strcmp(name,attribute))
{
strncpy(key,(char *)data,B_FILE_NAME_LENGTH - 1);
key[B_FILE_NAME_LENGTH - 1] = '\0';
keyLength = length > B_FILE_NAME_LENGTH ? B_FILE_NAME_LENGTH : length;
found = true;
break;
}
}
if (!found)
continue;
}
off_t value;
if (tree.Find((uint8 *)key,keyLength,&value) < B_OK)
{
if (*inode->Name())
fprintf(stderr," inode at (%ld, %d) name \"%s\" is not in index!\n",runs[i].allocation_group,runs[i].start,inode->Name());
else
{
// inode is obviously deleted!
block_run parent = inode->Parent();
Directory *directory = (Directory *)Inode::Factory(&disk,parent);
if (directory != NULL && directory->InitCheck() == B_OK)
{
BPlusTree *parentTree;
if (directory->GetTree(&parentTree) == B_OK)
{
char name[B_FILE_NAME_LENGTH];
uint16 length;
off_t offset,searchOffset = disk.ToBlock(runs[i]);
bool found = false;
while (parentTree->GetNextEntry(name,&length,B_FILE_NAME_LENGTH,&offset) == B_OK)
{
if (offset == searchOffset)
{
fprintf(stderr," inode at (%ld, %d) name \"%s\" was obviously deleted, but the parent \"%s\" still contains it!\n",runs[i].allocation_group,runs[i].start,name,directory->Name());
found = true;
break;
}
}
if (!found)
fprintf(stderr," inode at (%ld, %d) was obviously deleted, and the parent \"%s\" obviously doesn't contain it anymore!\n",runs[i].allocation_group,runs[i].start,directory->Name());
}
else
fprintf(stderr," inode at (%ld, %d) was obviously deleted, but the parent \"%s\" is invalid and still contains it!\n",runs[i].allocation_group,runs[i].start,directory->Name());
}
else
{
// not that this would be really possible... - but who knows
fprintf(stderr," inode at (%ld, %d) is not in index and has invalid parent!\n",runs[i].allocation_group,runs[i].start);
}
delete directory;
}
}
else
{
if (bplustree_node::LinkType(value) == BPLUSTREE_NODE)
{
if (disk.ToBlockRun(value) != runs[i])
fprintf(stderr," offset in index and inode offset doesn't match for inode \"%s\" at (%ld, %d)\n",inode->Name(),runs[i].allocation_group,runs[i].start);
}
else
{
// search duplicates
char name[B_FILE_NAME_LENGTH];
uint16 length;
off_t offset;
bool found = false,duplicates = false;
//puts("++");
tree.Rewind();
while (tree.GetNextEntry(name,&length,B_FILE_NAME_LENGTH,&offset) == B_OK)
{
//printf("search for = %ld, key = %ld -> value = %Ld (%ld, %d)\n",*(int32 *)&key,*(int32 *)&name,offset,disk.ToBlockRun(offset).allocation_group,disk.ToBlockRun(offset).start);
if (keyLength == length && !memcmp(key,name,keyLength))
{
duplicates = true;
if (disk.ToBlockRun(offset) == runs[i])
{
found = true;
break;
}
}
//else if (duplicates)
// break;
}
if (!found)
{
printf(" inode \"%s\" at (%ld, %d) not found in duplicates!\n",inode->Name(),runs[i].allocation_group,runs[i].start);
// return;
}
}
}
}
delete inode;
printf(" %7Ld files processed.\n",gCount);
}