RASCSI/src/raspberrypi/rascsi/rascsi_image.h
Uwe Seimet f3553c5480
Resolved issues 772, 827, 909; added numerous unit tests; code cleanup (#915)
* Resolved issues 772, 827, 909

* Added numerous unit tests

* Code cleanup

* Improved type safety by using PbDeviceType instead of string

* Do not flush cache on failed STOP UNIT

* Error message and error handling updates

* Removed duplicate code

* Use map for mapping shift counts

* Reject read/write access if the drive has 0 sectors

* Updated logging configuration for tests
2022-10-23 21:51:39 +02:00

51 lines
1.5 KiB
C++

//---------------------------------------------------------------------------
//
// SCSI Target Emulator RaSCSI Reloaded
// for Raspberry Pi
//
// Copyright (C) 2021-2022 Uwe Seimet
//
//---------------------------------------------------------------------------
#pragma once
#include "rascsi_interface.pb.h"
#include "command_context.h"
#include <string>
using namespace std;
using namespace rascsi_interface;
class RascsiImage
{
public:
RascsiImage();
~RascsiImage() = default;
void SetDepth(int d) { depth = d; }
int GetDepth() const { return depth; }
string GetDefaultFolder() const { return default_folder; }
string SetDefaultFolder(const string&);
bool CreateImage(const CommandContext&, const PbCommand&) const;
bool DeleteImage(const CommandContext&, const PbCommand&) const;
bool RenameImage(const CommandContext&, const PbCommand&) const;
bool CopyImage(const CommandContext&, const PbCommand&) const;
bool SetImagePermissions(const CommandContext&, const PbCommand&) const;
private:
bool CheckDepth(string_view) const;
string GetFullName(const string& filename) const { return default_folder + "/" + filename; }
bool CreateImageFolder(const CommandContext&, const string&) const;
bool ValidateParams(const CommandContext&, const PbCommand&, const string&, string&, string&) const;
static bool IsValidSrcFilename(const string&);
static bool IsValidDstFilename(const string&);
static string GetHomeDir();
string default_folder;
int depth = 1;
};