MF Developer's Guide
MF Interfaces | MF Methods | MF Types and Misc API

IMoaFile2

Interface ID: IID_IMoaFile2
Pointer type: PIMoaFile2
Inheritance: IMoaUnknown
Header file: moafile2.h
Description
The IMoaFile2 interface provides high level cross platform access to the filesystem via MOA. It is functionally a superset of the original IMoaFile interface, but not a direct superset of IMoaFile. Note that some methods may not be implemented for a particular IMoaFile2 object, so be sure to check the return value for errors. For example, the GetCachePriority() method only applies to remote files and the CreateFile() method is not defined for remote files.

Methods

SetSpec()
SetPathName()
GetPathName()
GetStream()
GetSize()
SetSize()
GetAccess()
SetAccess()
GetDates()
SetDates()
GetCachePriority()
SetCachePriority()
IsDirectory()
IsExisting()
GetMoaIOAttributeDict()
CreateFile()
CreateDirectory()
Delete()
SwapFile()
IsSameFile()
EnumFiles()
Rename()

CreateDirectory()

Syntax
CreateDirectory()
Parameters
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound File not found
kMoaFileErr_IoError Create failed, unknown
kMoaFileErr_DiskFull Create failed, disk is full
kMoaFileErr_DuplicateSpec Directory already exists
kMoaErr_NotImplemented Method not available for this object
Description
Creates a new directory.

CreateFile()

Syntax
CreateFile()
Parameters
Returns
kMoaErr_NoErr Success
kMoaFileErr_DiskFull Create failed, disk is full
kMoaFileErr_IoError Create failed, unknown I/O error
kMoaErr_FileNotFound File not found
kMoaErr_NotImplemented Method not available for this object
Description
Creates a new file.

Delete()

Syntax
Delete()
Parameters
Returns
kMoaErr_NoErr Success
kMoaFileErr_IoError Delete failed, unknown
kMoaErr_FileNotFound File not found
kMoaFileErr_DirectoryNotEmpty Directory specified for deletion was not empty
kMoaErr_NotImplemented Method not available for this object
Description
Deletes the file or directory specifed by the underlying pathname

EnumFiles()

Syntax
EnumFiles(MoaBoolParam resolveAlias, MoaFileEnumProc proc, PMoaVoid pClientData)
Parameters
resolveAlias
resolve flag
proc
proc pointer to be called for each file/directory
pClientData
client data
Returns
kMoaErr_NoErr Success
kMoaErr_BadParam You passed me a bogus argument
kMoaErr_NotImplemented
kMoaErr_NotEnoughSSW
Method not available for this object
Description
Enumerates all entries in the current directory. For each entry in the current directory, the procedure provided via proc is called. The following data are passed to the callback procedure:

This method is not implemented in Director and always returns either kMoaErr_NotImplemented or kMoaErr_NotEnoughSSW

GetAccess()

Syntax
GetAccess(MoaUlong * pAccessPerm)
Parameters
pAccessPerm
on return contains access permissions for the current file
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound Could not find the file
kMoaFileErr_BadFileSpec underlying pathname is invalid
kMoaFileErr_IoError Unknown I/O error
kMoaErr_NotImplemented Method not available for this object
Description
Returns the access permissions for the current file in pAccessPerm.

GetCachePriority()

Syntax
GetCachePriority()
Parameters
Returns
MoaCachePriority
Description
Gets the cache priority of the current file. Cache priorities include: These are only useful if the underlying path object references a remote file.

GetDates()

Syntax
GetDates(MoaWide * pCreate, MoaWide * pModify, MoaWide * pAccess)
Parameters
pCreate
on return contains creation date
pModify
on return contains last modified date
pAccess
on return contains last access date
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound Could not find the file
kMoaFileErr_BadFileSpec underlying pathname is invalid
kMoaFileErr_IoError Unknown I/O error
kMoaErr_NotImplemented Method not available for this object
Description
Returns the various date attributes of the current file.

GetMoaIOAttributeDict()

Syntax
GetMoaIOAttributeDict(PIMoaIOAttributeDict *ppIDict)
Parameters
ppIDict
on return contains pointer to an IMoaDict interface
Returns
kMoaErr_NoErr Success or standard MOA QueryInterface errors
Description
Returns an interface the an IMoaIOAttribute interface. This interface is used to access the various file attributes of the object pointed to by the underlying pathname. Note that this interface is identical to IMoaDict. The client is responsible for releasing this interface when done. See Types and Miscellaneous API for a complete listing of the attribute dictionary entries and their values.

GetPathName()

Syntax
GetPathName(PIMoaPathName * ppIMoaPathName)
Parameters
ppIMoaPathName
on return contains a pointer to an IMoaPathName instance
Returns
kMoaErr_NoErr Success or standard MOA QueryInterface errors
Description
Returns a pointer to an instance of the IMoaPathName interface. This interface is a clone of the underlying PathName interface. It can be used to set the filename, path and other details of the target file using the SetPathName() method. The client is responsible for releasing this interface when done.

GetSize()

Syntax
GetSize(MoaUlong * pFileLen)
Parameters
pFileLen
on return contains file size
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound Could not find the file
kMoaFileErr_BadFileSpec underlying pathname is invalid
kMoaFileErr_IoError Unknown I/O error
kMoaErr_NotImplemented Method not available for this object
Description
Returns the size of the current file in *pFileLen.

GetStream()

Syntax
GetStream(MoaUlong bufferSize, PIMoaStream2 * ppStream)
Parameters
bufferSize
buffer size of the stream
ppStream
on return contains a pointer to an IMoaStream2 interface
Returns
kMoaErr_NoErr Success or standard MOA QueryInterface errors
Description
Used to acquire an IMoaStream2 interface to the current file. The client is responsible for releasing this interface when done.

IsDirectory()

Syntax
IsDirectory()
Parameters
Returns
MoaBoolParam
Description
Returns TRUE if the underlying pathname points to a directory. This method does not apply to remote files.

IsExisting()

Syntax
IsExisting()
Parameters
Returns
MoaBoolParam
Description
Returns TRUE if the object pointed to by the underlying pathname exists. This method does not apply to remote files.

IsSameFile()

Syntax
IsSameFile(PIMoaFile2 pOther)
Parameters
pOther
pointer to an IMoaFile2 interface
Returns
MoaBoolParam
Description
This method is not implemented in Director and actually returns either kMoaErr_NotImplemented or kMoaErr_NotEnoughSSW

Rename()

Syntax
Rename(ConstPMoaChar pNameBuf)
Parameters
pNameBuf
pointer to string containing new name
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound File not found
kMoaFileErr_FileBusy File in use
kMoaFileErr_IoError Unknown I/O error
kMoaErr_NotImplemented Method not available for this object
Description
Renames the file or directory currently pointed to by the underlying pathname.

SetAccess()

Syntax
SetAccess(MoaUlong accessPerm)
Parameters
accessPerm
new access permissions for current file
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound Could not find the file
kMoaFileErr_BadFileSpec underlying pathname is invalid
kMoaFileErr_IoError Unknown I/O error
kMoaErr_NotImplemented Method not available for this object
Description
Used to set the access perms of the current file.

SetCachePriority()

Syntax
SetCachePriority(MoaCachePriority cacheVal)
Parameters
cacheVal
new cache priority constant
Returns
kMoaErr_NoErr Success
kMoaErr_BadParam You passed me a bogus argument
Description
Sets the cache priority of the current file. Cache priorities include: These are only useful if the underlying path object references a remote file. All implementations are required to support get/set cache priority even if the implementation doesn't deal with remote files.

SetDates()

Syntax
SetDates(const MoaWide * pCreate, const MoaWide * pModify, const MoaWide * pAccess)
Parameters
pCreate
creation date
pModify
modified date
pAccess
access date
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound Could not find the file
kMoaFileErr_BadFileSpec underlying pathname is invalid
kMoaFileErr_IoError Unknown I/O error
kMoaErr_NotImplemented Method not available for this object
Description
Sets the various date attributes of the current file.

SetPathName()

Syntax
SetPathName(const PIMoaPathName pIMoaPathName)
Parameters
pIMoaPathName
pointer to an instance of IMoaPathname
Returns
kMoaErr_NoErr Success or standard MOA CreateInterface errors
Description
Sets the IMoaFile2 object's underlying pathName using a previously resolved IMoaPathname object. The given IMoaPathname interface is cloned so the client doesn't have a reference to the same interface as the IMoaFile2 implementation. The client should release this interface after calling SetPathName()

SetSize()

Syntax
SetSize(MoaUlong fileLen)
Parameters
fileLen
new size of file
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound Could not find the file
kMoaFileErr_BadFileSpec underlying pathname is invalid
kMoaFileErr_DiskFull Create failed, disk is full
kMoaFileErr_IoError Unknown I/O error
kMoaErr_NotImplemented Method not available for this object
Description
Sets the current file's length to fileLen.

SetSpec()

Syntax
SetSpec(ConstPMoaChar pFullPathName)
Parameters
pFullPathName
pointer to a pathName string
Returns
kMoaErr_NoErr Success
Description
Used to set the underlying pathName. Prior to Director 11, if you pass in a partial path in pFullPathName such as "somefile.txt", the resulting object would reference a file of that name in the folder where the Director Application is located. With Director 11 on Macintosh, using such a partial reference will result in an invalid file reference. You can use the folderName player property to find out the folder containing the host application.

SwapFile()

Syntax
SwapFile(PIMoaFile2 pOther)
Parameters
pOther
pointer to an IMoaFile2 instance
Returns
kMoaErr_NoErr Success
kMoaErr_FileNotFound File not found
kMoaFileErr_BadFileSpec One of files is a directory
kMoaErr_NotImplemented
kMoaErr_NotEnoughSSW
Method not available for this object
Description
Exchanges the files specified by the two IMoaFile2 instances (this and pOther). If pOther doesn't exist, the file specified by "this" is moved to the pathname specified by pOther.

This method is not implemented in Director and returns either kMoaErr_NotImplemented or kMoaErr_NotEnoughSSW

Copyright © 1995-2008 Adobe Macromedia Software LLC, Inc.