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.

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(PIMoaFile2 This)

Parameters

This
Pointer to the IMoaFile2 interface

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

Description

Creates a new directory.

CreateFile()

Syntax

CreateFile(PIMoaFile2 This)

Parameters

This
Pointer to the IMoaFile2 interface

Returns

kMoaErr_NoErr Success
kMoaFileErr_DiskFull Create failed, disk is full
kMoaFileErr_IoError Create failed, unknown I/O error
kMoaErr_FileNotFound File not found

Description

Creates a new file.

Delete()

Syntax

Delete(PIMoaFile2 This)

Parameters

This
Pointer to the IMoaFile2 interface

Returns

kMoaErr_NoErr Success
kMoaFileErr_IoError Delete failed, unknown
kMoaErr_FileNotFound File not found
kMoaFileErr_DirectoryNotEmpty Directory specified for deletion was not empty

Description

Deletes the file or directory specifed by the underlying pathname

EnumFiles()

Syntax

EnumFiles(PIMoaFile2 This,
MoaBoolParam resolveAlias,
MoaFileEnumProc proc,
PMoaVoid pClientData))

Parameters

This
Pointer to the IMoaFile2 interface

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

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: pIMoaPathName - IMoaPathName interface to the current file isDirectory - TRUE if the file is a directory pLastModDate - The last modified date of the file pFileType - The file type as a "C" string (implementation dependent) e.g. for MAC files: "TEXT" for WIN files: "txt" for remote files: "text/html" pClientData - The client data passed in to EnumFiles

GetAccess()

Syntax

GetAccess(PIMoaFile2 This,
MoaUlong FAR * pAccessPerm))

Parameters

This
Pointer to the IMoaFile2 interface

pAccessPerm)
on return contains access perm 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

Description

Returns the access permissions for the current file in pAccessPerm.

GetCachePriority()

Syntax

GetCachePriority(PIMoaFile2 This)

Parameters

This
Pointer to the IMoaFile2 interface

Returns

MoaCachePriority

Description

Gets the cache priority of the current file. Cache priorities include: kMoaCachePriority_Always kMoaCachePriority_IfYouCan kMoaCachePriority_Never These are only useful if the underlying path object references a remote file.

GetDates()

Syntax

GetDates(PIMoaFile2 This,
MoaWide FAR * pCreate,
MoaWide FAR * pModify,
MoaWide FAR * pAccess))

Parameters

This
Pointer to the IMoaFile2 interface

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

Description

Returns the various date attributes of the current file.

GetMoaIOAttributeDict()

Syntax

GetMoaIOAttributeDict(PIMoaFile2 This,
PIMoaIOAttributeDict FAR *ppIDict))

Parameters

This
Pointer to the IMoaFile2 interface

*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. 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(PIMoaFile2 This,

PIMoaPathName FAR * ppIMoaPathName))

Parameters

This
Pointer to the IMoaFile2 interface

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(PIMoaFile2 This,
MoaUlong FAR * pFileLen)

Parameters

This
Pointer to the IMoaFile2 interface

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

Description

Returns the size of the current file in *pFileLen.

GetStream()

Syntax

GetStream(PIMoaFile2 This,
MoaUlong bufferSize,
PIMoaStream2 FAR * ppStream)

Parameters

This
Pointer to the IMoaFile2 interface

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(PIMoaFile2 This)

Parameters

This
Pointer to the IMoaFile2 interface

Returns

MoaBoolParam

Description

Returns TRUE if the underlying pathname points to a directory.

IsExisting()

Syntax

IsExisting(PIMoaFile2 This)

Parameters

This
Pointer to the IMoaFile2 interface

Returns

MoaBoolParam

Description

Returns TRUE if the object pointed to by the underlying pathname exists.

IsSameFile()

Syntax

IsSameFile(PIMoaFile2 This,
PIMoaFile2 pOther)

Parameters

This
Pointer to the IMoaFile2 interface

pOther
pointer to an IMoaFile2 interface

Returns

MoaBoolParam

Description

Returns TRUE if the current IMoaFile instance and the instance pointer passed in via pOther point to the same file or directory.

Rename()

Syntax

Rename(PIMoaFile2 This,
ConstPMoaChar pNameBuf)

Parameters

This
Pointer to the IMoaFile2 interface

pNameBuf)
point 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

Description

Renames the file or directory currently pointed to by the underlying pathname.

SetAccess()

Syntax

SetAccess(PIMoaFile2 This,
MoaUlong accessPerm)

Parameters

This
Pointer to the IMoaFile2 interface

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

Description

Used to set the access perms of the current file.

SetCachePriority()

Syntax

SetCachePriority(PIMoaFile2 This,
MoaCachePriority cacheVal))

Parameters

This
Pointer to the IMoaFile2 interface

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: kMoaCachePriority_Always kMoaCachePriority_IfYouCan kMoaCachePriority_Never 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(PIMoaFile2 This,
const MoaWide FAR * pCreate,
const MoaWide FAR * pModify,
const MoaWide FAR * pAccess))

Parameters

This
Pointer to the IMoaFile2 interface

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

Description

Sets the various date attributes of the current file.

SetPathName()

Syntax

SetPathName(PIMoaFile2 This,
const PIMoaPathName pIMoaPathName))

Parameters

This
Pointer to the IMoaFile2 interface

pIMoaPathName
pointer to an instance of IMoaPathname

Returns

kMoaErr_NoErr Success
kMoaFileErr_BadFileSpec @@@

Description

Sets the MoaFile object's underlying pathName using a previously resolved IMoaPathname object. The given PathName interface is cloned so the client doesn't have a reference to the same interface as the MoaFile2 implementation. The client should release this interface after calling SetPathName()

SetSize()

Syntax

SetSize(PIMoaFile2 This,
MoaUlong fileLen)

Parameters

This
Pointer to the IMoaFile2 interface

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

Description

Sets the current file's length to fileLen.

SetSpec()

Syntax

SetSpec(PIMoaFile2 This,
ConstPMoaChar pFullPathName))

Parameters

This
Pointer to the IMoaFile2 interface

pFullPathName
pointer to a pathName string

Returns

kMoaErr_NoErr Success

Description

Used to set the underlying pathName.

SwapFile()

Syntax

SwapFile(PIMoaFile2 This,
PIMoaFile2 pOther)

Parameters

This
Pointer to the IMoaFile2 interface

pOther
pointer to an IMoaFile2 instance

Returns

kMoaErr_NoErr Success
kMoaErr_FileNotFound File not found
kMoaFileErr_BadFileSpec One of files is a directory

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.

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