mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
FileSys/Kernel: Implement SetSize service call for File objects.
This commit is contained in:
parent
d34673990b
commit
23c2fbfc7a
|
@ -43,6 +43,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual size_t GetSize() const = 0;
|
virtual size_t GetSize() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the file in bytes
|
||||||
|
* @param size New size of the file
|
||||||
|
* @return true if successful
|
||||||
|
*/
|
||||||
|
virtual bool SetSize(const u64 size) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the file
|
* Close the file
|
||||||
* @return true if the file closed correctly
|
* @return true if the file closed correctly
|
||||||
|
|
|
@ -48,6 +48,15 @@ size_t File_RomFS::GetSize() const {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the file in bytes
|
||||||
|
* @param size New size of the file
|
||||||
|
* @return true if successful
|
||||||
|
*/
|
||||||
|
bool File_RomFS::SetSize(const u64 size) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the file
|
* Close the file
|
||||||
* @return true if the file closed correctly
|
* @return true if the file closed correctly
|
||||||
|
|
|
@ -44,6 +44,13 @@ public:
|
||||||
*/
|
*/
|
||||||
size_t GetSize() const override;
|
size_t GetSize() const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the file in bytes
|
||||||
|
* @param size New size of the file
|
||||||
|
* @return true if successful
|
||||||
|
*/
|
||||||
|
bool SetSize(const u64 size) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the file
|
* Close the file
|
||||||
* @return true if the file closed correctly
|
* @return true if the file closed correctly
|
||||||
|
|
|
@ -75,6 +75,17 @@ size_t File_SDMC::GetSize() const {
|
||||||
return static_cast<size_t>(file->GetSize());
|
return static_cast<size_t>(file->GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the file in bytes
|
||||||
|
* @param size New size of the file
|
||||||
|
* @return true if successful
|
||||||
|
*/
|
||||||
|
bool File_SDMC::SetSize(const u64 size) const {
|
||||||
|
file->Resize(size);
|
||||||
|
file->Flush();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the file
|
* Close the file
|
||||||
* @return true if the file closed correctly
|
* @return true if the file closed correctly
|
||||||
|
|
|
@ -47,6 +47,13 @@ public:
|
||||||
*/
|
*/
|
||||||
size_t GetSize() const override;
|
size_t GetSize() const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the file in bytes
|
||||||
|
* @param size New size of the file
|
||||||
|
* @return true if successful
|
||||||
|
*/
|
||||||
|
bool SetSize(const u64 size) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the file
|
* Close the file
|
||||||
* @return true if the file closed correctly
|
* @return true if the file closed correctly
|
||||||
|
|
|
@ -181,6 +181,14 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case FileCommand::SetSize:
|
||||||
|
{
|
||||||
|
u64 size = cmd_buff[1] | ((u64)cmd_buff[2] << 32);
|
||||||
|
DEBUG_LOG(KERNEL, "SetSize %s %s size=%d", GetTypeName().c_str(), GetName().c_str(), size);
|
||||||
|
backend->SetSize(size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case FileCommand::Close:
|
case FileCommand::Close:
|
||||||
{
|
{
|
||||||
DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
|
DEBUG_LOG(KERNEL, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
|
||||||
|
|
Loading…
Reference in a new issue