Filename Class Reference

#include <c4d_file.h>

详细描述

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)

运算符

const Filename operator= (const Filename &fname)
const Filename operator+= (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 friend Filename   operator+ (const Filename &fname1, const Filename &fname2)

构造函数 & 析构函数文档编制

◆  Filename() [1/4]

Filename ( void  )

Default constructor.

◆  Filename() [2/4]

Filename ( const Char string )

Constructs the filename from a character array.

参数
[in] string The filename character array.

◆  Filename() [3/4]

Filename ( const maxon::String string )

Constructs the filename from a string.

参数
[in] string The filename string.

◆  Filename() [4/4]

Filename ( const Filename src )

Copy constructor. Creates a filename from another filename.

参数
[in] src The source filename.

◆  ~Filename()

~ Filename ( void  )

Default destructor.

成员函数文档编制

◆  IsPopulated()

Bool IsPopulated ( ) const

Checks if the filename has been set.

返回
true if filename was set, otherwise false .

◆  GetString()

String GetString ( void  ) const

Gets the String of the filename.

返回
The string with the full filename.

◆  SetString()

void SetString ( const maxon::String str )

Sets the filename to the passed string.

参数
[in] str The string to use to set the filename.

◆  GetDirectory()

const Filename GetDirectory ( void  ) const

Gets the directory that the file is located.

返回
The directory part for the filename.

◆  SetDirectory()

void SetDirectory ( const Filename str )

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

参数
[in] str The directory to set for the filename.

◆  GetFile()

const Filename GetFile ( void  ) const

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

返回
The file part of the filename.

◆  SetFile()

void SetFile ( const Filename str )

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

参数
[in] str The 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() .

返回
The file part of the filename as a string.

◆  GetSuffix()

String GetSuffix ( void  ) const

Gets the suffix of the filename.

注意
Suffix strings do not contain the dot character ' .'.
返回
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.

注意
Suffix strings do not contain the dot character ' .'.
参数
[in] str A 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  )

如同 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.

参数
[in] str The suffix to check against.
返回
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.

参数
[in] adr The memory to read from. The caller owns the pointed memory block.
[in] size The size of memory block starting at adr ,或 -1 if the buffer is "big enough".
[in] transferOwnership 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.

参数
[in] mfs The 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.

参数
[in] fname The right-operand filename.
返回
The left-operand filename.

◆  operator+=()

const Filename & operator+= ( const Filename fname )

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

参数
[in] fname The right-operand filename.
返回
The left-operand filename.

◆  operator==()

Bool operator== ( const Filename fname ) const

Checks if two filenames are equal.

参数
[in] fname The right-operand filename.
返回
true if filenames are equal, otherwise false .

◆  operator!=()

Bool operator!= ( const Filename fname ) const

Check if two filenames are different.

参数
[in] fname The right-operand filename.
返回
true if filenames are different, otherwise false .

◆  CopyTo()

void CopyTo ( Filename dst ) const

Copies the filename to dst .

参数
[out] dst The destination filename. The caller owns the pointed filename.

◆  IsBrowserUrl()

Bool IsBrowserUrl ( ) const

Checks if the filename is a content browser url.

返回
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. 范例: To load a file:

Bool ok = fn. FileSelect ( FILESELECTTYPE::ANYTHING , FILESELECT::LOAD , "Load" );

To save a bmp 文件:

Bool ok = fn. FileSelect ( FILESELECTTYPE::IMAGES , FILESELECT::SAVE , "Save" , "bmp" );
参数
[in] type The type of file to show in the file selector: FILESELECTTYPE
[in] flags The file selector flags: FILESELECT
[in] title The title for the file selector dialog.
[in] force_suffix Set this to suffix to force a filename suffix when in save mode.
返回
true if the user selected a file, otherwise false .

Friends And Related Function Documentation

◆  operator+

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

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

参数
[in] fname1 The left-operand filename.
[in] fname2 The right-operand filename.
返回
The result of the concatenation of the 2 filenames.

Member Data Documentation

◆  dummy1

maxon::Url dummy1
private
FILESELECTTYPE::IMAGES
@ IMAGES
Image files.
FILESELECT::SAVE
@ SAVE
Save dialog.
FILESELECTTYPE::ANYTHING
@ ANYTHING
Any file.
FILESELECT::LOAD
@ LOAD
Load dialog.
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
Filename::FileSelect
Bool FileSelect(FILESELECTTYPE type, FILESELECT flags, const maxon::String &title, const maxon::String &force_suffix=maxon::String())