mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-01 13:51:43 +00:00
52c2aa474f
* Rebrand project to PiSCSI - rascsi ->piscsi - rasctl -> scsictl - rasdump -> scsidump - ras* -> piscsi* (rasutil -> piscsi_util, etc.) * Refined the formatting and wording of the app startup banner * Kept some references to rascsi and rasctl where backwards compatibility is concerned * Point to the new github repo URL Co-authored-by: nucleogenic <nr@nucleogenic.com> Co-authored-by: Uwe Seimet <Uwe.Seimet@seimet.de>
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2021-2022 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(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 bool ChangeOwner(const CommandContext&, const path&, bool);
|
|
static string GetHomeDir();
|
|
static pair<int, int> GetUidAndGid();
|
|
|
|
string default_folder;
|
|
|
|
int depth = 1;
|
|
};
|