mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-22 19:05:08 -04:00
tio: implement server/dispatch logic.
This commit is contained in:
parent
cee1ecd06f
commit
6ce2076d92
8 changed files with 634 additions and 2 deletions
48
stratosphere/TioServer/source/tio_file_server_processor.hpp
Normal file
48
stratosphere/TioServer/source/tio_file_server_processor.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
#include "tio_file_server_htcs_server.hpp"
|
||||
#include "tio_file_server_packet.hpp"
|
||||
|
||||
namespace ams::tio {
|
||||
|
||||
class FileServerProcessor {
|
||||
private:
|
||||
bool m_is_inserted{};
|
||||
bool m_is_mounted{};
|
||||
size_t m_request_buffer_size{};
|
||||
FileServerHtcsServer &m_htcs_server;
|
||||
size_t m_open_file_count{};
|
||||
size_t m_open_directory_count{};
|
||||
fs::FileHandle m_files[0x80]{};
|
||||
fs::DirectoryHandle m_directories[0x80]{};
|
||||
os::SdkMutex m_fs_mutex{};
|
||||
os::SdkMutex m_mutex{};
|
||||
public:
|
||||
constexpr FileServerProcessor(FileServerHtcsServer &htcs_server) : m_htcs_server(htcs_server) { /* ... */ }
|
||||
|
||||
void SetInserted(bool ins) { m_is_inserted = ins; }
|
||||
void SetRequestBufferSize(size_t size) { m_request_buffer_size = size; }
|
||||
public:
|
||||
bool ProcessRequest(FileServerRequestHeader *header, u8 *body, int socket);
|
||||
|
||||
void Unmount();
|
||||
private:
|
||||
bool SendResponse(const FileServerResponseHeader &header, const void *body, int socket);
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue