ACC SHELL

Path : /usr/share/YaST2/include/partitioning/
File Upload :
Current File : //usr/share/YaST2/include/partitioning/ep-loop-lib.ycp

/**
 * File:	ep-loop-lib.ycp
 * Package:	yast2-storage
 * Summary:	Expert Partitioner
 * Authors:	Arvin Schnell <aschnell@suse.de>
 *
 * This file must only be included in other Expert Partitioner files ("ep-*.ycp").
 */
{
    textdomain "storage";


    void EpCreateLoop()
    {
	map<string, any> data = $[ "new" : true,
				   "create" : true ];

	data["type"] = `loop;
	data["format"] = true;

	if (DlgCreateLoop(data))
	{
	    string device = Storage::CreateLoop(data["fpath"]:"", data["create_file"]:false,
						data["size_k"]:0, data["mount"]:"");
	    data["device"] = device;

	    Storage::ChangeVolumeProperties(data);

	    UpdateMainStatus();
	    UpdateNavigationTree(nil);
	    TreePanel::Create();
	    UpdateTableFocus(device);
	}
    }


    void EpEditLoop(string device)
    {
	if (device == nil)
	{
	    Popup::Error(_("No crypt file selected."));
	    return;
	}

	map<string, map> target_map = Storage::GetTargetMap();
	map<string, any> data = Storage::GetPartition(target_map, device);

	if (!isempty(data["used_by"]:[]))
	{
	    // error popup, %1 is replaced by device name
	    Popup::Error(sformat(_("The Crypt File %1 is in use. It cannot be
edited. To edit %1, make sure it is not used."), device));
	    return;
	}

	if (DlgEditLoop(data))
	{
	    Storage::ChangeVolumeProperties(data);

	    UpdateMainStatus();
	    UpdateNavigationTree(nil);
	    TreePanel::Create();
	    UpdateTableFocus(device);
	}
    }


    void EpDeleteLoop(string device)
    {
	if (device == nil)
	{
	    // error popup
	    Popup::Error(_("No crypt file selected."));
	    return;
	}

	if (EpDeleteDevice(device))
	{
	    UpdateMainStatus();
	    UpdateNavigationTree(`loop);
	    TreePanel::Create();
	}
    }
}

ACC SHELL 2018