本文整理汇总了C++中BVRef类的典型用法代码示例。如果您正苦于以下问题:C++ BVRef类的具体用法?C++ BVRef怎么用?C++ BVRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BVRef类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadFileAtOffset
long ReadFileAtOffset(const char * fileSpec, void *buffer, uint64_t offset, uint64_t length)
{
const char *filePath;
BVRef bvr;
if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL)
return -1;
if (bvr->fs_readfile == NULL)
return -1;
return bvr->fs_readfile(bvr, (char *)filePath, buffer, offset, length);
}
示例2: GetFileBlock
long GetFileBlock(const char *fileSpec, unsigned long long *firstBlock)
{
const char * filePath;
BVRef bvr;
// Resolve the boot volume from the file spec.
if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL) {
printf("Boot volume for '%s' is bogus\n", fileSpec);
return -1;
}
return bvr->fs_getfileblock(bvr, (char *)filePath, firstBlock);
}
示例3: GetFSUUID
long GetFSUUID(char *spec, char *uuidStr)
{
BVRef bvr;
long rval = -1;
const char *devSpec;
if ((bvr = getBootVolumeRef(spec, &devSpec)) == NULL)
return -1;
if(bvr->fs_getuuid)
rval = bvr->fs_getuuid(bvr, uuidStr);
return rval;
}
示例4: LoadThinFatFile
long LoadThinFatFile(const char *fileSpec, void **binary)
{
const char *filePath;
FSReadFile readFile;
BVRef bvr;
unsigned long length, length2;
// Resolve the boot volume from the file spec.
if ((bvr = getBootVolumeRef(fileSpec, &filePath)) == NULL)
return -1;
*binary = (void *)kLoadAddr;
// Read file into load buffer. The data in the load buffer will be
// overwritten by the next LoadFile() call.
gFSLoadAddress = (void *) LOAD_ADDR;
readFile = bvr->fs_readfile;
if (readFile != NULL) {
// Read the first 4096 bytes (fat header)
length = readFile(bvr, (char *)filePath, *binary, 0, 0x1000);
if (length > 0) {
if (ThinFatFile(binary, &length) == 0) {
if (length == 0)
return 0;
// We found a fat binary; read only the thin part
length = readFile(bvr, (char *)filePath,
(void *)kLoadAddr, (unsigned long)(*binary) - kLoadAddr, length);
*binary = (void *)kLoadAddr;
} else {
// Not a fat binary; read the rest of the file
length2 = readFile(bvr, (char *)filePath, (void *)(kLoadAddr + length), length, 0);
if (length2 == -1) return -1;
length += length2;
}
}
} else {
length = bvr->fs_loadfile(bvr, (char *)filePath);
if (length > 0) {
ThinFatFile(binary, &length);
}
}
return length;
}
示例5: open_bvr
static int open_bvr(BVRef bvr, const char *filePath, int flags)
{
struct iob *io;
int fdesc;
int i;
if (bvr == NULL) {
return -1;
}
fdesc = GetFreeFd();
io = &iob[fdesc];
bzero(io, sizeof(*io));
// Mark the descriptor as taken.
io->i_flgs = F_ALLOC;
// Find the next available memory block in the download buffer.
io->i_buf = (char *) LOAD_ADDR;
for (i = 0; i < NFILES; i++) {
if ((iob[i].i_flgs != F_ALLOC) || (i == fdesc)) {
continue;
}
io->i_buf = max(iob[i].i_filesize + iob[i].i_buf, io->i_buf);
}
// Load entire file into memory. Unnecessary open() calls must be avoided.
gFSLoadAddress = io->i_buf;
io->i_filesize = bvr->fs_loadfile(bvr, (char *)filePath);
if (io->i_filesize < 0) {
close(fdesc);
return -1;
}
return fdesc;
}
示例6: getBootVolumeDescription
void getBootVolumeDescription( BVRef bvr, char * str, long strMaxLen, BOOL verbose )
{
unsigned char type = (unsigned char) bvr->part_type;
const char * name = getNameForValue( fdiskTypes, type );
char *p;
if (name == NULL)
name = bvr->type_name;
p = str;
if ( name && verbose ) {
sprintf( str, "hd(%d,%d) ",
BIOS_DEV_UNIT(bvr), bvr->part_no);
for (; strMaxLen > 0 && *p != '\0'; p++, strMaxLen--);
} else {
*p = '\0';
}
bvr->description(bvr, p, strMaxLen);
if (*p == '\0') {
const char * name = getNameForValue( fdiskTypes, type );
if (name == NULL) {
name = bvr->type_name;
}
if (name == NULL) {
sprintf(p, "TYPE %02x", type);
} else {
strncpy(p, name, strMaxLen);
}
}
}
示例7: GetDirEntry
long GetDirEntry(const char * dirSpec, long * dirIndex, const char ** name,
long * flags, long * time)
{
const char * dirPath;
BVRef bvr;
// Resolve the boot volume from the dir spec.
if ((bvr = getBootVolumeRef(dirSpec, &dirPath)) == NULL)
return -1;
// Return 0 on success, or -1 if there are no additional entries.
return bvr->fs_getdirentry( bvr,
/* dirPath */ (char *)dirPath,
/* dirIndex */ dirIndex,
/* dirEntry */ (char **)name, flags, time, 0, 0 );
}
示例8: LoadVolumeFile
long LoadVolumeFile(BVRef bvr, const char *filePath)
{
long fileSize;
// Read file into load buffer. The data in the load buffer will be
// overwritten by the next LoadFile() call.
gFSLoadAddress = (void *) LOAD_ADDR;
fileSize = bvr->fs_loadfile(bvr, (char *)filePath);
// Return the size of the file, or -1 if load failed.
return fileSize;
}