ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u32 size) const { std::string full_path = mount_point + path.AsString(); if (FileUtil::Exists(full_path)) return ResultCode(ErrorDescription::AlreadyExists, ErrorModule::FS, ErrorSummary::NothingHappened, ErrorLevel::Info); if (size == 0) { FileUtil::CreateEmptyFile(full_path); return RESULT_SUCCESS; } FileUtil::IOFile file(full_path, "wb"); // Creates a sparse file (or a normal file on filesystems without the concept of sparse files) // We do this by seeking to the right size, then writing a single null byte. if (file.Seek(size - 1, SEEK_SET) && file.WriteBytes("", 1) == 1) return RESULT_SUCCESS; return ResultCode(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource, ErrorLevel::Info); }
/** * Delete a directory specified by its path * @param path Path relative to the archive * @return Whether the directory could be deleted */ bool Archive_SDMC::DeleteDirectory(const FileSys::Path& path) const { return FileUtil::DeleteDir(GetMountPoint() + path.AsString()); }
bool Archive_SDMC::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); }