mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-01 13:51:43 +00:00
41bdcd4aed
* Update logging * Remove duplicate code * Update unit tests * Clean up includes * Merge ProtobufSerializer into protobuf_util namespace * Precompile regex * Add const * Add Split() convenience method, update log level/ID parsing * Move log.h to legacy folder * Elimininate gotos * Fixes for gcc 13 * Update compiler flags * Update default folder handling * Use references instead of pointers * Move code for better encapsulation * Move code * Remove unused method argument * Move device logger * Remove redundant to_string * Rename for consistency * Update handling of protobuf pointers * Simplify protobuf usage * Memory handling update * Add hasher
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2021-2023 Uwe Seimet
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "generated/piscsi_interface.pb.h"
|
|
#include "command_context.h"
|
|
#include <string>
|
|
#include <filesystem>
|
|
|
|
using namespace std;
|
|
using namespace filesystem;
|
|
using namespace piscsi_interface;
|
|
|
|
class PiscsiImage
|
|
{
|
|
public:
|
|
|
|
PiscsiImage();
|
|
~PiscsiImage() = default;
|
|
|
|
void SetDepth(int d) { depth = d; }
|
|
int GetDepth() const { return depth; }
|
|
string GetDefaultFolder() const { return default_folder; }
|
|
string SetDefaultFolder(string_view);
|
|
bool CreateImage(const CommandContext&) const;
|
|
bool DeleteImage(const CommandContext&) const;
|
|
bool RenameImage(const CommandContext&) const;
|
|
bool CopyImage(const CommandContext&) const;
|
|
bool SetImagePermissions(const CommandContext&) const;
|
|
|
|
private:
|
|
|
|
bool CheckDepth(string_view) const;
|
|
string GetFullName(const string& filename) const { return default_folder + "/" + filename; }
|
|
bool CreateImageFolder(const CommandContext&, string_view) const;
|
|
static bool IsReservedFile(const CommandContext&, const string&, const string&);
|
|
bool ValidateParams(const CommandContext&, const string&, string&, string&) const;
|
|
|
|
static bool IsValidSrcFilename(string_view);
|
|
static bool IsValidDstFilename(string_view);
|
|
static bool ChangeOwner(const CommandContext&, const path&, bool);
|
|
static string GetHomeDir();
|
|
static pair<int, int> GetUidAndGid();
|
|
|
|
string default_folder;
|
|
|
|
int depth = 1;
|
|
};
|