Lines Matching defs:file

8 	\file ResourceFile.cpp
46 // recognized file types (indices into kFileTypeNames)
60 "x86 resource file",
61 "PPC resource file",
62 "ELF object file",
63 "FatELF object file",
64 "PEF object file",
65 "empty file",
79 read_exactly(BPositionIO& file, off_t position, void* buffer, size_t size,
82 ssize_t read = file.ReadAt(position, buffer, size);
96 write_exactly(BPositionIO& file, off_t position, const void* buffer,
99 ssize_t written = file.WriteAt(position, buffer, size);
241 ResourceFile::SetTo(BFile* file, bool clobber)
243 status_t error = (file ? B_OK : B_BAD_VALUE);
247 _InitFile(*file, clobber);
291 // get the file size
294 throw Exception(error, "Failed to get the file size.");
372 ResourceFile::_InitFile(BFile& file, bool clobber)
376 // get the file size first
378 error = file.GetSize(&fileSize);
380 throw Exception(error, "Failed to get the file size.");
381 // read the first four bytes, and check, if they identify a resource file
384 read_exactly(file, 0, &magic, 4, "Failed to read magic number.");
386 throw Exception(B_IO_ERROR, "File is not a resource file.");
388 // empty file
391 fFile.SetTo(&file, 0);
394 // x86 resource file
397 fFile.SetTo(&file, kX86ResourcesOffset);
401 read_exactly(file, 0, &pefHeader, kPEFContainerHeaderSize,
404 // PPC resource file
407 fFile.SetTo(&file, kPPCResourcesOffset);
410 // PEF file
412 _InitPEFFile(file, pefHeader);
414 throw Exception(B_IO_ERROR, "File is not a resource file.");
416 // ELF file
418 _InitELFFile(file);
421 _InitFatELFFile(file);
423 // x86 resource file with screwed magic?
425 // "for x86 resource file. Try anyway.",
430 fFile.SetTo(&file, kX86ResourcesOffset);
434 // make it an x86 resource file
437 fFile.SetTo(&file, 0);
439 throw Exception(B_IO_ERROR, "File is not a resource file.");
443 throw Exception(error, "Failed to initialize resource file.");
454 ResourceFile::_InitELFFile(BFile& file)
458 // get the file size
460 error = file.GetSize(&fileSize);
462 throw Exception(error, "Failed to get the file size.");
466 read_exactly(file, 0, identification, EI_NIDENT,
489 _InitELFXFile<Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr>(file, fileSize);
492 _InitELFXFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr>(file, fileSize);
503 ResourceFile::_InitELFXFile(BFile& file, uint64 fileSize)
507 read_exactly(file, 0, &fileHeader, sizeof(ElfHeader),
542 "table exceeds file: %lu.",
555 read_exactly(file, programHeaderTableOffset, programHeaders,
580 "segment exceeds file: %lu.", segmentEnd);
600 "table exceeds file: %lu.",
613 read_exactly(file, sectionHeaderTableOffset, sectionHeaders,
629 // SHT_NOBITS sections take no space in the file
638 "section exceeds file: %lu.", sectionEnd);
648 // not necessary to align the position of the resources in the file to
659 throw Exception(B_IO_ERROR, "The ELF object file requires an "
666 // throw Exception("The ELF object file does not contain resources.");
671 // fine, init the offset file
672 fFile.SetTo(&file, resourceOffset);
677 ResourceFile::_InitFatELFFile(BFile& file)
679 // get the file size
681 status_t error = file.GetSize(&fileSize);
683 throw Exception(error, "Failed to get the file size.");
687 read_exactly(file, 0, &fileHeader, sizeof(fileHeader),
698 read_exactly(file, sizeof(FATELF_header), records,
718 fFile.SetTo(&file, resourceOffset);
723 ResourceFile::_InitPEFFile(BFile& file, const PEFContainerHeader& pefHeader)
726 // get the file size
728 error = file.GetSize(&fileSize);
730 throw Exception(error, "Failed to get the file size.");
733 throw Exception(B_IO_ERROR, "PEF file architecture is not PPC.");
745 read_exactly(file, shOffset, &sectionHeader, kPEFSectionHeaderSize,
758 "exceeds file: %lu.", sectionEnd);
763 // throw Exception("The PEF object file does not contain resources.");
767 // init the offset file
768 fFile.SetTo(&file, resourceOffset);
1069 " sum: In file: %lx, calculated: %lx.", fileCheckSum,
1189 // set the file size
1330 BFile* file = fFile.File();
1331 // make it an x86 resource file
1332 error = file->SetSize(4);
1334 throw Exception(error, "Failed to set file size.");
1335 write_exactly(*file, 0, kX86ResourceFileMagic, 4,
1339 fFile.SetTo(file, kX86ResourcesOffset);