mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-18 17:34:52 +00:00
moved everything to old stuff
This commit is contained in:
parent
e420476829
commit
5f19daf3ba
53 changed files with 1 additions and 6 deletions
72
old_stuff/tools/pkg extractor/FsFile.h
Normal file
72
old_stuff/tools/pkg extractor/FsFile.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
#pragma once
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include "Types.h"
|
||||
|
||||
enum fsOpenMode
|
||||
{
|
||||
fsRead = 0x1,
|
||||
fsWrite = 0x2,
|
||||
fsReadWrite = fsRead | fsWrite
|
||||
};
|
||||
|
||||
enum fsSeekMode
|
||||
{
|
||||
fsSeekSet,
|
||||
fsSeekCur,
|
||||
fsSeekEnd,
|
||||
};
|
||||
|
||||
class FsFile
|
||||
{
|
||||
std::FILE* m_file;
|
||||
public:
|
||||
FsFile();
|
||||
FsFile(const std::string& path, fsOpenMode mode = fsRead);
|
||||
bool Open(const std::string& path, fsOpenMode mode = fsRead);
|
||||
bool IsOpen() const;
|
||||
bool Close();
|
||||
bool Read(void* dst, U64 size);
|
||||
U32 ReadBytes(void* dst, U64 size);
|
||||
bool Write(const void* src, U64 size);
|
||||
bool Seek(S64 offset, fsSeekMode mode);
|
||||
U64 getFileSize();
|
||||
U64 Tell() const;
|
||||
~FsFile();
|
||||
|
||||
template< typename T > bool ReadBE(T& dst)
|
||||
{
|
||||
if (!Read(&dst, sizeof(T))) {
|
||||
return false;
|
||||
}
|
||||
::ReadBE(dst);
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* getOpenMode(fsOpenMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case fsRead: return "rb";
|
||||
case fsWrite: return "wb";
|
||||
case fsReadWrite: return "r+b";
|
||||
}
|
||||
|
||||
return "r";
|
||||
}
|
||||
|
||||
const int getSeekMode(fsSeekMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case fsSeekSet: return SEEK_SET;
|
||||
case fsSeekCur: return SEEK_CUR;
|
||||
case fsSeekEnd: return SEEK_END;
|
||||
}
|
||||
|
||||
return SEEK_SET;
|
||||
}
|
||||
std::FILE* fileDescr()
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue