本文整理汇总了C++中fs::file类的典型用法代码示例。如果您正苦于以下问题:C++ file类的具体用法?C++ file怎么用?C++ file使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了file类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sys_spu_image_open
s32 sys_spu_image_open(vm::ptr<sys_spu_image_t> img, vm::cptr<char> path)
{
sys_spu.warning("sys_spu_image_open(img=*0x%x, path=*0x%x)", img, path);
const fs::file f(vfs::get(path.get_ptr()));
if (!f)
{
sys_spu.error("sys_spu_image_open() error: '%s' not found!", path.get_ptr());
return CELL_ENOENT;
}
SceHeader hdr;
hdr.Load(f);
if (hdr.CheckMagic())
{
throw fmt::exception("sys_spu_image_open() error: '%s' is encrypted! Try to decrypt it manually and try again.", path.get_ptr());
}
f.seek(0);
u32 entry;
u32 offset = LoadSpuImage(f, entry);
img->type = SYS_SPU_IMAGE_TYPE_USER;
img->entry_point = entry;
img->segs.set(offset); // TODO: writing actual segment info
img->nsegs = 1; // wrong value
return CELL_OK;
}
开发者ID:DreadIsBack,项目名称:rpcs3,代码行数:31,代码来源:sys_spu.cpp
示例2: verify_npdrm_self_headers
extern bool verify_npdrm_self_headers(const fs::file& self, u8* klic_key)
{
if (!self)
return false;
self.seek(0);
if (self.size() >= 4 && self.read<u32>() == "SCE\0"_u32)
{
// Check the ELF file class (32 or 64 bit).
bool isElf32 = IsSelfElf32(self);
// Start the decrypter on this SELF file.
SELFDecrypter self_dec(self);
// Load the SELF file headers.
if (!self_dec.LoadHeaders(isElf32))
{
LOG_ERROR(LOADER, "SELF: Failed to load SELF file headers!");
return false;
}
// Load and decrypt the SELF file metadata.
if (!self_dec.LoadMetadata(klic_key))
{
LOG_ERROR(LOADER, "SELF: Failed to load SELF file metadata!");
return false;
}
}
return true;
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:31,代码来源:unself.cpp
示例3: cellUserInfoGetStat
s32 cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> stat)
{
cellUserInfo.warning("cellUserInfoGetStat(id=%d, stat=*0x%x)", id, stat);
if (id > CELL_SYSUTIL_USERID_MAX)
return CELL_USERINFO_ERROR_NOUSER;
if (id == CELL_SYSUTIL_USERID_CURRENT)
{
// TODO: Return current user/profile when that is implemented
id = 1;
}
const std::string& path = vfs::get(fmt::format("/dev_hdd0/home/%08d/", id));
if (!fs::is_dir(path))
return CELL_USERINFO_ERROR_NOUSER;
const fs::file f(path + "localusername");
if (!f)
return CELL_USERINFO_ERROR_INTERNAL;
stat->id = id;
strcpy_trunc(stat->name, f.to_string());
return CELL_OK;
}
开发者ID:Snake128,项目名称:rpcs3,代码行数:25,代码来源:cellUserInfo.cpp
示例4: sys_raw_spu_load
s32 sys_raw_spu_load(s32 id, vm::cptr<char> path, vm::ptr<u32> entry)
{
sysPrxForUser.warning("sys_raw_spu_load(id=%d, path=*0x%x, entry=*0x%x)", id, path, entry);
sysPrxForUser.warning("*** path = '%s'", path.get_ptr());
const fs::file f(vfs::get(path.get_ptr()));
if (!f)
{
sysPrxForUser.error("sys_raw_spu_load() error: '%s' not found!", path.get_ptr());
return CELL_ENOENT;
}
SceHeader hdr;
hdr.Load(f);
if (hdr.CheckMagic())
{
throw fmt::exception("sys_raw_spu_load() error: '%s' is encrypted! Try to decrypt it manually and try again.", path.get_ptr());
}
f.seek(0);
u32 _entry;
LoadSpuImage(f, _entry, RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id);
*entry = _entry | 1;
return CELL_OK;
}
开发者ID:Klozz,项目名称:rpcs3,代码行数:29,代码来源:sys_spu_.cpp
示例5: save_gui_cfg
void save_gui_cfg()
{
YAML::Emitter out;
out.SetSeqFormat(YAML::Flow);
out << g_gui_cfg;
// Save to file
s_gui_cfg.seek(0);
s_gui_cfg.trunc(0);
s_gui_cfg.write(out.c_str(), out.size());
}
开发者ID:sergioengineer,项目名称:rpcs3,代码行数:11,代码来源:rpcs3.cpp
示例6: decrypt_self
extern fs::file decrypt_self(fs::file elf_or_self, u8* klic_key)
{
if (!elf_or_self)
{
return fs::file{};
}
elf_or_self.seek(0);
// Check SELF header first. Check for a debug SELF.
if (elf_or_self.size() >= 4 && elf_or_self.read<u32>() == "SCE\0"_u32 && !CheckDebugSelf(elf_or_self))
{
// Check the ELF file class (32 or 64 bit).
bool isElf32 = IsSelfElf32(elf_or_self);
// Start the decrypter on this SELF file.
SELFDecrypter self_dec(elf_or_self);
// Load the SELF file headers.
if (!self_dec.LoadHeaders(isElf32))
{
LOG_ERROR(LOADER, "SELF: Failed to load SELF file headers!");
return fs::file{};
}
// Load and decrypt the SELF file metadata.
if (!self_dec.LoadMetadata(klic_key))
{
LOG_ERROR(LOADER, "SELF: Failed to load SELF file metadata!");
return fs::file{};
}
// Decrypt the SELF file data.
if (!self_dec.DecryptData())
{
LOG_ERROR(LOADER, "SELF: Failed to decrypt SELF file data!");
return fs::file{};
}
// Make a new ELF file from this SELF.
return self_dec.MakeElf(isElf32);
}
return elf_or_self;
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:45,代码来源:unself.cpp
示例7: Load
void ControlInfo::Load(const fs::file& f)
{
type = Read32(f);
size = Read32(f);
next = Read64(f);
if (type == 1)
{
control_flags.ctrl_flag1 = Read32(f);
control_flags.unknown1 = Read32(f);
control_flags.unknown2 = Read32(f);
control_flags.unknown3 = Read32(f);
control_flags.unknown4 = Read32(f);
control_flags.unknown5 = Read32(f);
control_flags.unknown6 = Read32(f);
control_flags.unknown7 = Read32(f);
}
else if (type == 2)
{
if (size == 0x30)
{
f.read(file_digest_30.digest, 20);
file_digest_30.unknown = Read64(f);
}
else if (size == 0x40)
{
f.read(file_digest_40.digest1, 20);
f.read(file_digest_40.digest2, 20);
file_digest_40.unknown = Read64(f);
}
}
else if (type == 3)
{
npdrm.magic = Read32(f);
npdrm.unknown1 = Read32(f);
npdrm.license = Read32(f);
npdrm.type = Read32(f);
f.read(npdrm.content_id, 48);
f.read(npdrm.digest, 16);
f.read(npdrm.invdigest, 16);
f.read(npdrm.xordigest, 16);
npdrm.unknown2 = Read64(f);
npdrm.unknown3 = Read64(f);
}
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:45,代码来源:unself.cpp
示例8: IsSelfElf32
static bool IsSelfElf32(const fs::file& f)
{
if (!f) return false;
f.seek(0);
SceHeader hdr;
SelfHeader sh;
hdr.Load(f);
sh.Load(f);
// Locate the class byte and check it.
u8 elf_class[0x8];
f.seek(sh.se_elfoff);
f.read(elf_class, 0x8);
return (elf_class[4] == 1);
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:19,代码来源:unself.cpp
示例9: CheckDebugSelf
static bool CheckDebugSelf(fs::file& s)
{
if (s.size() < 0x18)
{
return false;
}
// Get the key version.
s.seek(0x08);
const u16 key_version = s.read<le_t<u16>>();
// Check for DEBUG version.
if (key_version == 0x80 || key_version == 0xc0)
{
LOG_WARNING(LOADER, "Debug SELF detected! Removing fake header...");
// Get the real elf offset.
s.seek(0x10);
// Start at the real elf offset.
s.seek(key_version == 0x80 ? +s.read<be_t<u64>>() : +s.read<le_t<u64>>());
// Write the real ELF file back.
fs::file e = fs::make_stream<std::vector<u8>>();
// Copy the data.
char buf[2048];
while (u64 size = s.read(buf, 2048))
{
e.write(buf, size);
}
s = std::move(e);
return true;
}
// Leave the file untouched.
return false;
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:40,代码来源:unself.cpp
示例10: cellUserInfoGetStat
error_code cellUserInfoGetStat(u32 id, vm::ptr<CellUserInfoUserStat> stat)
{
cellUserInfo.warning("cellUserInfoGetStat(id=%d, stat=*0x%x)", id, stat);
if (id > CELL_SYSUTIL_USERID_MAX)
{
return CELL_USERINFO_ERROR_NOUSER;
}
if (id == CELL_SYSUTIL_USERID_CURRENT)
{
// TODO: Return current user/profile when that is implemented
id = 1;
}
if (!stat)
return CELL_USERINFO_ERROR_PARAM;
const std::string& path = vfs::get(fmt::format("/dev_hdd0/home/%08d/", id));
if (!fs::is_dir(path))
{
cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_NOUSER. User %d doesn't exist. Did you delete the user folder?", id);
return CELL_USERINFO_ERROR_NOUSER;
}
const fs::file f(path + "localusername");
if (!f)
{
cellUserInfo.error("cellUserInfoGetStat(): CELL_USERINFO_ERROR_INTERNAL. Username for user %d doesn't exist. Did you delete the username file?", id);
return CELL_USERINFO_ERROR_INTERNAL;
}
stat->id = id;
strcpy_trunc(stat->name, f.to_string());
return CELL_OK;
}
开发者ID:yiweigang,项目名称:rpcs3,代码行数:39,代码来源:cellUserInfo.cpp
示例11: Init
void Emulator::Init()
{
if (!g_tty)
{
g_tty.open(fs::get_config_dir() + "TTY.log", fs::rewrite + fs::append);
}
idm::init();
fxm::init();
// Reset defaults, cache them
cfg::root.from_default();
g_cfg_defaults = cfg::root.to_string();
// Reload global configuration
cfg::root.from_string(fs::file(fs::get_config_dir() + "/config.yml", fs::read + fs::create).to_string());
}
开发者ID:4iDragon,项目名称:rpcs3,代码行数:17,代码来源:System.cpp
示例12: Init
void Emulator::Init()
{
if (!g_tty)
{
g_tty.open(fs::get_config_dir() + "TTY.log", fs::rewrite + fs::append);
}
idm::init();
fxm::init();
// Reset defaults, cache them
g_cfg.from_default();
g_cfg_defaults = g_cfg.to_string();
// Reload global configuration
g_cfg.from_string(fs::file(fs::get_config_dir() + "/config.yml", fs::read + fs::create).to_string());
// Create directories
const std::string emu_dir_ = g_cfg.vfs.emulator_dir;
const std::string emu_dir = emu_dir_.empty() ? fs::get_config_dir() : emu_dir_;
const std::string dev_hdd0 = fmt::replace_all(g_cfg.vfs.dev_hdd0, "$(EmulatorDir)", emu_dir);
const std::string dev_hdd1 = fmt::replace_all(g_cfg.vfs.dev_hdd1, "$(EmulatorDir)", emu_dir);
const std::string dev_usb = fmt::replace_all(g_cfg.vfs.dev_usb000, "$(EmulatorDir)", emu_dir);
fs::create_path(dev_hdd0);
fs::create_dir(dev_hdd0 + "game/");
fs::create_dir(dev_hdd0 + "game/TEST12345/");
fs::create_dir(dev_hdd0 + "game/TEST12345/USRDIR/");
fs::create_dir(dev_hdd0 + "home/");
fs::create_dir(dev_hdd0 + "home/00000001/");
fs::create_dir(dev_hdd0 + "home/00000001/exdata/");
fs::create_dir(dev_hdd0 + "home/00000001/savedata/");
fs::create_dir(dev_hdd0 + "home/00000001/trophy/");
fs::write_file(dev_hdd0 + "home/00000001/localusername", fs::create + fs::excl + fs::write, "User"s);
fs::create_dir(dev_hdd0 + "disc/");
fs::create_dir(dev_hdd1 + "cache/");
fs::create_dir(dev_hdd1 + "game/");
fs::create_path(dev_hdd1);
fs::create_path(dev_usb);
#ifdef WITH_GDB_DEBUGGER
fxm::make<GDBDebugServer>();
#endif
// Initialize patch engine
fxm::make_always<patch_engine>()->append(fs::get_config_dir() + "/patch.yml");
}
开发者ID:Pataua,项目名称:rpcs3,代码行数:46,代码来源:System.cpp
示例13: Write16LE
inline void Write16LE(const fs::file& f, const u16 data)
{
f.write(&data, sizeof(data));
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:4,代码来源:unself.cpp
示例14: sizeof
void Elf32_Phdr::LoadLE(const fs::file& f)
{
f.read(this, sizeof(*this));
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:4,代码来源:unself.cpp
示例15: Read64LE
inline u64 Read64LE(const fs::file& f)
{
u64 ret;
f.read(&ret, sizeof(ret));
return ret;
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:6,代码来源:unself.cpp
示例16: wxDialog
SettingsDialog::SettingsDialog(wxWindow* parent)
: wxDialog(parent, wxID_ANY, "Settings", wxDefaultPosition)
{
// Load default config
loaded = YAML::Load(g_cfg_defaults);
// Incrementally load config.yml
const fs::file config(fs::get_config_dir() + "/config.yml", fs::read + fs::write + fs::create);
loaded += YAML::Load(config.to_string());
std::vector<std::unique_ptr<cfg_adapter>> pads;
static const u32 width = 458;
static const u32 height = 400;
// Settings panels
wxNotebook* nb_config = new wxNotebook(this, wxID_ANY, wxPoint(6, 6), wxSize(width, height));
wxPanel* p_system = new wxPanel(nb_config, wxID_ANY);
wxPanel* p_core = new wxPanel(nb_config, wxID_ANY);
wxPanel* p_graphics = new wxPanel(nb_config, wxID_ANY);
wxPanel* p_audio = new wxPanel(nb_config, wxID_ANY);
wxPanel* p_io = new wxPanel(nb_config, wxID_ANY);
wxPanel* p_misc = new wxPanel(nb_config, wxID_ANY);
wxPanel* p_networking = new wxPanel(nb_config, wxID_ANY);
nb_config->AddPage(p_core, "Core");
nb_config->AddPage(p_graphics, "Graphics");
nb_config->AddPage(p_audio, "Audio");
nb_config->AddPage(p_io, "Input / Output");
nb_config->AddPage(p_misc, "Misc");
nb_config->AddPage(p_networking, "Networking");
nb_config->AddPage(p_system, "System");
wxBoxSizer* s_subpanel_core = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* s_subpanel_core1 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_core2 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_graphics = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* s_subpanel_graphics1 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_graphics2 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_audio = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_io = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* s_subpanel_io1 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_io2 = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_system = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_misc = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* s_subpanel_networking = new wxBoxSizer(wxVERTICAL);
// Core
wxStaticBoxSizer* s_round_core_lle = new wxStaticBoxSizer(wxVERTICAL, p_core, "Load libraries");
chbox_list_core_lle = new wxCheckListBox(p_core, wxID_ANY, wxDefaultPosition, wxDefaultSize, {}, wxLB_EXTENDED);
chbox_list_core_lle->Bind(wxEVT_CHECKLISTBOX, &SettingsDialog::OnModuleListItemToggled, this);
wxTextCtrl* s_module_search_box = new wxTextCtrl(p_core, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, {});
s_module_search_box->Bind(wxEVT_TEXT, &SettingsDialog::OnSearchBoxTextChanged, this);
// Graphics
wxStaticBoxSizer* s_round_gs_render = new wxStaticBoxSizer(wxVERTICAL, p_graphics, "Rendering API");
wxStaticBoxSizer* s_round_gs_d3d_adapter = new wxStaticBoxSizer(wxVERTICAL, p_graphics, "D3D Adapter");
wxStaticBoxSizer* s_round_gs_res = new wxStaticBoxSizer(wxVERTICAL, p_graphics, "Resolution");
wxStaticBoxSizer* s_round_gs_aspect = new wxStaticBoxSizer(wxVERTICAL, p_graphics, "Aspect ratio");
wxStaticBoxSizer* s_round_gs_frame_limit = new wxStaticBoxSizer(wxVERTICAL, p_graphics, "Frame limit");
// Input / Output
wxStaticBoxSizer* s_round_io_pad_handler = new wxStaticBoxSizer(wxVERTICAL, p_io, "Controller handler");
wxStaticBoxSizer* s_round_io_keyboard_handler = new wxStaticBoxSizer(wxVERTICAL, p_io, "Keyboard handler");
wxStaticBoxSizer* s_round_io_mouse_handler = new wxStaticBoxSizer(wxVERTICAL, p_io, "Mouse handler");
wxStaticBoxSizer* s_round_io_camera = new wxStaticBoxSizer(wxVERTICAL, p_io, "Camera");
wxStaticBoxSizer* s_round_io_camera_type = new wxStaticBoxSizer(wxVERTICAL, p_io, "Camera type");
// Audio
wxStaticBoxSizer* s_round_audio_out = new wxStaticBoxSizer(wxVERTICAL, p_audio, "Audio out");
// Networking
wxStaticBoxSizer* s_round_net_status = new wxStaticBoxSizer(wxVERTICAL, p_networking, "Connection status");
// System
wxStaticBoxSizer* s_round_sys_lang = new wxStaticBoxSizer(wxVERTICAL, p_system, "Language");
wxRadioBox* rbox_ppu_decoder;
wxRadioBox* rbox_spu_decoder;
wxComboBox* cbox_gs_render = new wxComboBox(p_graphics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_gs_d3d_adapter = new wxComboBox(p_graphics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_gs_resolution = new wxComboBox(p_graphics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_gs_aspect = new wxComboBox(p_graphics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_gs_frame_limit = new wxComboBox(p_graphics, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_pad_handler = new wxComboBox(p_io, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);;
wxComboBox* cbox_keyboard_handler = new wxComboBox(p_io, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_mouse_handler = new wxComboBox(p_io, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_camera = new wxComboBox(p_io, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_camera_type = new wxComboBox(p_io, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_audio_out = new wxComboBox(p_audio, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(150, -1), 0, NULL, wxCB_READONLY);
wxComboBox* cbox_net_status = new wxComboBox(p_networking, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
wxComboBox* cbox_sys_lang = new wxComboBox(p_system, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY);
wxCheckBox* chbox_core_hook_stfunc = new wxCheckBox(p_core, wxID_ANY, "Hook static functions");
wxCheckBox* chbox_core_load_liblv2 = new wxCheckBox(p_core, wxID_ANY, "Load liblv2.sprx");
wxCheckBox* chbox_vfs_enable_host_root = new wxCheckBox(p_system, wxID_ANY, "Enable /host_root/");
wxCheckBox* chbox_gs_log_prog = new wxCheckBox(p_graphics, wxID_ANY, "Log shader programs");
wxCheckBox* chbox_gs_dump_depth = new wxCheckBox(p_graphics, wxID_ANY, "Write depth buffer");
//.........这里部分代码省略.........
开发者ID:Zangetsu38,项目名称:rpcs3,代码行数:101,代码来源:SettingsDialog.cpp
示例17: Write8
inline void Write8(const fs::file& f, const u8 data)
{
f.write(&data, sizeof(data));
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:4,代码来源:unself.cpp
示例18: Write32LE
inline void Write32LE(const fs::file& f, const u32 data)
{
f.write(&data, sizeof(data));
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:4,代码来源:unself.cpp
示例19: Write16
inline void Write16(const fs::file& f, const be_t<u16> data)
{
f.write(&data, sizeof(data));
}
开发者ID:AniLeo,项目名称:rpcs3,代码行数:4,代码来源:unself.cpp
示例20: Write64LE
__forceinline void Write64LE(const fs::file& f, const u64 data)
{
f.write(&data, sizeof(data));
}
开发者ID:Bruceharper,项目名称:rpcs3,代码行数:4,代码来源:unself.cpp
注:本文中的fs::file类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论