Filename Class Reference

#include <c4d_file.h>

Detailed Description

Manages file and path names.

Private Attributes

maxon::Url dummy1
 

Constructors/Destructors

 Filename (void)
 
 Filename (const Char *string)
 
 Filename (const maxon::String &string)
 
 Filename (const Filename &src)
 
 ~Filename (void)
 

String Content

Bool IsPopulated () const
 
String GetString (void) const
 
void SetString (const maxon::String &str)
 

Directory/File Parts

const Filename GetDirectory (void) const
 
void SetDirectory (const Filename &str)
 
const Filename GetFile (void) const
 
void SetFile (const Filename &str)
 
String GetFileString (void) const
 

Suffix Part

String GetSuffix (void) const
 
void SetSuffix (const maxon::String &str)
 
void ClearSuffix (void)
 
void ClearSuffixComplete (void)
 
Bool CheckSuffix (const maxon::String &str) const
 

Read/Write Memory

void SetMemoryReadMode (void *adr, Int size=-1, Bool transferOwnership=false)
 
void SetMemoryWriteMode (MemoryFileStruct *mfs)
 

Operators

const Filenameoperator= (const Filename &fname)
 
const Filenameoperator+= (const Filename &fname)
 
Bool operator== (const Filename &fname) const
 
Bool operator!= (const Filename &fname) const
 
void CopyTo (Filename *dst) const
 
Bool IsBrowserUrl () const
 
Bool FileSelect (FILESELECTTYPE type, FILESELECT flags, const maxon::String &title, const maxon::String &force_suffix=maxon::String())
 
const Filename operator+ (const Filename &fname1, const Filename &fname2)
 
static maxon::Result< BoolFileSelectMultiple (FILESELECT flags, const maxon::String &title, const maxon::Url &startUrl, const maxon::Id &settingsIdentifier, const maxon::Block< maxon::Tuple< maxon::String, maxon::String >> &filterStrings, const maxon::ValueReceiver< const maxon::Url & > &selectedUrls)
 

Constructor & Destructor Documentation

◆ Filename() [1/4]

Filename ( void  )

Default constructor.

◆ Filename() [2/4]

Filename ( const Char string)

Constructs the filename from a character array.

Parameters
[in]stringThe filename character array.

◆ Filename() [3/4]

Filename ( const maxon::String string)

Constructs the filename from a string.

Parameters
[in]stringThe filename string.

◆ Filename() [4/4]

Filename ( const Filename src)

Copy constructor. Creates a filename from another filename.

Parameters
[in]srcThe source filename.

◆ ~Filename()

~Filename ( void  )

Default destructor.

Member Function Documentation

◆ IsPopulated()

Bool IsPopulated ( ) const

Checks if the filename has been set.

Returns
true if filename was set, otherwise false.

◆ GetString()

String GetString ( void  ) const

Gets the String of the filename.

Returns
The string with the full filename.

◆ SetString()

void SetString ( const maxon::String str)

Sets the filename to the passed string.

Parameters
[in]strThe string to use to set the filename.

◆ GetDirectory()

const Filename GetDirectory ( void  ) const

Gets the directory that the file is located.

Returns
The directory part for the filename.

◆ SetDirectory()

void SetDirectory ( const Filename str)

Sets the directory for the filename. The file part remains unchanged.

Parameters
[in]strThe directory to set for the filename.

◆ GetFile()

const Filename GetFile ( void  ) const

Gets the file part of the filename only, without the path.

Returns
The file part of the filename.

◆ SetFile()

void SetFile ( const Filename str)

Sets the file part for the filename. The directory part remains unchanged.

Parameters
[in]strThe file part to set for the filename.

◆ GetFileString()

String GetFileString ( void  ) const

Convenience function to directly get the file part string. Identical to GetFile().GetString().

Returns
The file part of the filename as a string.

◆ GetSuffix()

String GetSuffix ( void  ) const

Gets the suffix of the filename.

Note
Suffix strings do not contain the dot character '.'.
Returns
The suffix. Only contains the suffix part without dot (e.g. "TIF").

◆ SetSuffix()

void SetSuffix ( const maxon::String str)

Sets the suffix part of the filename.

Note
Suffix strings do not contain the dot character '.'.
Parameters
[in]strA string with the suffix for the file. Only contains the suffix part and no dot (e.g. "TIF").

◆ ClearSuffix()

void ClearSuffix ( void  )

Clears the suffix part of the filename.

◆ ClearSuffixComplete()

void ClearSuffixComplete ( void  )

Same as ClearSuffix() only that it also clears suffixes longer than seven characters.

◆ CheckSuffix()

Bool CheckSuffix ( const maxon::String str) const

Checks if the suffix of the filename is the same as its string.

Parameters
[in]strThe suffix to check against.
Returns
true if the suffix was checked successfully, otherwise false.

◆ SetMemoryReadMode()

void SetMemoryReadMode ( void *  adr,
Int  size = -1,
Bool  transferOwnership = false 
)

Sets the filename to read from a memory block instead of from a file.

Parameters
[in]adrThe memory to read from. The caller owns the pointed memory block.
[in]sizeThe size of memory block starting at adr, or -1 if the buffer is "big enough".
[in]transferOwnershipIf true the ownership of the memory block is transfered to the caller, who then needs to free the memory with DeleteMem().
Otherwise (false by default) the memory block will be freed when the MemoryFileStruct is destructed.

◆ SetMemoryWriteMode()

void SetMemoryWriteMode ( MemoryFileStruct mfs)

Sets the filename to write to a memory block instead of to a file.

Parameters
[in]mfsThe memory file to write to. The caller owns the pointed memory file.

◆ operator=()

const Filename& operator= ( const Filename fname)

Assignment operator. Assigns the right-operand filename to the left-operand filename.

Parameters
[in]fnameThe right-operand filename.
Returns
The left-operand filename.

◆ operator+=()

const Filename& operator+= ( const Filename fname)

Concatenates the filenames and set the left-hand operand to the result.

Parameters
[in]fnameThe right-operand filename.
Returns
The left-operand filename.

◆ operator==()

Bool operator== ( const Filename fname) const

Checks if two filenames are equal.

Parameters
[in]fnameThe right-operand filename.
Returns
true if filenames are equal, otherwise false.

◆ operator!=()

Bool operator!= ( const Filename fname) const

Check if two filenames are different.

Parameters
[in]fnameThe right-operand filename.
Returns
true if filenames are different, otherwise false.

◆ CopyTo()

void CopyTo ( Filename dst) const

Copies the filename to dst.

Parameters
[out]dstThe destination filename. The caller owns the pointed filename.

◆ IsBrowserUrl()

Bool IsBrowserUrl ( ) const

Checks if the filename is a content browser url.

Returns
true if the filename is a browser url, otherwise false.

◆ FileSelect()

Bool FileSelect ( FILESELECTTYPE  type,
FILESELECT  flags,
const maxon::String title,
const maxon::String force_suffix = maxon::String() 
)

Opens a file selector dialog. Example: To load a file:

Bool ok = fn.FileSelect(FILESELECTTYPE::ANYTHING, FILESELECT::LOAD, "Load");
maxon::Bool Bool
Definition: ge_sys_math.h:55
@ LOAD
Load dialog.
@ ANYTHING
Any file.

To save a bmp file:

Bool ok = fn.FileSelect(FILESELECTTYPE::IMAGES, FILESELECT::SAVE, "Save", "bmp");
@ SAVE
Save dialog.
@ IMAGES
Image files.
Parameters
[in]typeThe type of file to show in the file selector: FILESELECTTYPE
[in]flagsThe file selector flags: FILESELECT
[in]titleThe title for the file selector dialog.
[in]force_suffixSet this to suffix to force a filename suffix when in save mode.
Returns
true if the user selected a file, otherwise false.

◆ FileSelectMultiple()

static maxon::Result<Bool> FileSelectMultiple ( FILESELECT  flags,
const maxon::String title,
const maxon::Url startUrl,
const maxon::Id settingsIdentifier,
const maxon::Block< maxon::Tuple< maxon::String, maxon::String >> &  filterStrings,
const maxon::ValueReceiver< const maxon::Url & > &  selectedUrls 
)
static

FileSelectMultiple allows to select files or folders in a OS file chooser dialog.

Parameters
[in]flagsFlags see FILESELECT.
[in]titleTitle to be set in the window.
[in]startUrlStart url to select in the file chooser.
[in]settingsIdentifierIdentifier to store settings for different callers (e.g. window dimensions etc). Every caller can have different settings. Keep empty for default settings
[in]filterStringsArray with tuples for valid file suffixes. first: name, second: ; seperated list of suffixes. e.g. BaseArray<Tuple<String, String>> filterStrings; filterStrings.Append({"All files"_s, "*.*"_s}) iferr_return; filterStrings.Append({"3D-Formats"_s, "*.c4d;*.dem;*.dxf;*.iob;*.lwo;*.lws;*.3dm;*.3dmf;*.ai;*.ps;*.wrl;*.3ds;*.obj;*.mon;*.dae;*.dwg;*.fbx;*.igs"_s}) iferr_return;
[out]selectedUrlsValue receiver which is triggered for every selected url.
Returns
True on success. False if user canceled. Error otherwise.

Friends And Related Function Documentation

◆ operator+

const Filename operator+ ( const Filename fname1,
const Filename fname2 
)
friend

Concatenates the two filenames. It will join directories and files parts.

Parameters
[in]fname1The left-operand filename.
[in]fname2The right-operand filename.
Returns
The result of the concatenation of the 2 filenames.

Member Data Documentation

◆ dummy1

maxon::Url dummy1
private