load super block

This commit is contained in:
w-mj committed 2019-06-17 21:38:10 +08:00
1 parent 9141002fc5
commit b54a2d6dcd
14 files changed
+213 -47

No files matched your search

+18 -7
View File
@@ -1,31 +1,42 @@
#include "mock_disk.h"
#include <unistd.h>
#include <iostream>
using namespace Dev;
_u32 MockDisk::read(MM::Buf& buf, _u32 size) {
f.read(buf.data, size);
std::cout << "\n开始读文件"<<ftell(f)<<std::endl;
fread(buf.data, size, 1, f);
// f.read(buf.data, size);
// for (int i = 0; i < size; i++)
// std::cout << (int)buf.data[i];
return size;
}
_u32 MockDisk::write(MM::Buf& buf, _u32 size) {
f.write(buf.data, size);
fwrite(buf.data, size, 1, f);
// f.write(buf.data, size);
return size;
}
_u32 MockDisk::tell() {
return f.tellg();
return ftell(f);
}
void MockDisk::seek(_u32 pos) {
f.seekg(pos);
fseek(f, pos, SEEK_SET);
}
void MockDisk::open(const std::string& path) {
f.open(path, std::ios::in);
std::cout << "正在打开文件" << std::endl;
f = fopen(path.c_str(), "ab+");
// f.open(path, std::ios::binary);
if (f == nullptr) {
// std::cout << "文件打开错误"<< std::endl;
perror("文件打开错误");
}
}
void MockDisk::close() {
if (f.is_open())
f.close();
fclose(f);
}