fastest 3D software for linux

Linux 3D
interactive ray-tracing
[Introduction] [Overview] [Core reference] [3D reference] [GUI]

Index

 EFile_Load
 EFile_MkDir
 EFile_OpenFileLoad
 EFile_Save
 EStr_CurrentDir
 EStr_MillisecondsToString
 EStr_MicrosecondsToString
 EStr_NanosecondsToString
 EStr_StringToInt
 EStr_StringToIntChk
 EStr_StringToIntHex
 EStr_StringGetUnique
 EStr_StringGetAndAddUniqueA
 EStr_EqualW
 EStr_CorrectDirName
 EStr_CorrectPath
 EStr_GetPathName
 EStr_WCharNToASCII
 EStrDupWtoUTF8
 EStrNDupWtoUTF8
 EStr_StringAfterPrefix
 EStr_GetLine

EFile_Load

A simple file reader with error checking

Syntax
int EFile_Load(const char* PFileName, uint8_t** PBufferRet, EIndex* PSizeRet)

Arguments
PFileName File name PBufferRet Pointer to the resulting buffer PSizeRet Pointer to the resulting size
Description
It adds a 0 at the end of the buffer, so if it was a text file it will be properly 0-terminated.

Return value
E_SUCCESS in all went well, otherwise the error code (E_NO_FILENAME, E_DIRECTORY, E_NO_READ_PERMISSION etc.)

EFile_MkDir

Create a directory

Syntax
int EFile_MkDir(const char* PName, const EBool PRecursive, const int PVerbosity)

Arguments
PName Directory name PRecursive If necessary, create any subdirectories above PName PVerbosity Verbosity level
Description
Creates a directory specified by PName. If PRecursive is TRUE, and directories above PName don't exist, it will create any directories leading to PName. Otherwise (if PRecursive is false), it returns an error.

Return value
E_SUCCESS if successful, otherwise an appropriate error code.

EFile_OpenFileLoad

A simple file reader with error checking

Syntax
int EFile_OpenFileLoad(FILE* PFile, uint8_t** PBufferRet, EIndex* PSizeRet)

Arguments
PFile Pointer to file that was already opened PBufferRet Pointer to the resulting buffer PSizeRet Pointer to the resulting size
Description
It adds a 0 at the end of the buffer, so if it was a text file it will be properly 0-terminated.

Return value
E_SUCCESS in all went well, otherwise the error code (E_NO_MEMORY)

EFile_Save

A simple file saver, with error checking

Syntax
int EFile_Save(const char* PFileName, const void* PBuffer, const EIndex PBytes)

Arguments
PFileName File name PBuffer Pointer to the data buffer to save PBytes Number of bytes in PBuffer
Description
Saves a data buffer to a file.

Return value
E_SUCCESS in all went well, otherwise the error code (E_NO_FILENAME, E_DIRECTORY, E_NO_READ_PERMISSION etc.)

EStr_CurrentDir

Return the current working directory

Syntax
char* EStr_CurrentDir(const EBool PAddSlash)

Arguments
PAddSlash Add a '/' character at the end
Description
The resulting string will be allocated with EMalloc, so it will be the caller's responsibility to free it when it's not used any more.

Return value
The current working directory or NULL in case of an error

EStr_MillisecondsToString

Convert milliseconds to a string

Syntax
char* EStr_MillisecondsToString(const ETime PMilliseconds, char* PTimeStr, const EBool PAlign)

Arguments
PMicroseconds Input value PTimeStr Target string PAlign If TRUE, try to keep the string the same length
Description
Converts milliseconds to a string with automatic switch to seconds, minutes or hours, depending on the value. If PAlign is TRUE, try to keep the string the same length (e.g " 3.450 ms"). This is useful, for example for interactively printing frame rendering times, so the string stays aligned as the value changes.

Return value
Pointer to the string.

See also
EStr_MillisecondsToString

EStr_MicrosecondsToString

Convert microseconds to a string

Syntax
char* EStr_MicrosecondsToString(const ETime PTime, char* PTimeStr, const EBool PAlign)

Arguments
PTime Input value PTimeStr Target string PAlign If TRUE, try to keep the string the same length
Description
Converts microseconds to a string with automatic switch to milliseconds, seconds, minutes or hours, depending on the value. If PAlign is TRUE, try to keep the string the same length (e.g " 3.450 ms"). This is useful, for example for interactively printing frame rendering times, so the string stays aligned as the value changes.

Return value
Pointer to the string.

See also
EStr_MillisecondsToString, EStr_NanosecondsToString

EStr_NanosecondsToString

Convert nanoseconds to a string

Syntax
char* EStr_NanosecondsToString(const ETime PTime, char* PTimeStr, const EBool PAlign)

Arguments
PTime Input value PTimeStr Target string PAlign If TRUE, try to keep the string the same length
Description
Converts nanoseconds to a string with automatic switch to microseconds, milliseconds, seconds, minutes or hours, depending on the value. If PAlign is TRUE, try to keep the string the same length (e.g " 3.450 ms"). This is useful, for example for interactively printing frame rendering times, so the string stays aligned as the value changes.

Return value
Pointer to the string.

See also
EStr_MicrosecondsToString, EStr_MillisecondsToString

EStr_StringToInt

Convert string to integer

Syntax
int EStr_StringToInt(const char* PPtr, const char PEndCharacter)

Argument
PPtr Pointer to the string
Description
Converts an ASCII string to an integer. No error checking is done. If the string does not contain a valid number, the result is indeterminate.

Return value
The resulting ingeter

EStr_StringToIntChk

Convert string to integer with error checking

Syntax
int EStr_StringToIntChk(const char* PPtr, int* PValueP)

Argument
PPtr Pointer to the string PValueP Pointer to the address where the resulting integer is to be stored
Description
Converts an ASCII string to an integer. Error checking is done. If the string does not contain a valid number, the result is indeterminate and an error code is returned. Note that the resulting integer will be returned in PValueP. This is for consistency with error reporting (as the return value). PValueP may be NULL. In this case, only the error checking is performed.

Return value
Status code E_SUCCESS, E_NO_DATA, or E_INCOMPATIBLE_DATA

EStr_StringToIntHex

Convert string to integer

Syntax
int EStr_StringToIntHex(const char* PStr)

Argument
PPtr Pointer to the string
Description
Converts an ASCII string to an integer. No error checking is done. If the string does not contain a valid number, the result is indeterminate.

Return value
The resulting ingeter

EStr_StringGetUnique

Create a string that is based on a given string, but is different from all the strings in an array

Syntax
char* EStr_StringGetUnique(const char* PString, const char** PStrings, const EIndex PNumOfStrings)

Arguments
PString The input string PStrings The array of strings among which PString must be unique PNumOfStrings The number of strings in the PStrings array
Description
EStr_StringGetUnique() first checks if PString is in the array, PStrings. If it is not, it simply returns a duplicate of PString. If the string is found in the array, it adds a postfix '-x', where x is a number, and increments the number until the resulting string is unique.

Return value
A unique string, based on PString, or NULL in case of an error

EStr_StringGetAndAddUniqueA

Create a string that is based on a given string, but is different from all the strings in an array

Syntax
char* EStr_StringGetAndAddUniqueA(const char* PString, char*** PStringsP, EIndex* PNumOfStringsP, EIndex* PNumOfStringsAllocatedP)

Arguments
PString The input string PStringsP Pointer to the array of strings among which PString must be unique PNumOfStringsP Pointer to the number of strings in the PStringsP array
Description
EStr_StringGetUnique() first checks if PString is in the array, LStrings. If it is not, it simply returns a duplicate of PString. If the string is found in the array, it adds a postfix '-x', where x is a number, and increments the number until the resulting string is unique.

Return value
A unique string, based on PString, or NULL in case of an error

EStr_EqualW

Check two wide-character strings if they are equal

Syntax
EBool EStr_EqualW(const wchar_t* PString0, const wchar_t* PString1)

Arguments
PString0 The first string PString0 The second string
Description
Checks if the two strings are equal. NULL pointers are accepted. 2 NULL pointers mean equality.

Return value
TRUE, if the strings are equal, FALSE otherwise.

EStr_CorrectDirName

Correct dir name:
rect dir name:
t dir name:
ir name:
name:
e:
// - remove multiple '//'s
- remove multiple '//'s
emove multiple '//'s
ve multiple '//'s
multiple '//'s
tiple '//'s
le '//'s
'//'s
's
// - expand ~ and environment variables

Syntax
char* EStr_CorrectDirName(const char* PPath)

Argument
PPath The input path string
Description
Corrects a directory name by removing multiple '/' characters and expanding '~' (home directory) and any environment variables. The resulting string will be allocated with EMalloc, so it will be the caller's responsibility to free it when it's not used any more.

Return value
The corrected directory path

EStr_CorrectPath

Correct path name
rect path name
t path name
ath name
name
me
// - remove multiple '//'s
- remove multiple '//'s
emove multiple '//'s
ve multiple '//'s
multiple '//'s
tiple '//'s
le '//'s
'//'s
's
// - expand "~" and environment variables

Syntax
char* EStr_CorrectPath(const char* PPath)

Argument
PPath The input path string
Description
Corrects a path name by removing multiple '/' characters and expanding '~' (home directory) and any environment variables. A path name may include a directory name + a file name at the end. The resulting string will be allocated with EMalloc, so it will be the caller's responsibility to free it when it's not used any more.

Return value
The corrected path

EStr_GetPathName

Get path name from a full path

Syntax
char* EStr_GetPathName(const char* PFullStr, char* PRet, const EIndex PMaxLen)

Arguments
PFullStr The full path PRet The result PMaxLen Maximum length to write
Description
Returns the path name without any file name at the end.

Return value
None.

EStr_WCharNToASCII

Convert a wide-character string to ASCII

Syntax
EIndex EStr_WCharNToASCII(const wchar_t* PSrc, const EIndex PLen, const char PUseThisForInvalidChars, char* PDst)

Argument
PSrc The source string PLen Number of characters to convert PUseThisForInvalidChars Replace chracters outside of ASCII range, with this value PDst The destination string
Description
Converts PLen wide characters to ASCII.

Return value
The number of characters that were within the ASCII range.

See also
EStrDupW, EStrDup8toW, EStrDupWto8

EStrDupWtoUTF8

Convert a wide-character string into UTF-8 format

Syntax
char* EStrDupWtoUTF8(const wchar_t* PWString)

Argument
PWString The string to duplicate
Description
Allocates enough memory and converts a wide-character string into UTF-8 format.

Return value
Pointer to the new string, or NULL in case of an error.

See also
EStrDup, EStrDupW, EStrDup8toW, EStrDupWto8, ERealloc, EFree

EStrNDupWtoUTF8

Convert a wide-character string into UTF-8 format

Syntax
char* EStrNDupWtoUTF8(const wchar_t* PWString, const EIndex PLength)

Argument
PWString The string to duplicate PLength The number of characters to copy from the source
Description
Allocates enough memory and converts a wide-character string into UTF-8 format.

Return value
Pointer to the new string, or NULL in case of an error.

See also
EStrDup, EStrDupW, EStrDup8toW, EStrDupWto8, ERealloc, EFree

EStr_StringAfterPrefix

Get string after a prefix

Syntax
const char* EStr_StringAfterPrefix(const char* PStr, const char* PPrefix)

Argument
PStr The main string PPrefix The prefix
Description
Skip a prefix in a string, if the string begins with that prefix.

Return value
If PStr begins with PPrefix, return the portion of PStr after that. Otherwise, PStr.

EStr_GetLine

Get a line from a buffer

Syntax
EIndex EStr_GetLine(const char* PStr, const EIndex PMaxLen, EIndex* PLineLength)

Arguments
PStr Pointer to the buffer PBufferSize Characters in the buffer (may not be 0-terminated) PLineLength If not NULL, return the length of the line
Description
Processes a line in a buffer. Lines may be terminated with either 0x0A or 0x0D + 0x0A.

Return value
Offset to the beginning of the next line
© 1996-2025 By Gabor Nagy