Lines Matching refs:file

8 	\file ResourceFile.cpp
44 // recognized file types (indices into kFileTypeNames)
57 "x86 resource file",
58 "PPC resource file",
59 "ELF object file",
60 "PEF object file",
61 "empty file",
78 read_exactly(BPositionIO& file, off_t position, void* buffer, size_t size,
81 ssize_t read = file.ReadAt(position, buffer, size);
95 write_exactly(BPositionIO& file, off_t position, const void* buffer,
98 ssize_t written = file.WriteAt(position, buffer, size);
240 ResourceFile::SetTo(BFile* file, bool clobber)
242 status_t error = (file ? B_OK : B_BAD_VALUE);
246 _InitFile(*file, clobber);
290 // get the file size
293 throw Exception(error, "Failed to get the file size.");
378 ResourceFile::_InitFile(BFile& file, bool clobber)
382 // get the file size first
384 error = file.GetSize(&fileSize);
386 throw Exception(error, "Failed to get the file size.");
387 // read the first four bytes, and check, if they identify a resource file
390 read_exactly(file, 0, magic, 4, "Failed to read magic number.");
392 throw Exception(B_IO_ERROR, "File is not a resource file.");
394 // empty file
397 fFile.SetTo(&file, 0);
400 // x86 resource file
403 fFile.SetTo(&file, kX86ResourcesOffset);
407 read_exactly(file, 0, &pefHeader, kPEFContainerHeaderSize,
410 // PPC resource file
413 fFile.SetTo(&file, kPPCResourcesOffset);
416 // PEF file
418 _InitPEFFile(file, pefHeader);
420 throw Exception(B_IO_ERROR, "File is not a resource file.");
422 // ELF file
424 _InitELFFile(file);
426 // x86 resource file with screwed magic?
428 // "for x86 resource file. Try anyway.",
433 fFile.SetTo(&file, kX86ResourcesOffset);
437 // make it an x86 resource file
440 fFile.SetTo(&file, 0);
442 throw Exception(B_IO_ERROR, "File is not a resource file.");
446 throw Exception(error, "Failed to initialize resource file.");
457 ResourceFile::_InitELFFile(BFile& file)
461 // get the file size
463 error = file.GetSize(&fileSize);
465 throw Exception(error, "Failed to get the file size.");
469 read_exactly(file, 0, identification, EI_NIDENT,
492 _InitELFXFile<Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr>(file, fileSize);
495 _InitELFXFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr>(file, fileSize);
506 ResourceFile::_InitELFXFile(BFile& file, uint64 fileSize)
510 read_exactly(file, 0, &fileHeader, sizeof(ElfHeader),
546 "table exceeds file: %lu.",
559 read_exactly(file, programHeaderTableOffset, programHeaders,
584 "segment exceeds file: %lu.", segmentEnd);
604 "table exceeds file: %lu.",
617 read_exactly(file, sectionHeaderTableOffset, sectionHeaders,
633 // SHT_NOBITS sections take no space in the file
642 "section exceeds file: %lu.", sectionEnd);
652 // not necessary to align the position of the resources in the file to
663 throw Exception(B_IO_ERROR, "The ELF object file requires an "
670 // throw Exception("The ELF object file does not contain resources.");
675 // fine, init the offset file
676 fFile.SetTo(&file, resourceOffset);
681 ResourceFile::_InitPEFFile(BFile& file, const PEFContainerHeader& pefHeader)
684 // get the file size
686 error = file.GetSize(&fileSize);
688 throw Exception(error, "Failed to get the file size.");
691 throw Exception(B_IO_ERROR, "PEF file architecture is not PPC.");
703 read_exactly(file, shOffset, &sectionHeader, kPEFSectionHeaderSize,
716 "exceeds file: %" B_PRIu32 ".", sectionEnd);
721 // throw Exception("The PEF object file does not contain resources.");
725 // init the offset file
726 fFile.SetTo(&file, resourceOffset);
1029 " sum: In file: %" B_PRIx32 ", calculated: %" B_PRIx32 ".",
1150 // set the file size
1298 BFile* file = fFile.File();
1299 // make it an x86 resource file
1300 error = file->SetSize(4);
1302 throw Exception(error, "Failed to set file size.");
1303 write_exactly(*file, 0, kX86ResourceFileMagic, 4,
1307 fFile.SetTo(file, kX86ResourcesOffset);