startAgain. c++ functions, search
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"BuildId": "27405482",
|
||||
"Modules":
|
||||
{
|
||||
"manageTextFile": "UnrealEditor-manageTextFile.dll"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,22 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "manageTextFile.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FmanageTextFileModule"
|
||||
|
||||
void FmanageTextFileModule::StartupModule()
|
||||
{
|
||||
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
||||
|
||||
}
|
||||
|
||||
void FmanageTextFileModule::ShutdownModule()
|
||||
{
|
||||
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
|
||||
// we call this function before unloading the module.
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FmanageTextFileModule, manageTextFile)
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "manageTextFileBPLibrary.h"
|
||||
#include "manageTextFile.h"
|
||||
|
||||
UmanageTextFileBPLibrary::UmanageTextFileBPLibrary(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool UmanageTextFileBPLibrary::CreateTextFile(FString Path, FString FileName, FString Text)
|
||||
{
|
||||
if (Path == "" || FileName == "") {
|
||||
UE_LOG(LogTemp, Warning, TEXT("Empty Path or FileName, aborting"));
|
||||
return false;
|
||||
}
|
||||
Path.ReplaceInline(TEXT("/"), TEXT("\\"));
|
||||
FString fullpath(Path + "\\" + FileName);
|
||||
return FFileHelper::SaveStringToFile(Text, *fullpath, FFileHelper::EEncodingOptions::ForceUTF8);
|
||||
}
|
||||
|
||||
bool UmanageTextFileBPLibrary::AppendStringToFile(FString Path, FString FileName, FString Text)
|
||||
{
|
||||
if (Path == "" || FileName == "") {
|
||||
UE_LOG(LogTemp, Warning, TEXT("Empty Path or FileName, aborting"));
|
||||
return false;
|
||||
}
|
||||
Path.ReplaceInline(TEXT("/"), TEXT("\\"));
|
||||
FString fullpath(Path + "\\" + FileName);
|
||||
|
||||
FString OldText;
|
||||
if (FPaths::FileExists(fullpath))
|
||||
{
|
||||
FFileHelper::LoadFileToString(OldText, *fullpath);
|
||||
OldText += Text;
|
||||
return FFileHelper::SaveStringToFile(Text, *fullpath, FFileHelper::EEncodingOptions::ForceUTF8, &IFileManager::Get(), FILEWRITE_Append);
|
||||
}
|
||||
else
|
||||
{
|
||||
return CreateTextFile(Path, FileName, Text);
|
||||
}
|
||||
}
|
||||
|
||||
bool UmanageTextFileBPLibrary::FileExists(FString Path, FString FileName)
|
||||
{
|
||||
if (Path == "" || FileName == "") {
|
||||
UE_LOG(LogTemp, Warning, TEXT("Empty Path or FileName, aborting"));
|
||||
return false;
|
||||
}
|
||||
Path.ReplaceInline(TEXT("/"), TEXT("\\"));
|
||||
return FPaths::FileExists(Path + "\\" + FileName);
|
||||
}
|
||||
|
||||
bool UmanageTextFileBPLibrary::DeleteFile(FString Path, FString FileName)
|
||||
{
|
||||
if (Path == "" || FileName == "") {
|
||||
UE_LOG(LogTemp, Warning, TEXT("Empty Path or FileName, aborting"));
|
||||
return false;
|
||||
}
|
||||
Path.ReplaceInline(TEXT("/"), TEXT("\\"));
|
||||
FString fullpath = Path + "\\" + FileName;
|
||||
return FPlatformFileManager::Get().GetPlatformFile().DeleteFile(*fullpath);
|
||||
}
|
||||
|
||||
bool UmanageTextFileBPLibrary::readFile(FString Path, FString FileName,FString &Str) {
|
||||
if (Path == "" || FileName == "") {
|
||||
UE_LOG(LogTemp, Warning, TEXT("Empty Path or FileName, aborting"));
|
||||
return false;
|
||||
}
|
||||
|
||||
FString fullpath = Path + "\\" + FileName;
|
||||
return FFileHelper::LoadFileToString(Str, *fullpath);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class FmanageTextFileModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Misc/FileHelper.h"
|
||||
#include "Misc/Paths.h"
|
||||
#include "HAL/PlatformFilemanager.h"
|
||||
#include "manageTextFileBPLibrary.generated.h"
|
||||
|
||||
/*
|
||||
* Function library class.
|
||||
* Each function in it is expected to be static and represents blueprint node that can be called in any blueprint.
|
||||
*
|
||||
* When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable.
|
||||
* BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins.
|
||||
* BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins.
|
||||
* DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu.
|
||||
* Its lets you name the node using characters not allowed in C++ function names.
|
||||
* CompactNodeTitle - the word(s) that appear on the node.
|
||||
* Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu.
|
||||
* Good example is "Print String" node which you can find also by using keyword "log".
|
||||
* Category - the category your node will be under in the Blueprint drop-down menu.
|
||||
*
|
||||
* For more info on custom blueprint nodes visit documentation:
|
||||
* https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation
|
||||
*/
|
||||
UCLASS()
|
||||
class UmanageTextFileBPLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "manageTextFile")
|
||||
static bool CreateTextFile(FString Path, FString FileName, FString Text);
|
||||
UFUNCTION(BlueprintCallable, Category = "manageTextFile")
|
||||
static bool AppendStringToFile(FString Path, FString FileName, FString Text);
|
||||
UFUNCTION(BlueprintCallable, Category = "manageTextFile")
|
||||
static bool FileExists(FString Path, FString FileName);
|
||||
UFUNCTION(BlueprintCallable, Category = "manageTextFile")
|
||||
static bool DeleteFile(FString Path, FString FileName);
|
||||
UFUNCTION(BlueprintCallable, Category = "manageTextFile")
|
||||
static bool readFile(FString Path, FString FileName, FString & Str);
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
// Some copyright should be here...
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class manageTextFile : ModuleRules
|
||||
{
|
||||
public manageTextFile(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add public include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
// ... add other public dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
// ... add private dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
// ... add any modules that your module loads dynamically here ...
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "1.0",
|
||||
"FriendlyName": "manageTextFile",
|
||||
"Description": "",
|
||||
"Category": "fileIO",
|
||||
"CreatedBy": "Dron",
|
||||
"CreatedByURL": "",
|
||||
"DocsURL": "",
|
||||
"MarketplaceURL": "",
|
||||
"SupportURL": "",
|
||||
"CanContainContent": false,
|
||||
"Installed": true,
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "manageTextFile",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user