FS : FSUSER_OpenDirectory, FSUSER_OpenFile, FSDIR_Read
This commit is contained in:
parent
fce1a24dbf
commit
a8e5cb01f9
@ -31,9 +31,15 @@ typedef struct{
|
|||||||
Handle handleLow, handleHigh;
|
Handle handleLow, handleHigh;
|
||||||
}FS_archive;
|
}FS_archive;
|
||||||
|
|
||||||
|
static inline FS_path FS_makePath(FS_pathType type, char* path)
|
||||||
|
{
|
||||||
|
return (FS_path){type, strlen(path)+1, (u8*)path};
|
||||||
|
}
|
||||||
|
|
||||||
Result FSUSER_Initialize(Handle handle);
|
Result FSUSER_Initialize(Handle handle);
|
||||||
Result FSUSER_OpenArchive(Handle handle, FS_archive* archive);
|
Result FSUSER_OpenArchive(Handle handle, FS_archive* archive);
|
||||||
|
Result FSUSER_OpenDirectory(Handle handle, Handle* out, FS_archive archive, FS_path dirLowPath);
|
||||||
|
Result FSUSER_OpenFile(Handle handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
|
||||||
Result FSUSER_OpenFileDirectly(Handle handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
|
Result FSUSER_OpenFileDirectly(Handle handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
|
||||||
|
|
||||||
Result FSFILE_Close(Handle handle);
|
Result FSFILE_Close(Handle handle);
|
||||||
@ -41,4 +47,6 @@ Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, u32 *buffer, u32 s
|
|||||||
Result FSFILE_Write(Handle handle, u32 *bytesWritten, u64 offset, u32 *buffer, u32 size, u32 flushFlags);
|
Result FSFILE_Write(Handle handle, u32 *bytesWritten, u64 offset, u32 *buffer, u32 size, u32 flushFlags);
|
||||||
Result FSFILE_GetSize(Handle handle, u64 *size);
|
Result FSFILE_GetSize(Handle handle, u64 *size);
|
||||||
|
|
||||||
|
Result FSDIR_Read(Handle handle, u32 *entriesRead, u32 entrycount, u16 *buffer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,7 +17,30 @@ Result FSUSER_Initialize(Handle handle)
|
|||||||
return cmdbuf[1];
|
return cmdbuf[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
Result FSUSER_OpenFileDirectly(Handle handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes)
|
Result FSUSER_OpenFile(Handle handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes) //archive needs to have been opened
|
||||||
|
{
|
||||||
|
u32* cmdbuf=getThreadCommandBuffer();
|
||||||
|
|
||||||
|
cmdbuf[0]=0x080201C2;
|
||||||
|
cmdbuf[1]=0;
|
||||||
|
cmdbuf[2]=archive.handleLow;
|
||||||
|
cmdbuf[3]=archive.handleHigh;
|
||||||
|
cmdbuf[4]=fileLowPath.type;
|
||||||
|
cmdbuf[5]=fileLowPath.size;
|
||||||
|
cmdbuf[6]=openflags;
|
||||||
|
cmdbuf[7]=attributes;
|
||||||
|
cmdbuf[8]=(fileLowPath.size<<14)|2;
|
||||||
|
cmdbuf[9]=(u32)fileLowPath.data;
|
||||||
|
|
||||||
|
Result ret=0;
|
||||||
|
if((ret=svc_sendSyncRequest(handle)))return ret;
|
||||||
|
|
||||||
|
if(out)*out=cmdbuf[3];
|
||||||
|
|
||||||
|
return cmdbuf[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
Result FSUSER_OpenFileDirectly(Handle handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes) //no need to have archive opened
|
||||||
{
|
{
|
||||||
u32* cmdbuf=getThreadCommandBuffer();
|
u32* cmdbuf=getThreadCommandBuffer();
|
||||||
|
|
||||||
@ -64,6 +87,26 @@ Result FSUSER_OpenArchive(Handle handle, FS_archive* archive)
|
|||||||
return cmdbuf[1];
|
return cmdbuf[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result FSUSER_OpenDirectory(Handle handle, Handle* out, FS_archive archive, FS_path dirLowPath)
|
||||||
|
{
|
||||||
|
u32* cmdbuf=getThreadCommandBuffer();
|
||||||
|
|
||||||
|
cmdbuf[0]=0x080B0102;
|
||||||
|
cmdbuf[1]=archive.handleLow;
|
||||||
|
cmdbuf[2]=archive.handleHigh;
|
||||||
|
cmdbuf[3]=dirLowPath.type;
|
||||||
|
cmdbuf[4]=dirLowPath.size;
|
||||||
|
cmdbuf[5]=(dirLowPath.size<<14)|0x2;
|
||||||
|
cmdbuf[6]=(u32)dirLowPath.data;
|
||||||
|
|
||||||
|
Result ret=0;
|
||||||
|
if((ret=svc_sendSyncRequest(handle)))return ret;
|
||||||
|
|
||||||
|
if(out)*out=cmdbuf[3];
|
||||||
|
|
||||||
|
return cmdbuf[1];
|
||||||
|
}
|
||||||
|
|
||||||
Result FSFILE_Close(Handle handle)
|
Result FSFILE_Close(Handle handle)
|
||||||
{
|
{
|
||||||
u32* cmdbuf=getThreadCommandBuffer();
|
u32* cmdbuf=getThreadCommandBuffer();
|
||||||
@ -130,3 +173,20 @@ Result FSFILE_GetSize(Handle handle, u64 *size)
|
|||||||
|
|
||||||
return cmdbuf[1];
|
return cmdbuf[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result FSDIR_Read(Handle handle, u32 *entriesRead, u32 entrycount, u16 *buffer)
|
||||||
|
{
|
||||||
|
u32 *cmdbuf=getThreadCommandBuffer();
|
||||||
|
|
||||||
|
cmdbuf[0]=0x08010042;
|
||||||
|
cmdbuf[1]=entrycount;
|
||||||
|
cmdbuf[2]=((entrycount*0x228)<<4)|0xC;
|
||||||
|
cmdbuf[3]=(u32)buffer;
|
||||||
|
|
||||||
|
Result ret=0;
|
||||||
|
if((ret=svc_sendSyncRequest(handle)))return ret;
|
||||||
|
|
||||||
|
if(entriesRead)*entriesRead=cmdbuf[2];
|
||||||
|
|
||||||
|
return cmdbuf[1];
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user