# IMCFile Struct Reference
[MCCore]

Inheritance diagram for IMCFile:

List of all members.

## Public Types
enum | EFileSeekType { eBegin, eCurrent, eEnd }
enum | EFilePermission { eRead = 1, eWrite = 2, eReadWrite = 3, eAlways }
enum | EFileSeparator { kFileTypeSeparator = ';' }
## Public Member Functions
virtual MCErr MCCOMAPI | SetWithPathName (const TMCString &aFileName, boolean isDirectory=false)=0
virtual MCErr MCCOMAPI | SetWithFullPathName (const TMCString &aFileName, boolean isDirectory=false)=0
virtual MCErr MCCOMAPI | SetWithFile (const IMCFile &aFile)=0
virtual MCErr MCCOMAPI | SetPermissions (EFilePermission dataPermission)=0
virtual boolean MCCOMAPI | Exists (void) const =0
virtual boolean MCCOMAPI | IsOpen (void) const =0
virtual void MCCOMAPI | CurrentFileInfo (APIFileInfo &info) const =0
virtual boolean MCCOMAPI | IsDirectory (void) const =0
virtual MCErr MCCOMAPI | GetFileInfo (APIFileInfo &info)=0
virtual MCErr MCCOMAPI | GetMCFileType (MCFileTypeID &outFileID) const =0
virtual MCErr MCCOMAPI | GetSize (uint32 &length)=0
virtual MCErr MCCOMAPI | GetPhysicalSize (uint32 &dataSize)=0
virtual MCErr MCCOMAPI | GetPosition (uint32 &mark)=0
virtual void MCCOMAPI | GetPermissions (EFilePermission &aPermission) const =0
virtual MCErr MCCOMAPI | GetFileFreeSpace (uint64 &freeSpace)=0
virtual MCErr MCCOMAPI | CreateOnDisk (void)=0
virtual MCErr MCCOMAPI | CreateOnDiskWithFullPath (void)=0
virtual MCErr MCCOMAPI | Remove (void)=0
virtual MCErr MCCOMAPI | Open ()=0
virtual MCErr MCCOMAPI | Close (void)=0
virtual void MCCOMAPI | SetIsResourceFork (boolean isResourceFork)=0
| Sets whether the file represents a resource fork and should be opened as such.
virtual boolean MCCOMAPI | IsResourceFork (void) const =0
| Tells if this file is a resourcefork.
virtual MCErr MCCOMAPI | Flush (void)=0
virtual MCErr MCCOMAPI | Rename (const TMCString &newName)=0
virtual MCErr MCCOMAPI | Read (void *buffer, uint32 readAmount, uint32 *bytesRead=nil)=0
virtual MCErr MCCOMAPI | Write (const void *buffer, uint32 writeAmount, uint32 *bytesWritten=nil)=0
virtual MCErr MCCOMAPI | Seek (int32 distance, EFileSeekType startPoint)=0
virtual MCErr MCCOMAPI | SetEOF (uint32 newLength)=0
virtual void MCCOMAPI | GetFileName (TMCString &pathName) const =0
virtual void MCCOMAPI | GetPathName (TMCString &pathName) const =0
virtual void MCCOMAPI | GetFileFullPathName (TMCString &pathName) const =0
virtual void MCCOMAPI | GetFileURL (TMCString &outURL) const =0
virtual void MCCOMAPI | GetUnixFullPathName (TMCString &outUnixPathName) const =0
virtual void MCCOMAPI | GetParentFolderPath (TMCString &outParentPath) const =0
virtual void MCCOMAPI | GetBaseName (TMCString &baseName) const =0
virtual void MCCOMAPI | SetBaseName (const TMCString &baseName)=0
virtual void MCCOMAPI | GetRelativeFileName (TMCString &theRelFileName, const TMCString &rootName)=0
virtual void MCCOMAPI | SetWithRelativeFileName (const TMCString &theRelFileName, const TMCString &rootName, boolean isDirectory=false)=0
virtual MCErr MCCOMAPI | SetMCFileType (const MCFileTypeID &inFileID)=0
virtual void MCCOMAPI | SetReadOnly (const boolean inReadOnly)=0
virtual void MCCOMAPI | SetModificationTime (const TMCSystemTime &inModificationTime)=0
virtual void MCCOMAPI | SetMacTypeAndCreator (const TMCFileID *inMacType, const IDType *inMacCreator)=0
virtual MCErr MCCOMAPI | SetExtension (const TMCString &extension)=0
virtual void MCCOMAPI | GetExtension (TMCString &extension) const =0
virtual boolean MCCOMAPI | IsSameAs (const IMCFile &aFile)=0
virtual MCErr MCCOMAPI | CopyTo (IMCFile &toFile)=0
virtual CFileHandleType MCCOMAPI | GetFileHandle ()=0

## Detailed Description

IMCFile is the interface to access a file.

To create an IMCFile, use IShFileUtilities::CreateIMCFile():

     TMCCountedPtr<IMCFile> file;
     gFileUtilities->CreateIMCFile(&file);

## Member Enumeration Documentation

enum IMCFile::EFilePermission

Enumerator:

  eRead |
  eWrite |
  eReadWrite |
  eAlways |

enum IMCFile::EFileSeekType

Enumerator:

  eBegin |
  eCurrent |
  eEnd |

enum IMCFile::EFileSeparator

Enumerator:

  kFileTypeSeparator |

## Member Function Documentation

virtual MCErr MCCOMAPI IMCFile::Close | ( | void |  | ) | `[pure virtual]`

Closes the file.

virtual MCErr MCCOMAPI IMCFile::CopyTo | ( | IMCFile & | toFile | ) | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::CreateOnDisk | ( | void |  | ) | `[pure virtual]`

Creates the file/folder on the disk. (The parent folder must exist)

virtual MCErr MCCOMAPI IMCFile::CreateOnDiskWithFullPath | ( | void |  | ) | `[pure virtual]`

Creates the file/folder on the disk. The parent folders are created if needed

virtual void MCCOMAPI IMCFile::CurrentFileInfo | ( | APIFileInfo & | info | ) | const`[pure virtual]`

Returns information about the file (data of modification...)

virtual boolean MCCOMAPI IMCFile::Exists | ( | void |  | ) | const`[pure virtual]`

Returns true if the file exists on the disk.

virtual MCErr MCCOMAPI IMCFile::Flush | ( | void |  | ) | `[pure virtual]`

Writes all the data to the disk.

virtual void MCCOMAPI IMCFile::GetBaseName | ( | TMCString & | baseName | ) | const`[pure virtual]`

Returns the base name of the file, ie the file name without any extension.

Parameters:

  | baseName |

virtual void MCCOMAPI IMCFile::GetExtension | ( | TMCString & | extension | ) | const`[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::GetFileFreeSpace | ( | uint64 & | freeSpace | ) | `[pure virtual]`

virtual void MCCOMAPI IMCFile::GetFileFullPathName | ( | TMCString & | pathName | ) | const`[pure virtual]`

virtual CFileHandleType MCCOMAPI IMCFile::GetFileHandle | ( |  | ) | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::GetFileInfo | ( | APIFileInfo & | info | ) | `[pure virtual]`

Returns information about the file (data of modification...)

virtual void MCCOMAPI IMCFile::GetFileName | ( | TMCString & | pathName | ) | const`[pure virtual]`

virtual void MCCOMAPI IMCFile::GetFileURL | ( | TMCString & | outURL | ) | const`[pure virtual]`

Returns fullpathname as a file URL (file://...)

Parameters:

  | outURL | The URL that is returned.

virtual MCErr MCCOMAPI IMCFile::GetMCFileType | ( | MCFileTypeID & | outFileID | ) | const`[pure virtual]`

Returns the file type associated with this file.

virtual void MCCOMAPI IMCFile::GetParentFolderPath | ( | TMCString & | outParentPath | ) | const`[pure virtual]`

Returns the path of the folder containing this file (or folder) If endBySeparator is true, the last char of the string is the path separator

Parameters:

  | outParentPath |

virtual void MCCOMAPI IMCFile::GetPathName | ( | TMCString & | pathName | ) | const`[pure virtual]`

virtual void MCCOMAPI IMCFile::GetPermissions | ( | EFilePermission & | aPermission | ) | const`[pure virtual]`

Returns the read/write permissions

virtual MCErr MCCOMAPI IMCFile::GetPhysicalSize | ( | uint32 & | dataSize | ) | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::GetPosition | ( | uint32 & | mark | ) | `[pure virtual]`

virtual void MCCOMAPI IMCFile::GetRelativeFileName | ( | TMCString & | theRelFileName,
|  | const TMCString & | rootName |
| ) |  |  | `[pure virtual]`

Incomplete relative path support: it works only if theRelFileName is in a subfolder of rootName

Example:

- rootName = "C:\EOVIA\CARRARA\"
- theRelFileName= "C:\EOVIA\CARRARA\EXTENSIONS\PLUGINS" becomes "\EXTENSIONS\PLUGINS"

However:

- theRelFileName= "C:\PROGRAM FILES\" is unchanged

Parameters:

  | theRelFileName | The path to make "relative" to rootName
  | rootName | The base path to remove from theRelFileName

virtual MCErr MCCOMAPI IMCFile::GetSize | ( | uint32 & | length | ) | `[pure virtual]`

Returns the size of the file.

Parameters:

  | length | The size of the file.

virtual void MCCOMAPI IMCFile::GetUnixFullPathName | ( | TMCString & | outUnixPathName | ) | const`[pure virtual]`

Returns fullpathname as a unix file path (MACOSX only)

Parameters:

  | outUnixPathName | The unix path for the file.

virtual boolean MCCOMAPI IMCFile::IsDirectory | ( | void |  | ) | const`[pure virtual]`

Returns true if the file is a directory.

virtual boolean MCCOMAPI IMCFile::IsOpen | ( | void |  | ) | const`[pure virtual]`

Returns true if the file is already opened.

virtual boolean MCCOMAPI IMCFile::IsResourceFork | ( | void |  | ) | const`[pure virtual]`

Tells if this file is a resourcefork.

virtual boolean MCCOMAPI IMCFile::IsSameAs | ( | const IMCFile & | aFile | ) | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::Open | ( |  | ) | `[pure virtual]`

Opens a file using the permissions specified in SetPermissions

Note: When opening the file to write, the file size is not reset to 0. You need to call SetEOF for that purpose.

virtual MCErr MCCOMAPI IMCFile::Read | ( | void * | buffer,
|  | uint32 | readAmount,
|  | uint32 * | bytesRead = `nil` |
| ) |  |  | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::Remove | ( | void |  | ) | `[pure virtual]`

Delete the file from the disk.

virtual MCErr MCCOMAPI IMCFile::Rename | ( | const TMCString & | newName | ) | `[pure virtual]`

Renames the file.

Parameters:

  | newName | The new name of the file.

virtual MCErr MCCOMAPI IMCFile::Seek | ( | int32 | distance,
|  | EFileSeekType | startPoint |
| ) |  |  | `[pure virtual]`

virtual void MCCOMAPI IMCFile::SetBaseName | ( | const TMCString & | baseName | ) | `[pure virtual]`

Sets the base name of the file, ie the file name without any extension.

Parameters:

  | baseName | The new base name of the file.

virtual MCErr MCCOMAPI IMCFile::SetEOF | ( | uint32 | newLength | ) | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::SetExtension | ( | const TMCString & | extension | ) | `[pure virtual]`

virtual void MCCOMAPI IMCFile::SetIsResourceFork | ( | boolean | isResourceFork | ) | `[pure virtual]`

Sets whether the file represents a resource fork and should be opened as such.

virtual void MCCOMAPI IMCFile::SetMacTypeAndCreator | ( | const TMCFileID * | inMacType,
|  | const IDType * | inMacCreator |
| ) |  |  | `[pure virtual]`

Sets the mac file type and creator (unfortunately still needed) A null pointer won't change the info

virtual MCErr MCCOMAPI IMCFile::SetMCFileType | ( | const MCFileTypeID & | inFileID | ) | `[pure virtual]`

virtual void MCCOMAPI IMCFile::SetModificationTime | ( | const TMCSystemTime & | inModificationTime | ) | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::SetPermissions | ( | EFilePermission | dataPermission | ) | `[pure virtual]`

Sets the read/write permission for this file.

Parameters:

  | dataPermission | The permissions (see EFilePermission).

virtual void MCCOMAPI IMCFile::SetReadOnly | ( | const boolean | inReadOnly | ) | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::SetWithFile | ( | const IMCFile & | aFile | ) | `[pure virtual]`

Sets the file path from another file.

Parameters:

  | aFile | The file from which we get the path.

virtual MCErr MCCOMAPI IMCFile::SetWithFullPathName | ( | const TMCString & | aFileName,
|  | boolean | isDirectory = `false` |
| ) |  |  | `[pure virtual]`

Sets the full path name of the file.

Parameters:

  | aFileName | The full path name of the file.
  | isDirectory | True if the file is a directory.

virtual MCErr MCCOMAPI IMCFile::SetWithPathName | ( | const TMCString & | aFileName,
|  | boolean | isDirectory = `false` |
| ) |  |  | `[pure virtual]`

Sets the full path name (path of the folder).

Parameters:

  | aFileName | The full path name of the folder.
  | isDirectory | True if the file is a directory.

virtual void MCCOMAPI IMCFile::SetWithRelativeFileName | ( | const TMCString & | theRelFileName,
|  | const TMCString & | rootName,
|  | boolean | isDirectory = `false` |
| ) |  |  | `[pure virtual]`

virtual MCErr MCCOMAPI IMCFile::Write | ( | const void * | buffer,
|  | uint32 | writeAmount,
|  | uint32 * | bytesWritten = `nil` |
| ) |  |  | `[pure virtual]`

The documentation for this struct was generated from the following file:

- IMCFile.h