mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-09-25 21:03:18 +02:00
haze: event_reactor, file_system_proxy, ptp: style
This commit is contained in:
parent
453afc7d08
commit
a5a2b22a52
@ -18,7 +18,7 @@
|
|||||||
#include <haze/async_usb_server.hpp>
|
#include <haze/async_usb_server.hpp>
|
||||||
#include <haze/common.hpp>
|
#include <haze/common.hpp>
|
||||||
#include <haze/event_reactor.hpp>
|
#include <haze/event_reactor.hpp>
|
||||||
#include <haze/filesystem_proxy.hpp>
|
#include <haze/file_system_proxy.hpp>
|
||||||
#include <haze/ptp.hpp>
|
#include <haze/ptp.hpp>
|
||||||
#include <haze/ptp_object_database.hpp>
|
#include <haze/ptp_object_database.hpp>
|
||||||
#include <haze/ptp_object_heap.hpp>
|
#include <haze/ptp_object_heap.hpp>
|
||||||
|
@ -42,7 +42,7 @@ namespace haze {
|
|||||||
public:
|
public:
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
Result WaitFor(s32 *out_arg_waiter, Args &&... arg_waiters) {
|
Result WaitFor(s32 *out_arg_waiter, Args &&... arg_waiters) {
|
||||||
const Waiter arg_waiter_array[] = {arg_waiters...};
|
const Waiter arg_waiter_array[] = { arg_waiters... };
|
||||||
return this->WaitForImpl(out_arg_waiter, sizeof...(Args), arg_waiter_array);
|
return this->WaitForImpl(out_arg_waiter, sizeof...(Args), arg_waiter_array);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
@ -20,12 +20,12 @@
|
|||||||
|
|
||||||
namespace haze {
|
namespace haze {
|
||||||
|
|
||||||
class FilesystemProxy final {
|
class FileSystemProxy final {
|
||||||
private:
|
private:
|
||||||
EventReactor *m_reactor;
|
EventReactor *m_reactor;
|
||||||
FsFileSystem *m_filesystem;
|
FsFileSystem *m_filesystem;
|
||||||
public:
|
public:
|
||||||
constexpr explicit FilesystemProxy() : m_reactor(), m_filesystem() { /* ... */ }
|
constexpr explicit FileSystemProxy() : m_reactor(), m_filesystem() { /* ... */ }
|
||||||
|
|
||||||
void Initialize(EventReactor *reactor, FsFileSystem *fs) {
|
void Initialize(EventReactor *reactor, FsFileSystem *fs) {
|
||||||
HAZE_ASSERT(fs != nullptr);
|
HAZE_ASSERT(fs != nullptr);
|
||||||
@ -41,10 +41,13 @@ namespace haze {
|
|||||||
private:
|
private:
|
||||||
template <typename F, typename... Args>
|
template <typename F, typename... Args>
|
||||||
Result ForwardResult(F func, Args &&... args) {
|
Result ForwardResult(F func, Args &&... args) {
|
||||||
Result rc = func(std::forward<Args>(args)...);
|
/* Perform the method call, collecting its result. */
|
||||||
|
const Result rc = func(std::forward<Args>(args)...);
|
||||||
|
|
||||||
|
/* If the event loop was stopped, return that here. */
|
||||||
R_UNLESS(!m_reactor->GetStopRequested(), haze::ResultStopRequested());
|
R_UNLESS(!m_reactor->GetStopRequested(), haze::ResultStopRequested());
|
||||||
|
|
||||||
|
/* Otherwise, return the call result. */
|
||||||
R_RETURN(rc);
|
R_RETURN(rc);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
@ -72,23 +75,23 @@ namespace haze {
|
|||||||
R_RETURN(this->ForwardResult(fsFsOpenFile, m_filesystem, path, mode, out_file));
|
R_RETURN(this->ForwardResult(fsFsOpenFile, m_filesystem, path, mode, out_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FileGetSize(FsFile *file, s64 *out_size) {
|
Result GetSizeFile(FsFile *file, s64 *out_size) {
|
||||||
R_RETURN(this->ForwardResult(fsFileGetSize, file, out_size));
|
R_RETURN(this->ForwardResult(fsFileGetSize, file, out_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FileSetSize(FsFile *file, s64 size) {
|
Result SetSizeFile(FsFile *file, s64 size) {
|
||||||
R_RETURN(this->ForwardResult(fsFileSetSize, file, size));
|
R_RETURN(this->ForwardResult(fsFileSetSize, file, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FileRead(FsFile *file, s64 off, void *buf, u64 read_size, u32 option, u64 *out_bytes_read) {
|
Result ReadFile(FsFile *file, s64 off, void *buf, u64 read_size, u32 option, u64 *out_bytes_read) {
|
||||||
R_RETURN(this->ForwardResult(fsFileRead, file, off, buf, read_size, option, out_bytes_read));
|
R_RETURN(this->ForwardResult(fsFileRead, file, off, buf, read_size, option, out_bytes_read));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FileWrite(FsFile *file, s64 off, const void *buf, u64 write_size, u32 option) {
|
Result WriteFile(FsFile *file, s64 off, const void *buf, u64 write_size, u32 option) {
|
||||||
R_RETURN(this->ForwardResult(fsFileWrite, file, off, buf, write_size, option));
|
R_RETURN(this->ForwardResult(fsFileWrite, file, off, buf, write_size, option));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileClose(FsFile *file) {
|
void CloseFile(FsFile *file) {
|
||||||
fsFileClose(file);
|
fsFileClose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,15 +107,15 @@ namespace haze {
|
|||||||
R_RETURN(this->ForwardResult(fsFsOpenDirectory, m_filesystem, path, mode, out_dir));
|
R_RETURN(this->ForwardResult(fsFsOpenDirectory, m_filesystem, path, mode, out_dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result DirectoryRead(FsDir *d, s64 *out_total_entries, size_t max_entries, FsDirectoryEntry *buf) {
|
Result ReadDirectory(FsDir *d, s64 *out_total_entries, size_t max_entries, FsDirectoryEntry *buf) {
|
||||||
R_RETURN(this->ForwardResult(fsDirRead, d, out_total_entries, max_entries, buf));
|
R_RETURN(this->ForwardResult(fsDirRead, d, out_total_entries, max_entries, buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result DirectoryGetEntryCount(FsDir *d, s64 *out_count) {
|
Result GetEntryCountDirectory(FsDir *d, s64 *out_count) {
|
||||||
R_RETURN(this->ForwardResult(fsDirGetEntryCount, d, out_count));
|
R_RETURN(this->ForwardResult(fsDirGetEntryCount, d, out_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectoryClose(FsDir *d) {
|
void CloseDirectory(FsDir *d) {
|
||||||
fsDirClose(d);
|
fsDirClose(d);
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
namespace haze {
|
namespace haze {
|
||||||
|
|
||||||
constexpr size_t PtpUsbBulkHighSpeedMaxPacketLength = 0x200;
|
constexpr inline size_t PtpUsbBulkHighSpeedMaxPacketLength = 0x200;
|
||||||
constexpr size_t PtpUsbBulkHeaderLength = 2 * sizeof(uint32_t) + 2 * sizeof(uint16_t);
|
constexpr inline size_t PtpUsbBulkHeaderLength = 2 * sizeof(u32) + 2 * sizeof(u16);
|
||||||
constexpr size_t PtpStringMaxLength = 255;
|
constexpr inline size_t PtpStringMaxLength = 255;
|
||||||
|
|
||||||
enum PtpUsbBulkContainerType : u16 {
|
enum PtpUsbBulkContainerType : u16 {
|
||||||
PtpUsbBulkContainerType_Undefined = 0,
|
PtpUsbBulkContainerType_Undefined = 0,
|
||||||
@ -43,12 +43,12 @@ namespace haze {
|
|||||||
PtpOperationCode_GetObjectHandles = 0x1007,
|
PtpOperationCode_GetObjectHandles = 0x1007,
|
||||||
PtpOperationCode_GetObjectInfo = 0x1008,
|
PtpOperationCode_GetObjectInfo = 0x1008,
|
||||||
PtpOperationCode_GetObject = 0x1009,
|
PtpOperationCode_GetObject = 0x1009,
|
||||||
PtpOperationCode_GetThumb = 0x100A,
|
PtpOperationCode_GetThumb = 0x100a,
|
||||||
PtpOperationCode_DeleteObject = 0x100B,
|
PtpOperationCode_DeleteObject = 0x100b,
|
||||||
PtpOperationCode_SendObjectInfo = 0x100C,
|
PtpOperationCode_SendObjectInfo = 0x100c,
|
||||||
PtpOperationCode_SendObject = 0x100D,
|
PtpOperationCode_SendObject = 0x100d,
|
||||||
PtpOperationCode_InitiateCapture = 0x100E,
|
PtpOperationCode_InitiateCapture = 0x100e,
|
||||||
PtpOperationCode_FormatStore = 0x100F,
|
PtpOperationCode_FormatStore = 0x100f,
|
||||||
PtpOperationCode_ResetDevice = 0x1010,
|
PtpOperationCode_ResetDevice = 0x1010,
|
||||||
PtpOperationCode_SelfTest = 0x1011,
|
PtpOperationCode_SelfTest = 0x1011,
|
||||||
PtpOperationCode_SetObjectProtection = 0x1012,
|
PtpOperationCode_SetObjectProtection = 0x1012,
|
||||||
@ -59,12 +59,12 @@ namespace haze {
|
|||||||
PtpOperationCode_ResetDevicePropValue = 0x1017,
|
PtpOperationCode_ResetDevicePropValue = 0x1017,
|
||||||
PtpOperationCode_TerminateOpenCapture = 0x1018,
|
PtpOperationCode_TerminateOpenCapture = 0x1018,
|
||||||
PtpOperationCode_MoveObject = 0x1019,
|
PtpOperationCode_MoveObject = 0x1019,
|
||||||
PtpOperationCode_CopyObject = 0x101A,
|
PtpOperationCode_CopyObject = 0x101a,
|
||||||
PtpOperationCode_GetPartialObject = 0x101B,
|
PtpOperationCode_GetPartialObject = 0x101b,
|
||||||
PtpOperationCode_InitiateOpenCapture = 0x101C,
|
PtpOperationCode_InitiateOpenCapture = 0x101c,
|
||||||
PtpOperationCode_StartEnumHandles = 0x101D,
|
PtpOperationCode_StartEnumHandles = 0x101d,
|
||||||
PtpOperationCode_EnumHandles = 0x101E,
|
PtpOperationCode_EnumHandles = 0x101e,
|
||||||
PtpOperationCode_StopEnumHandles = 0x101F,
|
PtpOperationCode_StopEnumHandles = 0x101f,
|
||||||
PtpOperationCode_GetVendorExtensionMaps = 0x1020,
|
PtpOperationCode_GetVendorExtensionMaps = 0x1020,
|
||||||
PtpOperationCode_GetVendorDeviceInfo = 0x1021,
|
PtpOperationCode_GetVendorDeviceInfo = 0x1021,
|
||||||
PtpOperationCode_GetResizedImageObject = 0x1022,
|
PtpOperationCode_GetResizedImageObject = 0x1022,
|
||||||
@ -96,12 +96,12 @@ namespace haze {
|
|||||||
PtpResponseCode_IncompleteTransfer = 0x2007,
|
PtpResponseCode_IncompleteTransfer = 0x2007,
|
||||||
PtpResponseCode_InvalidStorageId = 0x2008,
|
PtpResponseCode_InvalidStorageId = 0x2008,
|
||||||
PtpResponseCode_InvalidObjectHandle = 0x2009,
|
PtpResponseCode_InvalidObjectHandle = 0x2009,
|
||||||
PtpResponseCode_DevicePropNotSupported = 0x200A,
|
PtpResponseCode_DevicePropNotSupported = 0x200a,
|
||||||
PtpResponseCode_InvalidObjectFormatCode = 0x200B,
|
PtpResponseCode_InvalidObjectFormatCode = 0x200b,
|
||||||
PtpResponseCode_StoreFull = 0x200C,
|
PtpResponseCode_StoreFull = 0x200c,
|
||||||
PtpResponseCode_ObjectWriteProtected = 0x200D,
|
PtpResponseCode_ObjectWriteProtected = 0x200d,
|
||||||
PtpResponseCode_StoreReadOnly = 0x200E,
|
PtpResponseCode_StoreReadOnly = 0x200e,
|
||||||
PtpResponseCode_AccessDenied = 0x200F,
|
PtpResponseCode_AccessDenied = 0x200f,
|
||||||
PtpResponseCode_NoThumbnailPresent = 0x2010,
|
PtpResponseCode_NoThumbnailPresent = 0x2010,
|
||||||
PtpResponseCode_SelfTestFailed = 0x2011,
|
PtpResponseCode_SelfTestFailed = 0x2011,
|
||||||
PtpResponseCode_PartialDeletion = 0x2012,
|
PtpResponseCode_PartialDeletion = 0x2012,
|
||||||
@ -112,26 +112,26 @@ namespace haze {
|
|||||||
PtpResponseCode_UnknownVendorCode = 0x2017,
|
PtpResponseCode_UnknownVendorCode = 0x2017,
|
||||||
PtpResponseCode_CaptureAlreadyTerminated = 0x2018,
|
PtpResponseCode_CaptureAlreadyTerminated = 0x2018,
|
||||||
PtpResponseCode_DeviceBusy = 0x2019,
|
PtpResponseCode_DeviceBusy = 0x2019,
|
||||||
PtpResponseCode_InvalidParentObject = 0x201A,
|
PtpResponseCode_InvalidParentObject = 0x201a,
|
||||||
PtpResponseCode_InvalidDevicePropFormat = 0x201B,
|
PtpResponseCode_InvalidDevicePropFormat = 0x201b,
|
||||||
PtpResponseCode_InvalidDevicePropValue = 0x201C,
|
PtpResponseCode_InvalidDevicePropValue = 0x201c,
|
||||||
PtpResponseCode_InvalidParameter = 0x201D,
|
PtpResponseCode_InvalidParameter = 0x201d,
|
||||||
PtpResponseCode_SessionAlreadyOpened = 0x201E,
|
PtpResponseCode_SessionAlreadyOpened = 0x201e,
|
||||||
PtpResponseCode_TransactionCanceled = 0x201F,
|
PtpResponseCode_TransactionCanceled = 0x201f,
|
||||||
PtpResponseCode_SpecificationOfDestinationUnsupported = 0x2020,
|
PtpResponseCode_SpecificationOfDestinationUnsupported = 0x2020,
|
||||||
PtpResponseCode_InvalidEnumHandle = 0x2021,
|
PtpResponseCode_InvalidEnumHandle = 0x2021,
|
||||||
PtpResponseCode_NoStreamEnabled = 0x2022,
|
PtpResponseCode_NoStreamEnabled = 0x2022,
|
||||||
PtpResponseCode_InvalidDataSet = 0x2023,
|
PtpResponseCode_InvalidDataSet = 0x2023,
|
||||||
PtpResponseCode_MtpUndefined = 0xA800,
|
PtpResponseCode_MtpUndefined = 0xa800,
|
||||||
PtpResponseCode_MtpInvalid_ObjectPropCode = 0xA801,
|
PtpResponseCode_MtpInvalid_ObjectPropCode = 0xa801,
|
||||||
PtpResponseCode_MtpInvalid_ObjectProp_Format = 0xA802,
|
PtpResponseCode_MtpInvalid_ObjectProp_Format = 0xa802,
|
||||||
PtpResponseCode_MtpInvalid_ObjectProp_Value = 0xA803,
|
PtpResponseCode_MtpInvalid_ObjectProp_Value = 0xa803,
|
||||||
PtpResponseCode_MtpInvalid_ObjectReference = 0xA804,
|
PtpResponseCode_MtpInvalid_ObjectReference = 0xa804,
|
||||||
PtpResponseCode_MtpInvalid_Dataset = 0xA806,
|
PtpResponseCode_MtpInvalid_Dataset = 0xa806,
|
||||||
PtpResponseCode_MtpSpecification_By_Group_Unsupported = 0xA807,
|
PtpResponseCode_MtpSpecification_By_Group_Unsupported = 0xa807,
|
||||||
PtpResponseCode_MtpSpecification_By_Depth_Unsupported = 0xA808,
|
PtpResponseCode_MtpSpecification_By_Depth_Unsupported = 0xa808,
|
||||||
PtpResponseCode_MtpObject_Too_Large = 0xA809,
|
PtpResponseCode_MtpObject_Too_Large = 0xa809,
|
||||||
PtpResponseCode_MtpObjectProp_Not_Supported = 0xA80A,
|
PtpResponseCode_MtpObjectProp_Not_Supported = 0xa80A,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PtpEventCode : u16 {
|
enum PtpEventCode : u16 {
|
||||||
@ -145,11 +145,11 @@ namespace haze {
|
|||||||
PtpEventCode_ObjectInfoChanged = 0x4007,
|
PtpEventCode_ObjectInfoChanged = 0x4007,
|
||||||
PtpEventCode_DeviceInfoChanged = 0x4008,
|
PtpEventCode_DeviceInfoChanged = 0x4008,
|
||||||
PtpEventCode_RequestObjectTransfer = 0x4009,
|
PtpEventCode_RequestObjectTransfer = 0x4009,
|
||||||
PtpEventCode_StoreFull = 0x400A,
|
PtpEventCode_StoreFull = 0x400a,
|
||||||
PtpEventCode_DeviceReset = 0x400B,
|
PtpEventCode_DeviceReset = 0x400b,
|
||||||
PtpEventCode_StorageInfoChanged = 0x400C,
|
PtpEventCode_StorageInfoChanged = 0x400c,
|
||||||
PtpEventCode_CaptureComplete = 0x400D,
|
PtpEventCode_CaptureComplete = 0x400d,
|
||||||
PtpEventCode_UnreportedStatus = 0x400E,
|
PtpEventCode_UnreportedStatus = 0x400e,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PtpDevicePropertyCode : u16 {
|
enum PtpDevicePropertyCode : u16 {
|
||||||
@ -163,12 +163,12 @@ namespace haze {
|
|||||||
PtpDevicePropertyCode_FNumber = 0x5007,
|
PtpDevicePropertyCode_FNumber = 0x5007,
|
||||||
PtpDevicePropertyCode_FocalLength = 0x5008,
|
PtpDevicePropertyCode_FocalLength = 0x5008,
|
||||||
PtpDevicePropertyCode_FocusDistance = 0x5009,
|
PtpDevicePropertyCode_FocusDistance = 0x5009,
|
||||||
PtpDevicePropertyCode_FocusMode = 0x500A,
|
PtpDevicePropertyCode_FocusMode = 0x500a,
|
||||||
PtpDevicePropertyCode_ExposureMeteringMode = 0x500B,
|
PtpDevicePropertyCode_ExposureMeteringMode = 0x500b,
|
||||||
PtpDevicePropertyCode_FlashMode = 0x500C,
|
PtpDevicePropertyCode_FlashMode = 0x500c,
|
||||||
PtpDevicePropertyCode_ExposureTime = 0x500D,
|
PtpDevicePropertyCode_ExposureTime = 0x500d,
|
||||||
PtpDevicePropertyCode_ExposureProgramMode = 0x500E,
|
PtpDevicePropertyCode_ExposureProgramMode = 0x500e,
|
||||||
PtpDevicePropertyCode_ExposureIndex = 0x500F,
|
PtpDevicePropertyCode_ExposureIndex = 0x500f,
|
||||||
PtpDevicePropertyCode_ExposureBiasCompensation = 0x5010,
|
PtpDevicePropertyCode_ExposureBiasCompensation = 0x5010,
|
||||||
PtpDevicePropertyCode_DateTime = 0x5011,
|
PtpDevicePropertyCode_DateTime = 0x5011,
|
||||||
PtpDevicePropertyCode_CaptureDelay = 0x5012,
|
PtpDevicePropertyCode_CaptureDelay = 0x5012,
|
||||||
@ -179,12 +179,12 @@ namespace haze {
|
|||||||
PtpDevicePropertyCode_EffectMode = 0x5017,
|
PtpDevicePropertyCode_EffectMode = 0x5017,
|
||||||
PtpDevicePropertyCode_BurstNumber = 0x5018,
|
PtpDevicePropertyCode_BurstNumber = 0x5018,
|
||||||
PtpDevicePropertyCode_BurstInterval = 0x5019,
|
PtpDevicePropertyCode_BurstInterval = 0x5019,
|
||||||
PtpDevicePropertyCode_TimelapseNumber = 0x501A,
|
PtpDevicePropertyCode_TimelapseNumber = 0x501a,
|
||||||
PtpDevicePropertyCode_TimelapseInterval = 0x501B,
|
PtpDevicePropertyCode_TimelapseInterval = 0x501b,
|
||||||
PtpDevicePropertyCode_FocusMeteringMode = 0x501C,
|
PtpDevicePropertyCode_FocusMeteringMode = 0x501c,
|
||||||
PtpDevicePropertyCode_UploadUrl = 0x501D,
|
PtpDevicePropertyCode_UploadUrl = 0x501d,
|
||||||
PtpDevicePropertyCode_Artist = 0x501E,
|
PtpDevicePropertyCode_Artist = 0x501e,
|
||||||
PtpDevicePropertyCode_CopyrightInfo = 0x501F,
|
PtpDevicePropertyCode_CopyrightInfo = 0x501f,
|
||||||
PtpDevicePropertyCode_SupportedStreams = 0x5020,
|
PtpDevicePropertyCode_SupportedStreams = 0x5020,
|
||||||
PtpDevicePropertyCode_EnabledStreams = 0x5021,
|
PtpDevicePropertyCode_EnabledStreams = 0x5021,
|
||||||
PtpDevicePropertyCode_VideoFormat = 0x5022,
|
PtpDevicePropertyCode_VideoFormat = 0x5022,
|
||||||
@ -195,16 +195,16 @@ namespace haze {
|
|||||||
PtpDevicePropertyCode_VideoBrightness = 0x5027,
|
PtpDevicePropertyCode_VideoBrightness = 0x5027,
|
||||||
PtpDevicePropertyCode_AudioFormat = 0x5028,
|
PtpDevicePropertyCode_AudioFormat = 0x5028,
|
||||||
PtpDevicePropertyCode_AudioBitrate = 0x5029,
|
PtpDevicePropertyCode_AudioBitrate = 0x5029,
|
||||||
PtpDevicePropertyCode_AudioSamplingRate = 0x502A,
|
PtpDevicePropertyCode_AudioSamplingRate = 0x502a,
|
||||||
PtpDevicePropertyCode_AudioBitPerSample = 0x502B,
|
PtpDevicePropertyCode_AudioBitPerSample = 0x502b,
|
||||||
PtpDevicePropertyCode_AudioVolume = 0x502C,
|
PtpDevicePropertyCode_AudioVolume = 0x502c,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PtpObjectFormatCode : u16 {
|
enum PtpObjectFormatCode : u16 {
|
||||||
PtpObjectFormatCode_Undefined = 0x3000,
|
PtpObjectFormatCode_Undefined = 0x3000,
|
||||||
PtpObjectFormatCode_Association = 0x3001,
|
PtpObjectFormatCode_Association = 0x3001,
|
||||||
PtpObjectFormatCode_Defined = 0x3800,
|
PtpObjectFormatCode_Defined = 0x3800,
|
||||||
PtpObjectFormatCode_MtpMediaCard = 0xB211,
|
PtpObjectFormatCode_MtpMediaCard = 0xb211,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PtpAssociationType : u16 {
|
enum PtpAssociationType : u16 {
|
||||||
@ -252,16 +252,16 @@ namespace haze {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct PtpUsbBulkContainer {
|
struct PtpUsbBulkContainer {
|
||||||
uint32_t length;
|
u32 length;
|
||||||
uint16_t type;
|
u16 type;
|
||||||
uint16_t code;
|
u16 code;
|
||||||
uint32_t trans_id;
|
u32 trans_id;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(PtpUsbBulkContainer) == PtpUsbBulkHeaderLength);
|
static_assert(sizeof(PtpUsbBulkContainer) == PtpUsbBulkHeaderLength);
|
||||||
|
|
||||||
struct PtpNewObjectInfo {
|
struct PtpNewObjectInfo {
|
||||||
uint32_t storage_id;
|
u32 storage_id;
|
||||||
uint32_t parent_object_id;
|
u32 parent_object_id;
|
||||||
uint32_t object_id;
|
u32 object_id;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ namespace haze {
|
|||||||
class PtpResponder final {
|
class PtpResponder final {
|
||||||
private:
|
private:
|
||||||
AsyncUsbServer m_usb_server;
|
AsyncUsbServer m_usb_server;
|
||||||
FilesystemProxy m_fs;
|
FileSystemProxy m_fs;
|
||||||
PtpUsbBulkContainer m_request_header;
|
PtpUsbBulkContainer m_request_header;
|
||||||
PtpObjectHeap *m_object_heap;
|
PtpObjectHeap *m_object_heap;
|
||||||
u32 m_send_object_id;
|
u32 m_send_object_id;
|
||||||
|
@ -383,11 +383,11 @@ namespace haze {
|
|||||||
R_TRY(m_fs.OpenDirectory(fileobj->GetName(), FsDirOpenMode_ReadDirs | FsDirOpenMode_ReadFiles, std::addressof(dir)));
|
R_TRY(m_fs.OpenDirectory(fileobj->GetName(), FsDirOpenMode_ReadDirs | FsDirOpenMode_ReadFiles, std::addressof(dir)));
|
||||||
|
|
||||||
/* Ensure we maintain a clean state on exit. */
|
/* Ensure we maintain a clean state on exit. */
|
||||||
ON_SCOPE_EXIT { m_fs.DirectoryClose(std::addressof(dir)); };
|
ON_SCOPE_EXIT { m_fs.CloseDirectory(std::addressof(dir)); };
|
||||||
|
|
||||||
/* Count how many entries are in the directory. */
|
/* Count how many entries are in the directory. */
|
||||||
s64 entry_count = 0;
|
s64 entry_count = 0;
|
||||||
R_TRY(m_fs.DirectoryGetEntryCount(std::addressof(dir), std::addressof(entry_count)));
|
R_TRY(m_fs.GetEntryCountDirectory(std::addressof(dir), std::addressof(entry_count)));
|
||||||
|
|
||||||
/* Begin writing. */
|
/* Begin writing. */
|
||||||
R_TRY(db.AddDataHeader(m_request_header, sizeof(u32) + (entry_count * sizeof(u32))));
|
R_TRY(db.AddDataHeader(m_request_header, sizeof(u32) + (entry_count * sizeof(u32))));
|
||||||
@ -398,7 +398,7 @@ namespace haze {
|
|||||||
while (true) {
|
while (true) {
|
||||||
/* Get the next batch. */
|
/* Get the next batch. */
|
||||||
s64 read_count = 0;
|
s64 read_count = 0;
|
||||||
R_TRY(m_fs.DirectoryRead(std::addressof(dir), std::addressof(read_count), DirectoryReadSize, s_dir_entries));
|
R_TRY(m_fs.ReadDirectory(std::addressof(dir), std::addressof(read_count), DirectoryReadSize, s_dir_entries));
|
||||||
|
|
||||||
/* Write to output. */
|
/* Write to output. */
|
||||||
for (s64 i = 0; i < read_count; i++) {
|
for (s64 i = 0; i < read_count; i++) {
|
||||||
@ -450,9 +450,9 @@ namespace haze {
|
|||||||
R_TRY(m_fs.OpenFile(fileobj->GetName(), FsOpenMode_Read, std::addressof(file)));
|
R_TRY(m_fs.OpenFile(fileobj->GetName(), FsOpenMode_Read, std::addressof(file)));
|
||||||
|
|
||||||
/* Ensure we maintain a clean state on exit. */
|
/* Ensure we maintain a clean state on exit. */
|
||||||
ON_SCOPE_EXIT { m_fs.FileClose(std::addressof(file)); };
|
ON_SCOPE_EXIT { m_fs.CloseFile(std::addressof(file)); };
|
||||||
|
|
||||||
R_TRY(m_fs.FileGetSize(std::addressof(file), std::addressof(size)));
|
R_TRY(m_fs.GetSizeFile(std::addressof(file), std::addressof(size)));
|
||||||
}
|
}
|
||||||
|
|
||||||
object_info.filename = std::strrchr(fileobj->GetName(), '/') + 1;
|
object_info.filename = std::strrchr(fileobj->GetName(), '/') + 1;
|
||||||
@ -512,11 +512,11 @@ namespace haze {
|
|||||||
R_TRY(m_fs.OpenFile(fileobj->GetName(), FsOpenMode_Read, std::addressof(file)));
|
R_TRY(m_fs.OpenFile(fileobj->GetName(), FsOpenMode_Read, std::addressof(file)));
|
||||||
|
|
||||||
/* Ensure we maintain a clean state on exit. */
|
/* Ensure we maintain a clean state on exit. */
|
||||||
ON_SCOPE_EXIT { m_fs.FileClose(std::addressof(file)); };
|
ON_SCOPE_EXIT { m_fs.CloseFile(std::addressof(file)); };
|
||||||
|
|
||||||
/* Get the file's size. */
|
/* Get the file's size. */
|
||||||
s64 size = 0, offset = 0;
|
s64 size = 0, offset = 0;
|
||||||
R_TRY(m_fs.FileGetSize(std::addressof(file), std::addressof(size)));
|
R_TRY(m_fs.GetSizeFile(std::addressof(file), std::addressof(size)));
|
||||||
|
|
||||||
/* Send the header and file size. */
|
/* Send the header and file size. */
|
||||||
R_TRY(db.AddDataHeader(m_request_header, size));
|
R_TRY(db.AddDataHeader(m_request_header, size));
|
||||||
@ -524,7 +524,7 @@ namespace haze {
|
|||||||
while (true) {
|
while (true) {
|
||||||
/* Get the next batch. */
|
/* Get the next batch. */
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
R_TRY(m_fs.FileRead(std::addressof(file), offset, s_fs_buffer, FsBufferSize, FsReadOption_None, std::addressof(bytes_read)));
|
R_TRY(m_fs.ReadFile(std::addressof(file), offset, s_fs_buffer, FsBufferSize, FsReadOption_None, std::addressof(bytes_read)));
|
||||||
|
|
||||||
offset += bytes_read;
|
offset += bytes_read;
|
||||||
|
|
||||||
@ -640,11 +640,11 @@ namespace haze {
|
|||||||
R_TRY(m_fs.OpenFile(fileobj->GetName(), FsOpenMode_Write | FsOpenMode_Append, std::addressof(file)));
|
R_TRY(m_fs.OpenFile(fileobj->GetName(), FsOpenMode_Write | FsOpenMode_Append, std::addressof(file)));
|
||||||
|
|
||||||
/* Ensure we maintain a clean state on exit. */
|
/* Ensure we maintain a clean state on exit. */
|
||||||
ON_SCOPE_EXIT { m_fs.FileClose(std::addressof(file)); };
|
ON_SCOPE_EXIT { m_fs.CloseFile(std::addressof(file)); };
|
||||||
|
|
||||||
/* Truncate the file after locking for write. */
|
/* Truncate the file after locking for write. */
|
||||||
s64 offset = 0;
|
s64 offset = 0;
|
||||||
R_TRY(m_fs.FileSetSize(std::addressof(file), 0));
|
R_TRY(m_fs.SetSizeFile(std::addressof(file), 0));
|
||||||
|
|
||||||
/* Begin writing. */
|
/* Begin writing. */
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -653,7 +653,7 @@ namespace haze {
|
|||||||
Result rc = dp.ReadBuffer(s_fs_buffer, FsBufferSize, std::addressof(bytes_received));
|
Result rc = dp.ReadBuffer(s_fs_buffer, FsBufferSize, std::addressof(bytes_received));
|
||||||
|
|
||||||
/* Write to the file. */
|
/* Write to the file. */
|
||||||
R_TRY(m_fs.FileWrite(std::addressof(file), offset, s_fs_buffer, bytes_received, 0));
|
R_TRY(m_fs.WriteFile(std::addressof(file), offset, s_fs_buffer, bytes_received, 0));
|
||||||
|
|
||||||
offset += bytes_received;
|
offset += bytes_received;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user