class MFileObject

Jump to documentation

Manipulate Unix filenames and search paths. (OpenMaya) (OpenMaya.py)

public members:

MFileObject ()
MFileObject ( const MFileObject & other )
virtual ~MFileObject ()
MFileObject & operator= ( const MFileObject & other )
MStatus setRawName ( const MString & fileName )
MStatus setRawPath ( const MString & filePath )
MStatus setRawFullName ( const MString & fullFileName )
MStatus overrideResolvedFullName ( const MString & fullFileName )
MString rawName () const
MString rawPath () const
MString rawFullName () const
MString expandedPath () const
MString expandedFullName () const
MString resolvedName () const
MString resolvedPath () const
MString resolvedFullName () const
unsigned int pathCount ()
MString ithPath ( unsigned int index )
MString ithFullName ( unsigned int index )
bool exists ()
bool exists ( unsigned int index )
bool isSet () const
MStatus setName ( const MString & fileName )
MStatus setFullName ( const MString & fileName )
MString name () const
MString path () const
MString fullName () const

Documentation

Manipulate Unix filenames and search paths
Description

The MFileObject class implements an object that contains both a filename and a search path. The search path is specified by a single string in which multiple elements are separated by ':' characters. As well this string can contain Unix environment variables, specified as $VARNAME,

Filenames can be produced by the class by combining the path element with the filename element of the MFileObject. As well, methods are available to test for the existance of the files produced.

Functions

MFileObject:: MFileObject ()

Description

Class constructor. Create a new MFileObject that contains neither a path nor a filename.

MFileObject:: MFileObject ( const MFileObject & other )
Description

Copy constructor. Create a new MFileObject instance and initialize it with the same path and filename as the given instance.

Arguments

  • other the MFileObject to copy

MFileObject:: ~MFileObject ()
Description

Class destructor.

MFileObject & MFileObject:: operator= ( const MFileObject & other )
Description

Assignment operator. Allows assignment between MFileObjects.

MStatus MFileObject:: setRawName ( const MString & fileName )

Description

Set the unresolved filename element of the MFileObject instance. This name should not contain any '/' characters, it should indicate simply the name of a file. The directories in which this name will be searched for are specified by setRawPath.

Arguments

  • fileName An MString containing the filename.

Return Value

  • MS::kSuccess operation successful

MStatus MFileObject:: setRawPath ( const MString & pathName )
Description

Set the unresolved path element of the MFileObject instance. This should contain a list of directories, each separated by a single ':' character. The pathnames can contain Unix environment variables in the form $VARNAME. These will be expanded when paths to actual filenames are constructed.

Note that if the specified pathName is relative, contains environment variables, or does not exist, the paths returned by MFileObject::resolvedPath() and MFileObject::expandedPath() may not match the rawPath. See the description of MFileObject::resolvedPath() and MFileObject::expandedPath() for more information.

Arguments

  • pathName An MString containing the path string.

Return Value

  • MS::kSuccess operation successful

MStatus MFileObject:: setRawFullName ( const MString & fullFileName )

Description

This method combines the functions of the setRawName and setRawPath methods in that it sets both the path and filename from the given name.

If any '/' characters appear in the given name then the path element of the MFileObject is set to everything in name up to, but not including the last '/'. The filename is set to the part of name after the final '/'.

If no '/' characters appear in the given name then the path element is set to "." and the filename is set to the given name.

Note that if the specified fullFileName is relative, contains environment variables, or does not exist, the full names returned by MFileObject::resolvedFullName() and MFileObject::expandedFullName() may not match the fullFileName. See the description of MFileObject::resolvedFullName() and MFileObject::expandedFullName() for more information.

Arguments

  • fileName the string used to initialize the path and filename.

Return Value

  • MS::kSuccess operation successful

MStatus MFileObject:: overrideResolvedFullName ( const MString & fullFileName )

Description

Normally when a raw file name is set, Maya will perform a series of operations on it in an attempt to resolve it to a valid file name. This final resolved file name can be accessed through the MFileObject::resolvedName(), MFileObject::resolvedPath(), and MFileObject::resolvedFullFileName() methods and can be quite different from the originally specified raw file name.

This method will override the normal Maya path resolution process and explicitly set the resolved file name. This path does not have to be a valid file path, but if any '/' characters appear in the given name then the resolved path element of the MFileObject is set to everything in name up to, but not including the last '/'. The resolved filename is set to the part of name after the final '/'.

Once the resolved file name is set, it is only guaranteed to be retained in the MFileObject so long as the raw file path is not updated. Once MFileObject::setRawPath(), MFileObject::setRawName(), or MFileObject::setRawFullName() is called, the normal Maya path resolution process will be re-invoked and the resolved path and filename will be updated.

Arguments

  • fileName the string used to override the path and filename.

Return Value

  • MS::kSuccess operation successful

MString MFileObject:: rawName () const

Description

Returns the unresolved filename element of the MFileObject.

Return Value

  • an MString containing the filename.

MString MFileObject:: rawPath () const

Description

Returns the path element of the MFileObject with all environment variables unexpanded.

Return Value

  • an MString containing the path.

MString MFileObject:: rawFullName () const

Description

Returns the unrsolved full file name (path plus filename) of the MFileObject with all environment variables unexpanded.

Return Value

  • an MString containing the filename.

MString MFileObject:: expandedPath () const

Description

Returns the path element of the MFileObject with all environment variables expanded.

After expanding environment variables Maya may perform additional modifications to the path in order to resolve it to a valid location on disk. This resolved path can be accessed through MFileObject::resolvedPath().

Return Value

  • an MString containing the path.

MString MFileObject:: expandedFullName () const

Description

Returns the first pathname of a file constructed from the path and filename elements. All variables in the path element are expanded, and the first path (the part before the first ':' in the path) is prepended to the filename element to construct the fullName.

After expanding environment variables Maya may perform additional modifications to the full file name in order to resolve it to a valid location on disk. This resolved full file name can be accessed through MFileObject::resolvedFullName().

Return Value

  • an MString containing the filename.

MString MFileObject:: resolvedName () const

Description

Returns the resolved filename element of the MFileObject.

Return Value

  • an MString containing the filename.

MString MFileObject:: resolvedPath () const

Description

Returns the resolved path element of the MFileObject. In order to build the resolved path, Maya first expands all environment variables and then may perform additional modifications, such as prepending directories to a relative path name, in order to resolve the path to a valid location on disk.

Return Value

  • an MString containing the path.

MString MFileObject:: resolvedFullName () const

Description

Returns the first pathname of a file constructed from the path and filename elements. All variables in the path element are expanded, and the first path (the part before the first ':' in the path) is prepended to the filename element. After expanding all environment variables Maya may then perform additional modifications, such as prepending directories to a relative path name, in order to resolve the path to a valid location on disk.

Return Value

  • an MString containing the filename.

MStatus MFileObject:: setName ( const MString & fileName )

Description

Set the filename element of the MFileObject instance. This name should not contain any '/' characters, it should indicate simply the name of a file. The directories in which this name will be searched for are specified by setRawPath.

This method will be made OBSOLETE in a future release. The method MFileObject::setRawName( const MString & fileName ) should be used instead.

Arguments

  • fileName An MString containing the filename.

Return Value

  • MS::kSuccess operation successful

MStatus MFileObject:: setFullName ( const MString & fileName )

Description

This method combines the functions of the setName and setRawPath methods in that it sets both the path and filename from the given name.

If any '/' characters appear in the given name then the path element of the MFileObject is set to everything in name up to, but not including the last '/'. The filename is set to the part of name after the final '/'.

If no '/' characters appear in the given name then the path element is set to "." and the filename is set to the given name.

This method will be made OBSOLETE in a future release. The method MFileObject::setRawFullName( const MString & fileName ) should be used instead.

Arguments

  • fileName the string used to initialize the path and filename.

Return Value

  • MS::kSuccess operation successful

MString MFileObject:: name () const

Description

Returns the filename element of the MFileObject.

This method will be made OBSOLETE in a future release. The method MFileObject::resolvedName() should be used instead.

Return Value

  • an MString containing the filename.

MString MFileObject:: path () const

Description

Returns the path element of the MFileObject with all environment variables expanded.

This method will be made OBSOLETE in a future release. The methods MFileObject::expandedPath() or MFileObject::resolvedPath() should be used instead.

Return Value

  • an MString containing the path.

MString MFileObject:: fullName () const

Description

Returns the first pathname of a file constructed from the path and filename elements. All variables in the path element are expanded, and the first path (the part before the first ':' in the path) is prepended to the filename element to construct the fullName.

This method will be made OBSOLETE in a future release. The methods MFileObject::expandedFullName() or MFileObject::resolvedFullName() should be used instead.

Return Value

  • an MString containing the filename.

unsigned int MFileObject:: pathCount ()

Description

Returns the number of paths in the path element of the MFileObject. This will be equal to one more than the number of ':' characters specified by the setRawPath method.

Return Value

  • an integer containing the number of path elements.

MString MFileObject:: ithPath ( unsigned int index )

Description

Returns the indicated portion of the path element of the MFileObject. All variables in the path element are expanded, and the portion indicated by the argument is extracted and returned.

Arguments

  • index the index of the desired path portion.

Return Value

  • an MString containing the path element.

MString MFileObject:: ithFullName ( unsigned int index )

Description

Returns the pathname of a file constructed from the indicated portion of the path element and filename element. All variables in the path element are expanded, and the indicated path portion is prepended to the filename element to construct the fullName.

Arguments

  • index the index of the desired path portion.

Return Value

  • an MString containing the pathname.

bool MFileObject:: exists ()

Description

Checks to see if the file returned by the fullName method exists and is readable.

Return Value

  • bool true if the file exists and is readable and false otherwise.

bool MFileObject:: exists ( unsigned int index )

Description

Checks to see if the file constructed from the indicated portion of the path element and filename element exists and is readble.

Return Value

  • bool true if the file exists and is readable and false otherwise.

bool MFileObject:: isSet () const

Description

Checks to see if both file and path elements of the MFileObject have been set.

Return Value

  • bool true if both elements have been set and false otherwise.

This class has no child classes.


Autodesk® Maya® 8.0 © 1997-2006 Autodesk, Inc. All rights reserved. doc++ Copyright