Agrarsense
Static Public Member Functions | Static Private Attributes | Friends | List of all members
UAgrarsensePaths Class Reference

#include <AgrarsensePaths.h>

Inheritance diagram for UAgrarsensePaths:
Inheritance graph
[legend]
Collaboration diagram for UAgrarsensePaths:
Collaboration graph
[legend]

Static Public Member Functions

static FString GetProjectRootFolder ()
 
static FString GetContentFolderPath ()
 
static FString GetDataFolder ()
 
static FString GetExamplesFolder ()
 

Static Private Attributes

static FString DataPathForThisRun = ""
 

Friends

class AAgrarsenseGameModeBase
 

Detailed Description

Definition at line 14 of file AgrarsensePaths.h.

Member Function Documentation

◆ GetContentFolderPath()

FString UAgrarsensePaths::GetContentFolderPath ( )
static

Get project content folder path

Returns
project content folder path

Definition at line 32 of file AgrarsensePaths.cpp.

33{
34 FString RootPath = GetProjectRootFolder();
35 FString ContentFolder = RootPath + "Unreal/Agrarsense/Content/";
36
37 return ContentFolder;
38}
static FString GetProjectRootFolder()

References GetProjectRootFolder().

◆ GetDataFolder()

FString UAgrarsensePaths::GetDataFolder ( )
static

Get AGRARSENSE data folder

Returns
data folder path

Definition at line 40 of file AgrarsensePaths.cpp.

41{
42 if (!DataPathForThisRun.IsEmpty())
43 {
44 return DataPathForThisRun;
45 }
46
47 IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
48
49 FString RootPath = GetProjectRootFolder();
50 FString DataRoot = RootPath + "Data";
51
52 if (!FPaths::DirectoryExists(DataRoot))
53 {
54 PlatformFile.CreateDirectory(*DataRoot);
55 }
56
57 // Continue with the rest of the logic
58 FString BaseDataFolderPath = DataRoot + "/Run";
59
60 int32 RunIndex = 0;
61 do
62 {
63 DataPathForThisRun = BaseDataFolderPath + FString::FromInt(RunIndex);
64 RunIndex++;
65 } while (PlatformFile.DirectoryExists(*DataPathForThisRun));
66
67 DataPathForThisRun += "/"; // Append slash to the path
68
69 PlatformFile.CreateDirectory(*DataPathForThisRun);
70
71 return DataPathForThisRun;
72}
static FString DataPathForThisRun

References DataPathForThisRun, and GetProjectRootFolder().

Referenced by ALidarManager::BeginPlay(), ULogFile::Create(), ASensor::CreateDataSavePath(), and USimulatorJsonExporter::CreateUniqueFilePath().

◆ GetExamplesFolder()

FString UAgrarsensePaths::GetExamplesFolder ( )
static

Get AGRARSENSE Examples folder

Returns
data folder path

Definition at line 74 of file AgrarsensePaths.cpp.

75{
76 FString RootPath = GetProjectRootFolder();
77
78 FString DataFolderPath = RootPath + "Examples/";
79
80 // Check if dir exists, if it doesn't let's create it.
81 IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
82 if (!PlatformFile.DirectoryExists(*DataFolderPath))
83 {
84 PlatformFile.CreateDirectory(*DataFolderPath);
85 }
86
87 return DataFolderPath;
88}

References GetProjectRootFolder().

◆ GetProjectRootFolder()

FString UAgrarsensePaths::GetProjectRootFolder ( )
static

Get project root folder path. When playing in Editor this means Git root path (example. C:/Agrarsense/). when playing on packaged build this means SOME_PATH/Agrarsense.exe path.

Returns
FString path to project root folder.

Definition at line 17 of file AgrarsensePaths.cpp.

18{
19 FString ProjectRootPath = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
20
21 // How many characters to remove so we get Actual project root folder
22 int CharsToRemove = 11;
23#if WITH_EDITOR
24 CharsToRemove = 18;
25#endif
26
27 ProjectRootPath.RemoveAt(ProjectRootPath.Len() - CharsToRemove, CharsToRemove, true);
28
29 return ProjectRootPath;
30}

Referenced by GetContentFolderPath(), GetDataFolder(), and GetExamplesFolder().

Friends And Related Function Documentation

◆ AAgrarsenseGameModeBase

friend class AAgrarsenseGameModeBase
friend

Definition at line 52 of file AgrarsensePaths.h.

Member Data Documentation

◆ DataPathForThisRun

FString UAgrarsensePaths::DataPathForThisRun = ""
staticprivate

Definition at line 54 of file AgrarsensePaths.h.

Referenced by GetDataFolder().


The documentation for this class was generated from the following files: