Elaztek Developer Hub
Blamite Game Engine - Strings  00428.01.13.25.2134.blamite
A library containing general purpose utilities and classes for use in multiple projects.
io.h
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <Windows.h>
4 
5 #ifdef STRINGS_EXPORTS
6 #define STRINGS_API __declspec(dllexport)
7 #else
8 #define STRINGS_API __declspec(dllimport)
9 #endif
10 
15 {
23  STRINGS_API bool FileExists(std::string name);
24 
33  STRINGS_API bool IsFile(std::string path);
34 
43  STRINGS_API bool IsDirectory(std::string path);
44 
53  STRINGS_API bool CreateNewFile(std::string filename, std::string file_contents);
54 
63  STRINGS_API void ValidatePath(std::string path);
64 
69 
75  STRINGS_API std::string GetApplicationDir();
76 
88  STRINGS_API bool ReadBinaryFile(std::string path, void** data, int64_t* size);
89 
101  STRINGS_API bool ReadFile(std::string path, void** data, int64_t* size);
102 
111  STRINGS_API std::vector<std::string> GetFileContentsAsLines(std::string path);
112 
120  STRINGS_API std::string GetFileContentsAsString(std::string path);
121 
130  STRINGS_API std::vector<std::string> GetFileList(std::string path);
131 
140  STRINGS_API std::vector<std::string> GetDirectoryList(std::string path);
141 
150  STRINGS_API std::vector<std::string> GetDeepFileList(std::string path);
151 
162  STRINGS_API std::string NormalizePath(std::string path);
163 
174  STRINGS_API std::string GetFileName(std::string path);
175 
186  STRINGS_API std::string GetFileNameWithoutExtension(std::string path);
187 
198  STRINGS_API std::string GetFileExtension(std::string path);
199 
213  STRINGS_API std::string GetFileExtension(std::string path, bool skip_file_check);
214 
229  STRINGS_API std::string GetContainingFolder(std::string path);
230 
246  STRINGS_API std::string GetContainingFolder(std::string path, bool require_exists);
247 
255  STRINGS_API std::string GetEngineDataRoot();
256 
267  STRINGS_API std::string ParseDataRoot(std::string path);
268 
272  STRINGS_API void ExploreDirectory(std::string path);
273 
281  STRINGS_API std::string GetAbsolutePathFromRelative(std::string relative_path);
282 
291  STRINGS_API std::string GetRelativePathFromAbsolute(std::string absolute_path);
292 
302  STRINGS_API bool WriteBinaryFile(std::string file_path, void* data, int64_t size);
303 
309  STRINGS_API void OpenFile(std::string file_path);
310 
318  STRINGS_API std::string GetModuleFilePath(HMODULE module_handle);
319 
327  STRINGS_API uint64_t GetFileSize(std::string file_path);
328 }
logger.h
BlamStrings::Utils::IO::GetApplicationDir
STRINGS_API std::string GetApplicationDir()
Retrieves the application's working directory.
Definition: io.cpp:114
BlamStrings::Utils::String::Split
STRINGS_API std::vector< std::string > Split(std::string string, std::string splitter)
Splits a string around any instance of a substring.
Definition: string.cpp:136
BlamStrings::Utils::IO::OpenFile
STRINGS_API void OpenFile(std::string file_path)
Opens a file with its default application.
Definition: io.cpp:468
BlamStrings::Utils::IO::GetDirectoryList
STRINGS_API std::vector< std::string > GetDirectoryList(std::string path)
Retrieves the list of all folders in the root of a given directory.
Definition: io.cpp:233
BlamStrings::Utils::IO::ReadBinaryFile
STRINGS_API bool ReadBinaryFile(std::string path, void **data, int64_t *size)
Reads a file as raw binary data.
Definition: io.cpp:153
BlamStrings::Utils::IO::GetFileSize
STRINGS_API uint64_t GetFileSize(std::string file_path)
Retrives the size of a file, in bytes.
Definition: io.cpp:487
BlamStrings::Utils::IO::GetFileExtension
STRINGS_API std::string GetFileExtension(std::string path)
Retrieves the extension of a file.
Definition: io.cpp:349
string.h
BlamStrings::Utils::IO::GetDeepFileList
STRINGS_API std::vector< std::string > GetDeepFileList(std::string path)
Retrieves the list of all files within a given directory.
Definition: io.cpp:261
BlamStrings::Logger::LogEvent
STRINGS_API void LogEvent(BlamBasicLogMessage message)
Logs an event to the logger.
Definition: logger.cpp:41
BlamStrings::Utils::IO
Utilities relating to reading/writing to and from files.
Definition: io.h:14
BlamStrings::Utils::IO::GetAbsolutePathFromRelative
STRINGS_API std::string GetAbsolutePathFromRelative(std::string relative_path)
Converts a relative path to an absolute file path.
Definition: io.cpp:438
WSV_WARNING
#define WSV_WARNING
Macro for 'Warning' log seveirty.
Definition: logger.h:24
BlamStrings::Utils::IO::CreateNewFile
STRINGS_API bool CreateNewFile(std::string filename, std::string file_contents)
Creates a file with the specified contents, or overwrites an existing file if it already exists.
Definition: io.cpp:75
BlamStrings::Utils::IO::ParseDataRoot
STRINGS_API std::string ParseDataRoot(std::string path)
Parses a data root folder.
Definition: io.cpp:416
BlamStrings::Utils::IO::GetEngineDataRoot
STRINGS_API std::string GetEngineDataRoot()
Retrieves the root folder for all game engine and editing kit user data files.
Definition: io.cpp:403
BlamStrings::Utils::String::Replace
STRINGS_API std::string Replace(std::string orig, std::string to_replace, std::string replace_with)
Replaces part of a string with another string.
Definition: string.cpp:94
BlamStrings::Utils::IO::GetFileList
STRINGS_API std::vector< std::string > GetFileList(std::string path)
Retrieves the list of all files in a given directory.
Definition: io.cpp:205
str_replace
#define str_replace(str, to, from)
Macro to more easily replace strings/chars within a given string.
Definition: string.h:41
BlamStrings::Utils::IO::IsDirectory
STRINGS_API bool IsDirectory(std::string path)
Checks if a given path refers to a directory.
Definition: io.cpp:58
BlamStrings::Utils::IO::GetFileName
STRINGS_API std::string GetFileName(std::string path)
Retrieves the name of the file or folder that a given path refers to.
Definition: io.cpp:314
BlamStrings::Utils::IO::WriteBinaryFile
STRINGS_API bool WriteBinaryFile(std::string file_path, void *data, int64_t size)
Creates a file with the specified contents, or overwrites an existing file if it already exists.
Definition: io.cpp:454
BlamStrings::Utils::IO::GetFileContentsAsString
STRINGS_API std::string GetFileContentsAsString(std::string path)
Reads a file as a string.
Definition: io.cpp:137
BlamStrings::Utils::IO::GetModuleFilePath
STRINGS_API std::string GetModuleFilePath(HMODULE module_handle)
Retrieves the file path for a given module (ie, a DLL or executable).
Definition: io.cpp:474
BlamStrings::Utils::IO::NormalizePath
STRINGS_API std::string NormalizePath(std::string path)
Normalizes a path string.
Definition: io.cpp:297
file
allowing up to file loggers to be attached(Short form:/fl[n])/fileloggerparameters[n] Not setting the switch overwrites the contents of an existing log file The default is not to append to the log file Encoding specifies the encoding for the file
Definition: msb.txt:91
BlamStrings::Utils::IO::IsFile
STRINGS_API bool IsFile(std::string path)
Checks if a given path refers to a regular file.
Definition: io.cpp:41
BlamStrings::Utils::IO::GetFileNameWithoutExtension
STRINGS_API std::string GetFileNameWithoutExtension(std::string path)
Retrieves the name of the file or folder that a given path refers to, excluding the file's extension ...
Definition: io.cpp:337
BlamStrings::Utils::IO::ReadFile
STRINGS_API bool ReadFile(std::string path, void **data, int64_t *size)
Reads a file as text data, with a NULL byte placed at the end of the file contents.
Definition: io.cpp:178
BlamStrings::Utils::String::Contains
STRINGS_API bool Contains(std::string string, std::string contains, bool ignore_case=false)
Determines whether or not a string contains the specified substring.
Definition: string.cpp:181
BlamStrings::Utils::IO::FileExists
STRINGS_API bool FileExists(std::string name)
Checks if the specified file or directory exists.
Definition: io.cpp:25
BlamStrings::Utils::IO::OpenGameDirectory
STRINGS_API void OpenGameDirectory()
Opens the engine's game directory in Windows Explorer.
Definition: io.cpp:107
BlamStrings::Utils::IO::GetContainingFolder
STRINGS_API std::string GetContainingFolder(std::string path)
Retrieves the containing folder of a given file or directory.
Definition: io.cpp:373
BlamStrings::Utils::IO::ValidatePath
STRINGS_API void ValidatePath(std::string path)
Validates that the specified path exists.
Definition: io.cpp:93
uuids::to_string
std::basic_string< CharT, Traits, Allocator > to_string(uuid const &id)
Definition: uuid.h:581
io.h
BlamStrings::Utils::IO::GetFileContentsAsLines
STRINGS_API std::vector< std::string > GetFileContentsAsLines(std::string path)
Reads a file as a list of strings.
Definition: io.cpp:121
STRINGS_API
#define STRINGS_API
Definition: io.h:8
BlamStrings::Utils::IO::GetRelativePathFromAbsolute
STRINGS_API std::string GetRelativePathFromAbsolute(std::string absolute_path)
Converts an absolute path to a relative file path.
Definition: io.cpp:446
WSV_ERROR
#define WSV_ERROR
Macro for 'Error' log seveirty.
Definition: logger.h:23
BlamStrings::Utils::IO::ExploreDirectory
STRINGS_API void ExploreDirectory(std::string path)
Opens a directory within the system file explorer.
Definition: io.cpp:433
BlamStrings::Utils::String::ContainsChar
STRINGS_API bool ContainsChar(std::string string, char contains)
Determines whether or not a string contains the specified character.
Definition: string.cpp:165
BlamLogLevel::Warning
@ Warning
Indicates a warning message. Not something critical, but something that could cause unexpected behavi...