Advertisement
Guest User

PersistCar

a guest
Apr 21st, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2.  
  3. #include "common.hpp"
  4. #include "natives.hpp"
  5. #include "VehicleHelper.h"
  6. #include "ModelAttachment.h"
  7.  
  8. namespace big
  9. {
  10.     class persistcar
  11.     {
  12.     public:
  13.         static void save_vehicle(Vehicle vehicle, std::string file_name)
  14.         {
  15.             if (ENTITY::DOES_ENTITY_EXIST(vehicle) == FALSE || ENTITY::IS_ENTITY_A_VEHICLE(vehicle) == FALSE)
  16.             {
  17.                 LOG_ERROR("Persist Car was passed an incorrect entity");
  18.                 return;
  19.             }
  20.  
  21.             auto file_path = check_vehicle_folder();
  22.             file_path /= file_name;
  23.             std::ofstream file(file_path, std::ios::out | std::ios::trunc);
  24.             file << get_full_vehicle_json(vehicle).dump(4);
  25.             file.close();
  26.         }
  27.  
  28.         static Vehicle load_vehicle(std::string file_name)
  29.         {
  30.             auto file_path = check_vehicle_folder();
  31.             file_path /= file_name;
  32.             std::ifstream file(file_path);
  33.  
  34.             nlohmann::json vehicle_json;
  35.             file >> vehicle_json;
  36.             file.close();
  37.  
  38.             return spawn_vehicle_full(vehicle_json, PLAYER::PLAYER_PED_ID());
  39.         }
  40.  
  41.         static std::vector<std::string> list_files()
  42.         {
  43.             auto file_path = check_vehicle_folder();
  44.             std::vector<std::string> return_value;
  45.             for (const auto& p : std::filesystem::directory_iterator(file_path))
  46.                 if (p.path().extension() == ".json")
  47.                     return_value.push_back(p.path().filename().generic_string());
  48.             return return_value;
  49.         }
  50.  
  51.         static Vehicle clone_ped_car(Ped ped)
  52.         {
  53.             if (PED::IS_PED_IN_ANY_VEHICLE(ped, FALSE))
  54.                 return spawn_vehicle_full(get_full_vehicle_json(PED::GET_VEHICLE_PED_IS_IN(ped, FALSE)), ped);
  55.             return NULL;
  56.         }
  57.  
  58.     private:
  59.         static Vehicle spawn_vehicle_full(nlohmann::json vehicle_json, Ped ped)
  60.         {
  61.             Vehicle vehicle = spawn_vehicle(vehicle_json, ped);
  62.             if (!vehicle_json["Tow"].is_null())
  63.             {
  64.                 Vehicle tow = spawn_vehicle(vehicle_json["Tow"], ped);
  65.                 auto pos = ENTITY::GET_ENTITY_COORDS(tow, true);
  66.                 pos.x -= 10;
  67.                 ENTITY::SET_ENTITY_COORDS_NO_OFFSET(tow, pos.x, 0.f, 0.f, TRUE, FALSE, FALSE);
  68.                 VEHICLE::ATTACH_VEHICLE_TO_TOW_TRUCK(vehicle, tow, -1, 0.f, 0.f, 0.f);
  69.                 VEHICLE::_SET_TOW_TRUCK_CRANE_HEIGHT(vehicle, 1.f);
  70.                 VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(tow);
  71.             }
  72.             else if(!vehicle_json["Trailer"].is_null())
  73.             {
  74.                 Vehicle trailer = spawn_vehicle(vehicle_json["Trailer"], ped);
  75.                 VEHICLE::ATTACH_VEHICLE_TO_TRAILER(vehicle, trailer, 1.0f);
  76.                 VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(trailer);
  77.             }
  78.             VEHICLE::SET_VEHICLE_ON_GROUND_PROPERLY(vehicle);
  79.             return vehicle;
  80.         }
  81.  
  82.         static Vehicle spawn_vehicle(nlohmann::json vehicle_json, Ped ped)
  83.         {
  84.             Vehicle vehicle = spawn_vehicle_json(vehicle_json, ped);
  85.             std::vector<nlohmann::json> model_attachments = vehicle_json["Model Attachments"];
  86.             for (nlohmann::json model_attachment : model_attachments)
  87.             {
  88.                 auto attachment = model_attachment.get<model_attachment::model_attachment>();
  89.                 STREAMING::REQUEST_MODEL(attachment.model_hash);
  90.                 Object object = OBJECT::CREATE_OBJECT(attachment.model_hash, 0, 0, 0, TRUE, FALSE, FALSE);
  91.                 ENTITY::ATTACH_ENTITY_TO_ENTITY(object, vehicle, 0, attachment.position.x, attachment.position.y, attachment.position.z, attachment.rotation.x, attachment.rotation.y, attachment.rotation.z, false, false, false, false, 0, true);
  92.                 STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(attachment.model_hash);
  93.             }
  94.             std::vector<nlohmann::json> vehicle_attachments = vehicle_json["Vehicle Attachments"];
  95.             for (nlohmann::json vehicle_attachment : vehicle_attachments)
  96.             {
  97.                 Vehicle vehicle_to_attach = spawn_vehicle_json(vehicle_attachment["Vehicle"], ped);
  98.                 auto attachment = vehicle_attachment["Model Attachment"].get<model_attachment::model_attachment>();
  99.                 ENTITY::ATTACH_ENTITY_TO_ENTITY(vehicle_to_attach, vehicle, 0, attachment.position.x, attachment.position.y, attachment.position.z, attachment.rotation.x, attachment.rotation.y, attachment.rotation.z, false, false, false, false, 0, true);
  100.                 VEHICLE::SET_VEHICLE_IS_CONSIDERED_BY_PLAYER(vehicle_to_attach, false);
  101.             }
  102.             return vehicle;
  103.         }
  104.  
  105.         static Vehicle spawn_vehicle_json(nlohmann::json vehicle_json, Ped ped)
  106.         {
  107.             Hash vehicle_hash = vehicle_json["Vehicle Model Hash"];
  108.  
  109.             auto pos = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
  110.             Vehicle vehicle = CreateVehicle(vehicle_hash, pos.x, pos.y, pos.z, ENTITY::GET_ENTITY_HEADING(ped));
  111.             VEHICLE::SET_VEHICLE_DIRT_LEVEL(vehicle, 0.0f);
  112.             VEHICLE::SET_VEHICLE_MOD_KIT(vehicle, 0);
  113.             VEHICLE::SET_VEHICLE_TYRES_CAN_BURST(vehicle, FALSE);
  114.             VEHICLE::SET_VEHICLE_COLOURS(vehicle, vehicle_json["Primary Color"], vehicle_json["Secondary Color"]);
  115.             if (!vehicle_json["Custom Primary Color"].is_null())
  116.             {
  117.                 std::vector<int> primary_custom_color = vehicle_json["Custom Primary Color"];
  118.                 VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, primary_custom_color[0], primary_custom_color[1], primary_custom_color[2]);
  119.             }
  120.             if (!vehicle_json["Custom Secondary Color"].is_null())
  121.             {
  122.                 std::vector<int> secondary_custom_color = vehicle_json["Custom Secondary Color"];
  123.                 VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(vehicle, secondary_custom_color[0], secondary_custom_color[1], secondary_custom_color[2]);
  124.             }
  125.             VEHICLE::SET_VEHICLE_WINDOW_TINT(vehicle, vehicle_json["Vehicle Window Tint"]);
  126.             if (!vehicle_json["Radio Station"].is_null())
  127.                 AUDIO::SET_VEH_RADIO_STATION(vehicle, vehicle_json["Radio Station"].get<std::string>().c_str());
  128.             VEHICLE::SET_VEHICLE_NUMBER_PLATE_TEXT(vehicle, vehicle_json["Plate Text"].get<std::string>().c_str());
  129.             VEHICLE::SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehicle, vehicle_json["Plate Text Index"]);
  130.             VEHICLE::SET_VEHICLE_EXTRA_COLOURS(vehicle, vehicle_json["Pearlescent Color"], vehicle_json["Wheel Color"]);
  131.             std::map<int, bool> vehicle_extras = vehicle_json["Vehicle Extras"];
  132.             for (int i = 0; i <= 20; i++)
  133.             {
  134.                 if (VEHICLE::DOES_EXTRA_EXIST(vehicle, i))
  135.                     VEHICLE::SET_VEHICLE_EXTRA(vehicle, i, vehicle_extras[i]);
  136.             }
  137.             if (!vehicle_json["Vehicle Livery"].is_null())
  138.             {
  139.                 VEHICLE::SET_VEHICLE_LIVERY(vehicle, vehicle_json["Vehicle Livery"]);
  140.             }
  141.             if (VEHICLE::IS_THIS_MODEL_A_CAR(ENTITY::GET_ENTITY_MODEL(vehicle)) == TRUE || VEHICLE::IS_THIS_MODEL_A_BIKE(ENTITY::GET_ENTITY_MODEL(vehicle)))
  142.             {
  143.                 VEHICLE::SET_VEHICLE_WHEEL_TYPE(vehicle, vehicle_json["Wheel Type"]);
  144.                 for (int i = MOD_SPOILERS; i <= MOD_LIVERY; i++)
  145.                 {
  146.                     BOOL bModOn = !vehicle_json[mod_names[i]].is_null();
  147.                     if (bModOn == TRUE)
  148.                     {
  149.                         if (i == MOD_TIRESMOKE)
  150.                         {
  151.                             std::vector<int> tire_smoke_color = vehicle_json["Tire Smoke Color"];
  152.                             VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, tire_smoke_color[0], tire_smoke_color[1], tire_smoke_color[2]);
  153.                             VEHICLE::TOGGLE_VEHICLE_MOD(vehicle, MOD_TIRESMOKE, TRUE);
  154.                         }
  155.                         else if (vehicle_json[mod_names[i]].is_array())
  156.                         {
  157.                             std::vector<int> mod = vehicle_json[mod_names[i]];
  158.                             VEHICLE::SET_VEHICLE_MOD(vehicle, i, mod[0], mod[1]);
  159.                         }
  160.                         else
  161.                         {
  162.                             VEHICLE::TOGGLE_VEHICLE_MOD(vehicle, i, TRUE);
  163.                         }
  164.                     }
  165.                 }
  166.                 std::vector<bool> neon_lights = vehicle_json["Neon Lights"];
  167.                 for (int i = NEON_LEFT; i <= NEON_BACK; i++)
  168.                     VEHICLE::_SET_VEHICLE_NEON_LIGHT_ENABLED(vehicle, i, neon_lights[i]);
  169.                 std::vector<int> neon_color = vehicle_json["Neon Color"];
  170.                 VEHICLE::_SET_VEHICLE_NEON_LIGHTS_COLOUR(vehicle, neon_color[0], neon_color[1], neon_color[2]);
  171.                 if (VEHICLE::IS_VEHICLE_A_CONVERTIBLE(vehicle, 0))
  172.                 {
  173.                     int convertableState = vehicle_json["Convertable State"];
  174.                     if (convertableState == 0 || convertableState == 3 || convertableState == 5)
  175.                         VEHICLE::RAISE_CONVERTIBLE_ROOF(vehicle, TRUE);
  176.                     else
  177.                         VEHICLE::LOWER_CONVERTIBLE_ROOF(vehicle, TRUE);
  178.                 }
  179.                 VEHICLE::SET_VEHICLE_INTERIOR_COLOUR(vehicle, vehicle_json["Interior Color"]);
  180.                 VEHICLE::SET_VEHICLE_DASHBOARD_COLOUR(vehicle, vehicle_json["Dash Color"]);
  181.                 if (vehicle_json["Clan Logo"] == TRUE)
  182.                     AddClanLogoToVehicle(vehicle, ped);
  183.                 VEHICLE::SET_VEHICLE_HEADLIGHT_COLOUR(vehicle, vehicle_json["Headlight Color"]);
  184.             }
  185.             return vehicle;
  186.         }
  187.  
  188.         static nlohmann::json get_full_vehicle_json(Vehicle vehicle)
  189.         {
  190.             nlohmann::json vehicle_json = get_vehicle_json(vehicle);
  191.             vehicle_json["Model Attachments"] = get_model_attachments(vehicle);
  192.             Vehicle tow = VEHICLE::GET_ENTITY_ATTACHED_TO_TOW_TRUCK(vehicle);
  193.             if (ENTITY::DOES_ENTITY_EXIST(tow))
  194.             {
  195.                 vehicle_json["Tow"] = get_vehicle_json(tow);
  196.                 vehicle_json["Tow"]["Model Attachments"] = get_model_attachments(tow, true);
  197.                 vehicle_json["Tow"]["Vehicle Attachments"] = get_vehicle_attachents(tow, true);
  198.                 vehicle_json["Vehicle Attachments"] = std::vector<nlohmann::json>();
  199.             }
  200.             else
  201.             {
  202.                 vehicle_json["Vehicle Attachments"] = get_vehicle_attachents(vehicle);
  203.             }
  204.             if (VEHICLE::IS_VEHICLE_ATTACHED_TO_TRAILER(vehicle))
  205.             {
  206.                 Vehicle trailer;
  207.                 VEHICLE::GET_VEHICLE_TRAILER_VEHICLE(vehicle, &trailer);
  208.                 vehicle_json["Trailer"] = get_vehicle_json(trailer);
  209.                 vehicle_json["Trailer"]["Model Attachments"] = get_model_attachments(trailer);
  210.                 vehicle_json["Trailer"]["Vehicle Attachments"] = get_vehicle_attachents(trailer);
  211.             }
  212.             return vehicle_json;
  213.         }
  214.  
  215.         static model_attachment::model_attachment get_model_attachment(Vehicle vehicle, Object object)
  216.         {
  217.             Vector3 object_location = ENTITY::GET_ENTITY_COORDS(object, 0);
  218.             Vector3 location = ENTITY::GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS(vehicle, object_location.x, object_location.y, object_location.z);
  219.             Vector3 object_rotation = ENTITY::GET_ENTITY_ROTATION(object, 0);
  220.             Vector3 vehicle_rotation = ENTITY::GET_ENTITY_ROTATION(vehicle, 0);
  221.             Vector3 rotation;
  222.             rotation.x = (object_rotation.x - vehicle_rotation.x);
  223.             rotation.y = (object_rotation.y - vehicle_rotation.y);
  224.             rotation.z = (object_rotation.z - vehicle_rotation.z);
  225.             model_attachment::model_attachment attachment = { ENTITY::GET_ENTITY_MODEL(object), location, rotation };
  226.             return attachment;
  227.         }
  228.  
  229.         static nlohmann::json get_model_attachments(Vehicle vehicle, bool is_towed_vehicle = false)
  230.         {
  231.             std::vector<nlohmann::json> attached_objects;
  232.             rage::CObjectInterface* objIF = g_pointers->m_replay_interface->pCObjectInterface;
  233.             int numObj = objIF->iMaxObjects;
  234.             for (int i = 0; i < numObj; i++)
  235.             {
  236.                 rage::CObject* pCObject = objIF->get_object(i);
  237.                 if (pCObject == nullptr)
  238.                     continue;
  239.  
  240.                 Object object = g_pointers->m_ptr_to_handle(pCObject);
  241.                 if (object == 0)
  242.                     break;
  243.  
  244.                 if (!ENTITY::IS_ENTITY_ATTACHED_TO_ENTITY(vehicle, object))
  245.                     continue;
  246.  
  247.                 if (is_towed_vehicle && ENTITY::GET_ENTITY_MODEL(object) == 0xBC344305) //Don't save tow hook.
  248.                     continue;
  249.  
  250.                 attached_objects.push_back(get_model_attachment(vehicle, object));
  251.             };
  252.             return attached_objects;
  253.         }
  254.  
  255.         static nlohmann::json get_vehicle_attachents(Vehicle vehicle, bool is_towed_vehicle = false)
  256.         {
  257.             Vehicle trailer;
  258.             VEHICLE::GET_VEHICLE_TRAILER_VEHICLE(vehicle, &trailer);
  259.             std::vector<nlohmann::json> attached_vehicles;
  260.             rage::CVehicleInterface* vehicle_interface = g_pointers->m_replay_interface->pCVehicleInterface;
  261.             for (int i = 0; i < vehicle_interface->iMaxVehicles; i++)
  262.             {
  263.                 auto* vehicle_ptr = vehicle_interface->get_vehicle(i);
  264.                 if (vehicle_ptr == nullptr)
  265.                     continue;
  266.  
  267.                 Vehicle object = g_pointers->m_ptr_to_handle((rage::CObject*)vehicle_ptr);
  268.                 if (object == 0)
  269.                     break;
  270.  
  271.                 if (!ENTITY::IS_ENTITY_ATTACHED_TO_ENTITY(vehicle, object))
  272.                     continue;
  273.  
  274.                 if (is_towed_vehicle)
  275.                 {
  276.                     if (VEHICLE::IS_VEHICLE_ATTACHED_TO_TOW_TRUCK(object, vehicle))
  277.                         continue;
  278.                 }
  279.                 else
  280.                 {
  281.                     if (object == trailer || VEHICLE::IS_VEHICLE_ATTACHED_TO_TRAILER(object))
  282.                         continue;
  283.                 }
  284.  
  285.                 nlohmann::json model_attachment;
  286.                 model_attachment["Vehicle"] = get_vehicle_json(object);
  287.                 model_attachment["Model Attachment"] = get_model_attachment(vehicle, object);
  288.                 attached_vehicles.push_back(model_attachment);
  289.             }
  290.             return attached_vehicles;
  291.         }
  292.  
  293.         static nlohmann::json get_vehicle_json(Vehicle vehicle)
  294.         {
  295.             nlohmann::json vehicle_json;
  296.  
  297.             vehicle_json["Vehicle Model Hash"] = ENTITY::GET_ENTITY_MODEL(vehicle);
  298.             int primary_color, secondary_color;
  299.             VEHICLE::GET_VEHICLE_COLOURS(vehicle, &primary_color, &secondary_color);
  300.             vehicle_json["Primary Color"] = primary_color;
  301.             vehicle_json["Secondary Color"] = secondary_color;
  302.             if (VEHICLE::GET_IS_VEHICLE_PRIMARY_COLOUR_CUSTOM(vehicle))
  303.             {
  304.                 int custom_primary_color[3]{};
  305.                 VEHICLE::GET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, &custom_primary_color[0], &custom_primary_color[1], &custom_primary_color[2]);
  306.                 vehicle_json["Custom Primary Color"] = custom_primary_color;
  307.             }
  308.             if (VEHICLE::GET_IS_VEHICLE_SECONDARY_COLOUR_CUSTOM(vehicle))
  309.             {
  310.                 int custom_secondary_color[3]{};
  311.                 VEHICLE::GET_VEHICLE_CUSTOM_SECONDARY_COLOUR(vehicle, &custom_secondary_color[0], &custom_secondary_color[1], &custom_secondary_color[2]);
  312.                 vehicle_json["Custom Secondary Color"] = custom_secondary_color;
  313.             }
  314.             vehicle_json["Vehicle Window Tint"] = VEHICLE::GET_VEHICLE_WINDOW_TINT(vehicle);
  315.             auto radio_station = AUDIO::GET_PLAYER_RADIO_STATION_NAME();
  316.             if (radio_station == nullptr)
  317.                 radio_station = "OFF";
  318.             vehicle_json["Radio Station"] = radio_station;
  319.             vehicle_json["Plate Text"] = VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT(vehicle);
  320.             vehicle_json["Plate Text Index"] = VEHICLE::GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(vehicle);
  321.             int pearlescent_color, wheel_color;
  322.             VEHICLE::GET_VEHICLE_EXTRA_COLOURS(vehicle, &pearlescent_color, &wheel_color);
  323.             vehicle_json["Pearlescent Color"] = pearlescent_color;
  324.             vehicle_json["Wheel Color"] = wheel_color;
  325.             std::map<int,bool> vehicle_extras;
  326.             for (int i = 0; i <= 20; i++)
  327.             {
  328.                 if (VEHICLE::DOES_EXTRA_EXIST(vehicle, i))
  329.                     vehicle_extras[i] = !VEHICLE::IS_VEHICLE_EXTRA_TURNED_ON(vehicle, i);
  330.             }
  331.             vehicle_json["Vehicle Extras"] = vehicle_extras;
  332.             if ((VEHICLE::GET_VEHICLE_LIVERY_COUNT(vehicle) > 1) && VEHICLE::GET_VEHICLE_LIVERY(vehicle) >= 0)
  333.             {
  334.                 vehicle_json["Vehicle Livery"] = VEHICLE::GET_VEHICLE_LIVERY(vehicle);
  335.             }
  336.             if (VEHICLE::IS_THIS_MODEL_A_CAR(ENTITY::GET_ENTITY_MODEL(vehicle)) == TRUE || VEHICLE::IS_THIS_MODEL_A_BIKE(ENTITY::GET_ENTITY_MODEL(vehicle)))
  337.             {
  338.                 vehicle_json["Wheel Type"] = VEHICLE::GET_VEHICLE_WHEEL_TYPE(vehicle);
  339.                 for (int i = MOD_SPOILERS; i <= MOD_LIVERY; i++)
  340.                 {
  341.                     BOOL is_mod_on = VEHICLE::IS_TOGGLE_MOD_ON(vehicle, i);
  342.                     if (i == MOD_TIRESMOKE && is_mod_on == TRUE)
  343.                     {
  344.                         int tire_smoke_color[3]{};
  345.                         VEHICLE::GET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, &tire_smoke_color[0], &tire_smoke_color[1], &tire_smoke_color[2]);
  346.                         vehicle_json["Tire Smoke Color"] = tire_smoke_color;
  347.                     }
  348.                     else if (is_mod_on == TRUE)
  349.                     {
  350.                         vehicle_json[mod_names[i]] = "TOGGLE";
  351.                     }
  352.                     if (VEHICLE::GET_VEHICLE_MOD(vehicle, i) != -1)
  353.                     {
  354.                         int vehicle_mod[2] = { VEHICLE::GET_VEHICLE_MOD(vehicle, i), VEHICLE::GET_VEHICLE_MOD_VARIATION(vehicle, i) };
  355.                         vehicle_json[mod_names[i]] = vehicle_mod;
  356.                     }
  357.                 }
  358.                 bool neon_lights[4]{};
  359.                 for (int i = NEON_LEFT; i <= NEON_BACK; i++)
  360.                     neon_lights[i] = VEHICLE::_IS_VEHICLE_NEON_LIGHT_ENABLED(vehicle, i);
  361.                 int neon_color[3]{};
  362.                 VEHICLE::_GET_VEHICLE_NEON_LIGHTS_COLOUR(vehicle, &neon_color[0], &neon_color[1], &neon_color[2]);
  363.                 vehicle_json["Neon Color"] = neon_color;
  364.                 vehicle_json["Neon Lights"] = neon_lights;
  365.                 if (VEHICLE::IS_VEHICLE_A_CONVERTIBLE(vehicle, 0))
  366.                     vehicle_json["Convertable State"] = VEHICLE::GET_CONVERTIBLE_ROOF_STATE(vehicle);
  367.                 int interior_color, dashboard_color;
  368.                 VEHICLE::GET_VEHICLE_INTERIOR_COLOUR(vehicle, &interior_color);
  369.                 VEHICLE::GET_VEHICLE_DASHBOARD_COLOUR(vehicle, &dashboard_color);
  370.                 vehicle_json["Interior Color"] = interior_color;
  371.                 vehicle_json["Dash Color"] = dashboard_color;
  372.                 vehicle_json["Clan Logo"] = GRAPHICS::_DOES_VEHICLE_HAVE_DECAL(vehicle, 0);
  373.                 vehicle_json["Headlight Color"] = VEHICLE::GET_VEHICLE_HEADLIGHT_COLOUR(vehicle);
  374.             }
  375.             return vehicle_json;
  376.         }
  377.  
  378.         static std::filesystem::path check_vehicle_folder()
  379.         {
  380.             auto file_path = std::filesystem::path(std::getenv("appdata"));
  381.             file_path /= "BigBaseV2";
  382.             file_path /= "Vehicles";
  383.  
  384.             if (!std::filesystem::exists(file_path))
  385.             {
  386.                 std::filesystem::create_directory(file_path);
  387.             }
  388.             else if (!std::filesystem::is_directory(file_path))
  389.             {
  390.                 std::filesystem::remove(file_path);
  391.                 std::filesystem::create_directory(file_path);
  392.             }
  393.  
  394.             return file_path;
  395.         }
  396.     };
  397. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement