#include "fcb_inc_prot"

//==========================================/
void set_main_folder_index_start(int folder_index)
//==========================================/
    {
    SetLocalInt(FCB_HOST, MAIN_FOLDER_INDEX, folder_index);
    }

//==========================================/
int create_main_folder(string folder_index_link = "")
//==========================================/
    {
    int folder_index = GetLocalInt(FCB_HOST, MAIN_FOLDER_INDEX) + INCR_F10;
    SetLocalInt(FCB_HOST, MAIN_FOLDER_INDEX, folder_index);

    if(folder_index_link != "")
        {
        SetLocalInt(FCB_HOST, MAIN_FOLDER_INDEX_LINK_ + folder_index_link, folder_index);
        }
    return folder_index;
    }

//==========================================/
int create_main_file_type_link(int folder_target, int file_type_alternate = 0)
//==========================================/
    {
    if(folder_target > 0)
        {
        return INCR_LINK | folder_target;
        }
    else
        {
        return file_type_alternate;
        }
    }

//==========================================/
int create_main_file_int(int folder_index, string file_name, int file_type, int file_param = 0)
//==========================================/
    {
    //file_dir: [...][folder_index: 10][file_index: 10]
    int file_dir = folder_index | GetLocalInt(FCB_HOST, MAIN_FILE_INDEX_ + IntToHexString(folder_index))+1;
    SetLocalInt(FCB_HOST, MAIN_FILE_INDEX_ + IntToHexString(folder_index), file_dir);

    SetLocalString(FCB_HOST, MAIN_FILE_NAME_ + IntToHexString(file_dir), file_name);

    SetLocalInt(FCB_HOST, MAIN_FILE_TYPE_ + IntToHexString(file_dir), file_type);
    //file_param: data to hold
    SetLocalInt(FCB_HOST, MAIN_FILE_PARAM_ + IntToHexString(file_dir), file_param);

    return file_dir;
    }

//==========================================/
int create_main_file_str(int folder_index, string file_name, int file_type, string file_param = "")
//==========================================/
    {
    //file_dir: [...][folder_index: 10][file_index: 10]
    int file_dir = folder_index | GetLocalInt(FCB_HOST, MAIN_FILE_INDEX_ + IntToHexString(folder_index))+1;
    SetLocalInt(FCB_HOST, MAIN_FILE_INDEX_ + IntToHexString(folder_index), file_dir);

    SetLocalString(FCB_HOST, MAIN_FILE_NAME_ + IntToHexString(file_dir), file_name);

    SetLocalInt(FCB_HOST, MAIN_FILE_TYPE_ + IntToHexString(file_dir), file_type);
    //file_param: data to hold
    SetLocalString(FCB_HOST, MAIN_FILE_PARAM_ + IntToHexString(file_dir), file_param);

    return file_dir;
    }

//==========================================/
int create_main_file_obj(int folder_index, string file_name, int file_type, object file_param = OBJECT_INVALID)
//==========================================/
    {
    //file_dir: [...][folder_index: 10][file_index: 10]
    int file_dir = folder_index | GetLocalInt(FCB_HOST, MAIN_FILE_INDEX_ + IntToHexString(folder_index))+1;
    SetLocalInt(FCB_HOST, MAIN_FILE_INDEX_ + IntToHexString(folder_index), file_dir);

    SetLocalString(FCB_HOST, MAIN_FILE_NAME_ + IntToHexString(file_dir), file_name);

    SetLocalInt(FCB_HOST, MAIN_FILE_TYPE_ + IntToHexString(file_dir), file_type);
    //file_param: data to hold
    SetLocalObject(FCB_HOST, MAIN_FILE_PARAM_ + IntToHexString(file_dir), file_param);

    return file_dir;
    }
