mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
32 lines
939 B
C++
32 lines
939 B
C++
#include "io-device.hpp"
|
|
#include "orbis/KernelAllocator.hpp"
|
|
#include "orbis/uio.hpp"
|
|
|
|
struct NullDevice : public IoDevice {
|
|
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
|
std::uint32_t flags, std::uint32_t mode) override;
|
|
};
|
|
struct NullFile : public orbis::File {};
|
|
|
|
static orbis::ErrorCode null_write(orbis::File *file, orbis::Uio *uio,
|
|
orbis::Thread *) {
|
|
uio->resid = 0;
|
|
return {};
|
|
}
|
|
|
|
static const orbis::FileOps ops = {
|
|
.write = null_write,
|
|
};
|
|
|
|
orbis::ErrorCode NullDevice::open(orbis::Ref<orbis::File> *file,
|
|
const char *path, std::uint32_t flags,
|
|
std::uint32_t mode) {
|
|
auto newFile = orbis::knew<NullFile>();
|
|
newFile->device = this;
|
|
newFile->ops = &ops;
|
|
*file = newFile;
|
|
return {};
|
|
}
|
|
|
|
IoDevice *createNullCharacterDevice() { return orbis::knew<NullDevice>(); }
|