本文整理汇总了C++中FileHandle::close方法的典型用法代码示例。如果您正苦于以下问题:C++ FileHandle::close方法的具体用法?C++ FileHandle::close怎么用?C++ FileHandle::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHandle
的用法示例。
在下文中一共展示了FileHandle::close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_sf_file_write_fhandle
bool test_sf_file_write_fhandle(const char *filename, const int kib_rw) {
bool result = true;
FileHandle* file = sd.open(filename, O_WRONLY | O_CREAT | O_TRUNC);
if (file != NULL) {
int byte_write = 0;
timer.start();
for (int i = 0; i < kib_rw; i++) {
if (file->write(buffer, sizeof(buffer)) != sizeof(buffer)) {
result = false;
file->close();
printf("Write error!\r\n");
break;
} else {
byte_write++;
}
}
timer.stop();
file->close();
double test_time_sec = timer.read_us() / 1000000.0;
double speed = kib_rw / test_time_sec;
printf("%d KiB write in %.3f sec with speed of %.4f KiB/s\r\n", byte_write, test_time_sec, speed);
notify_performance_coefficient("write_kibps", speed);
} else {
printf("File '%s' not opened\r\n", filename);
result = false;
}
timer.reset();
return result;
}
示例2: file
SmartPtr<VKShader>
VKDevice::create_shader (const char *file_name)
{
FileHandle file (file_name, "rb");
XCAM_FAIL_RETURN (
ERROR, file.is_valid (), NULL,
"VKDevice load shader failed when opend shader file:%s.",
XCAM_STR (file_name));
size_t file_size;
XCAM_FAIL_RETURN (
ERROR, xcam_ret_is_ok (file.get_file_size (file_size)) || file_size == 0, NULL,
"VKDevice load shader failed when read shader file:%s.",
XCAM_STR (file_name));
std::vector<uint32_t> content (XCAM_ALIGN_UP (file_size, 4) / 4, 0);
XCAM_FAIL_RETURN (
ERROR, xcam_ret_is_ok (file.read_file ((void *)content.data (), file_size)), NULL,
"VKDevice load shader failed when read shader file:%s.",
XCAM_STR (file_name));
file.close ();
SmartPtr<VKShader> shader = create_shader (content);
if (shader.ptr ())
shader->set_name (file_name);
return shader;
}
示例3: file_close
void file_close(EngineState *s, int handle) {
debugC(2, kDebugLevelFile, "Closing file %d\n", handle);
FileHandle *f = getFileFromHandle(s, handle);
if (f)
f->close();
}
示例4: emit
bool Linker::emit(int pFileDescriptor)
{
FileHandle file;
file.delegate(pFileDescriptor);
MemoryArea* output = new MemoryArea(file);
bool result = emit(*output);
delete output;
file.close();
return result;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_frameworks_compile_mclinker,代码行数:12,代码来源:Linker.cpp
示例5: test_sf_file_read_fhandle
bool test_sf_file_read_fhandle(const char *filename, const int kib_rw) {
bool result = true;
FileHandle* file = sd.open(filename, O_RDONLY);
if (file) {
timer.start();
int byte_read = 0;
while (file->read(buffer, sizeof(buffer)) == sizeof(buffer)) {
byte_read++;
}
timer.stop();
file->close();
double test_time_sec = timer.read_us() / 1000000.0;
double speed = kib_rw / test_time_sec;
printf("%d KiB read in %.3f sec with speed of %.4f KiB/s\r\n", byte_read, test_time_sec, speed);
notify_performance_coefficient("fs_read_kibps", speed);
} else {
printf("File '%s' not opened\r\n", filename);
result = false;
}
timer.reset();
return result;
}
示例6: while
ParArchive::ParArchive(string filename)
{
is_corrupt = 0;
par_header header;
char *packet_body;
unsigned char digest[16];
MD5_CTX context;
FileHandle *file = open_filehandle(filename);
stringstream s;
const char *magic_packet_sequence = "PAR2\0PKT";
const char *main_packet_sequence = "PAR 2.0\0Main\0\0\0\0";
const char *filedesc_packet_sequence = "PAR 2.0\0FileDesc";
console->log("par2 parsing: " + filename);
while(fread(&header, sizeof(header), 1, file->fh) && !is_corrupt) {
Uint32 packet_size = 0;
if(header.length > sizeof(header) && (header.length < 1000000)) {
packet_size = header.length - sizeof(header);
packet_body = (char *)malloc(packet_size);
} else {
is_corrupt = 1;
packet_body = (char *)malloc(1);
}
if(!is_corrupt) {
if(1 != fread(packet_body, packet_size, 1, file->fh)){
console->log("Short read on body. I have no choice but to turn thee in for a corrupt file!");
is_corrupt = 1;
}
}
if(!is_corrupt) {
MD5_Init(&context);
MD5_Update(&context, header.recovery_set_id, 32);
MD5_Update(&context, packet_body, packet_size);
MD5_Final(digest, &context);
if(!CMP_MD5(digest, header.packet_hash)){
is_corrupt = 1;
}
}
if(!is_corrupt) {
if(0 == memcmp(header.magic_sequence, magic_packet_sequence, 8)) {
} else {
console->log("Not a PAR packet??");
is_corrupt = 1;
}
}
if(!is_corrupt) {
if(0 == memcmp(header.type, main_packet_sequence, 16)) {
}
if(0 == memcmp(header.type, filedesc_packet_sequence, 16)) {
Uint32 filename_length = header.length - sizeof(header) - 56;
char *name = (char *)malloc(filename_length +1);
memcpy(name, packet_body + 56, filename_length);
name[filename_length] = '\0';
ParFileInfo *new_file = new ParFileInfo(name);
memcpy(new_file->hash, packet_body + 16, 16);
// console->log("File " + new_file->filename);
// console->log(" hash: " + hash_to_hex(new_file->hash));
par_files.push_back(new_file);
free(name);
}
}
free(packet_body);
}
file->close();
close_finished_files();
}