DL Logo

ASFile Definitions

ASFILE_CREATE

Header: ASExpT.h:1501

Description

Create the file if it does not exist.

Syntax

#define ASFILE_CREATE 4

ASFILE_ENCRYPT

Header: ASExpT.h:1531

Description

File is to be encrypted when written to disk Encryption is with an instance specific key, so that the file is NOT readable if it is accidentally left when Acrobat exits (say, on a crash)

Syntax

#define ASFILE_ENCRYPT 128

ASFILE_LOCAL

Header: ASExpT.h:1511

Description

A hint indicating that a local copy of the file will be needed.

Syntax

#define ASFILE_LOCAL 16

ASFILE_RANDOMACCESS

Header: ASExpT.h:1516

Description

A hint indicating that the file will be primarily accessed randomly.

Syntax

#define ASFILE_RANDOMACCESS 32

ASFILE_READ

Header: ASExpT.h:1491

Description

Open the file for reading.

Syntax

#define ASFILE_READ 1

ASFILE_SERIAL

Header: ASExpT.h:1506

Description

A hint indicating that the file will be primarily accessed sequentially.

Syntax

#define ASFILE_SERIAL 8

ASFILE_TEMPORARY

Header: ASExpT.h:1523

Description

A hint that file is for temporary usage. Disk backing store is deleted on close, writes are not flushed to disk on close. If possible the file will be kept in memory.

Syntax

#define ASFILE_TEMPORARY 64

ASFILE_WRITE

Header: ASExpT.h:1496

Description

Open the file for writing.

Syntax

#define ASFILE_WRITE 2

MDFile

Header: ASExpT.h:1931

Syntax

#define MDFile ASMDFile

kASFileDialUp

Header: ASExpT.h:1562

Description

Set if media/access is a dial up connection. This flag is only fully implemented on Windows. On Mac OS, this flag is always conservatively set to true.

Syntax

#define kASFileDialUp 0x00000010L

kASFileDoCaching

Header: ASExpT.h:1555

Description

Set if the file is to be cached (requires kASFileUseMRead to be set as well).

Syntax

#define kASFileDoCaching 0x00000008L

kASFileHasOutstandingMReads

Header: ASExpT.h:1572

Description

true if the file has outstanding MReads.

Syntax

#define kASFileHasOutstandingMReads 0x00000040L

kASFileHasVirtualEOF

Header: ASExpT.h:1577

Description

true if the file is built with a Virtual EOF (Acrobat 10).

Syntax

#define kASFileHasVirtualEOF 0x00000080L

kASFileModeDisableExplicitMReadRequests

Header: ASExpT.h:1592

Description

If set, the file will be read all at once regardless of multiple read requests.

Syntax

#define kASFileModeDisableExplicitMReadRequests 0x0002

kASFileModeDoNotYieldIfBytesNotReady

Header: ASExpT.h:1585

Description

If set, ASFileRead does not yield if bytes are not ready (which raises the fileErrBytesNotReady exception).

Syntax

#define kASFileModeDoNotYieldIfBytesNotReady 0x0001

kASFileNoRequestIfBytesNotReady

Header: ASExpT.h:1605

Description

If set, no read requests are issued if bytes are not ready (that is, the bytes are not in the cache).

Syntax

#define kASFileNoRequestIfBytesNotReady 0x0008

kASFileRaiseIfBytesNotReady

Header: ASExpT.h:1599

Description

If set, ASFileRead will raise the fileErrBytesNotReady exception when trying to read from a file with a cache for which the requested bytes are not yet present.

Syntax

#define kASFileRaiseIfBytesNotReady 0x0004

kASFileSlowConnect

Header: ASExpT.h:1545

Description

Set if initiating each access to the file is slow. For example, access may be slow because the file is served by an HTTP server that spawns a new process for each request.

Syntax

#define kASFileSlowConnect 0x00000002L

kASFileSlowTransfer

Header: ASExpT.h:1537

Description

Set if the file's data transfer rate is generally slow.

Syntax

#define kASFileSlowTransfer 0x00000001L

kASFileStillFetching

Header: ASExpT.h:1567

Description

Set if the file is still being loaded.

Syntax

#define kASFileStillFetching 0x00000020L

kASFileSuspendIfBytesNotReady

Header: ASExpT.h:1614

Description

If set, ASFileRead will suspend the current thread when trying to read from a file with a cache for which the requested bytes are not yet present. Note that if kASFileSuspendIfBytesNotReady is set, the kASFileRaiseIfBytesNotReady is ignored.

Syntax

#define kASFileSuspendIfBytesNotReady 0x0010

kASFileUseMRead

Header: ASExpT.h:1550

Description

Use multi-read commands to access the file.

Syntax

#define kASFileUseMRead 0x00000004L

ASFile Enumerations

ASFileStatusFlags

Header: ASExpT.h:1946

Description

Values returned by ASFileSysGetStatusProc().

Enum Constants

kASFileOkay=0x0000
The MDFile is in a valid state.
kASFileIsTerminating=0x0001
The MDFile is being closed (for example, because the file is being displayed in a web browser's window and the user cancelled downloading).

ASFile Typedefs

ASFile

Header: ASExpT.h:1863

Description

An opaque representation of a particular open file. Each open file has a unique ASFile. The ASFile value has meaning only to the common ASFile implementation and bears no relationship to platform-specific file objects.

Syntax

typedef void *ASFile;

Returned From

Used By

Used In

ASFileOffset

Header: ASExpT.h:101

Description

A file offset value for use in callback procedures.

Syntax

typedef ASInt32 ASFileOffset;

Used By

ASFileOffset64

Header: ASExpT.h:102

Syntax

typedef ASInt64 ASFileOffset64;

Used By

ASFilePos

Header: ASExpT.h:95

Description

A file position value for use in callback procedures. This value cannot exceed 2 GB.

Syntax

typedef ASUns32 ASFilePos;

Used By

ASFilePos64

Header: ASExpT.h:105

Description

The absolute position within a file. This value can exceed 2 GB.

Syntax

typedef ASUns64 ASFilePos64;

Returned From

Used By

ASMDFile

Header: ASExpT.h:1929

Description

ASMDFile replaces MDFile. MDFile is an obsolete name for this data type for backward compatibility.

An MDFile is an opaque representation of a file instance for a particular file system. File system implementors may choose any convenient representation for an MDFile. In particular, file systems need not worry about MDFile space conflicts; the ASFile object exported by the common implementation is guaranteed to be unique across all open files, and the common implementation maps calls of ASFile methods to calls of ASFileSystem callbacks with the corresponding MDFile.

Syntax

typedef void *ASMDFile;

Used By

Used In

ASTFilePos

Header: ASExpT.h:204

Description

A numeric count value for use in I/O methods and data structures.

Syntax

typedef ASInt32 ASTFilePos;

ASTFilePos

Header: ASExpT.h:283

Syntax

typedef ASUns32 ASTFilePos;

Returned From

Used By

Used In

ASFile Callback Signatures

ASFileCompletionProc

Header: ASExpT.h:1887

Description

Called when an asynchronous read or write request has completed.

Syntax

void ASFileCompletionProc(ASFile aFile, const char *p, ASTFilePos fileOffsetRequested, ASTArraySize countRequested, ASTArraySize nBytesRead, ASErrorCode error, void *compProcClientData);

Parameters

aFile
IN/OUT The ASFile for which data is read or written.
p
IN/OUT A pointer to the buffer provided by the client. It contains nBytesRead bytes of data if error is zero.
fileOffsetRequested
IN/OUT The file offset requested by the client.
countRequested
IN/OUT The number of bytes requested by the client.
nBytesRead
IN/OUT The number of bytes actually read or written.
error
IN/OUT The error condition if it is non-zero; see AcroErr.h.
compProcClientData
IN/OUT The client data parameter provided by client.

ASFile Functions

ASFileAcquirePathName

Header: ASProcs.h:1025

Description

Gets the path name for a file and increments an internal reference count. It is the caller's responsibility to release the ASPathName when it is no longer needed by using ASFileSysReleasePath().

Related Methods

Syntax

ASPathName ASFileAcquirePathName(ASFile aFile);

Parameters

aFile
IN/OUT The file whose path name is acquired.

Returns

The ASPathName associated with asFile. You can use ASFileSysDIPathFromPath() to convert this to a device-independent path name.

ASFileCanSetEOF

Header: ASProcs.h:2481

Description

Checks if ASFileSetEOF() can be done for this file with a specified new file size.

Syntax

ASBool ASFileCanSetEOF(ASFile file, ASInt32 newFileSize);

Parameters

file
The file in question.
newFileSize
The proposed new file size. This parameter will be treated as unsigned.

ASFileClearOutstandingMReads

Header: ASProcs.h:1850

Description

Clears all outstanding mreads for the given file.

Syntax

void ASFileClearOutstandingMReads(ASFile fN);

Parameters

fN
The file to clear mreads for.

ASFileClose

Header: ASProcs.h:899

Description

Closes the specified file. After a call to ASFileClose(), the file handle is no longer valid but may be reused as the result of a subsequent call to ASFileSysOpenFile().

Syntax

ASErrorCode ASFileClose(ASFile aFile);

Parameters

aFile
IN/OUT The file to close. The file must have been opened previously using ASFileSysOpenFile().

Returns

0 if the operation was successful; some file system or platform-dependent error code is returned otherwise.

ASFileFlush

Header: ASProcs.h:1012

Description

Flushes any buffered data to a file. This method may raise file system or platform-specific exceptions.

Related Methods

Syntax

void ASFileFlush(ASFile aFile);

Parameters

aFile
The file whose data is flushed.

Exceptions

ASFileFromMDFile

Header: ASProcs.h:1268

Description

Gets the ASFile associated with the specified ASMDFile and ASFileSys.

Syntax

ASBool ASFileFromMDFile(ASMDFile mdFile, ASFileSys fileSys, ASFile *pfN);

Parameters

mdFile
IN/OUT The ASMDFile for which the information is desired.
fileSys
IN/OUT The ASFileSys through which fileID was opened.
pfN
IN/OUT (Filled by the method, may be NULL) The ASFile representing fileID within fileSys.

Returns

true if fileID is determined to be a valid file opened through fileSys, false otherwise.

ASFileGetEOF

Header: ASProcs.h:964

Description

Gets the current size of a file. It calls ASFileSysGetEofProc(). This call returns an error if the file size is greater than 2 GB.

Syntax

ASTFilePos ASFileGetEOF(ASFile aFile);

Parameters

aFile
The ASFile whose size is obtained.

Returns

The size of the file.

Exceptions

ASFileGetEOF64

Header: ASProcs.h:2759

Description

Gets the current size of a file.

Syntax

ASFilePos64 ASFileGetEOF64(ASFile aFile);

Parameters

aFile
IN/OUT The ASFile whose size is obtained. This call will work with files over 2 GB in length.

Returns

The size of the file.

Exceptions

ASFileGetFileSys

Header: ASProcs.h:1036

Description

Gets the file system through which a file was opened.

Related Methods

Syntax

ASFileSys ASFileGetFileSys(ASFile aFile);

Parameters

aFile
IN/OUT The open file whose file system is obtained.

Returns

The file's ASFileSys.

ASFileGetFileSysByName

Header: ASProcs.h:1250

Description

Gets the file system that was registered with the specified name.

Related Methods

Syntax

ASFileSys ASFileGetFileSysByName(ASAtom name);

Parameters

name
IN/OUT The ASAtom corresponding to the name of the file system to obtain. It may be one of the following:
String
Description
"Mac_K"
Mac OS file system
"DOS_K"
Classic Windows file system (it only supports host-encoded paths)
"Win_K"
Unicode Windows file system
"Unix_K"
UNIX file system
"CHTTP"
HTTP file system
"CDocumentum"
Documentum file system
"CODMA"
Open Document Management file system

Returns

The file system, otherwise NULL if no matching file system was found.

ASFileGetMDFile

Header: ASProcs.h:1287

Description

Given an ASFile, returns the fileSys and the ASMDFile identification in that fileSys. This call is needed for a file system in a plug-in to be able to call the inner routines in another file system.

Syntax

ASBool ASFileGetMDFile(ASFile fN, ASMDFile *pFileID, ASFileSys *pFileSys);

Parameters

fN
IN/OUT The ASFile for which the information is desired.
pFileID
IN/OUT (Filled by the method, may be NULL) The ASMDFile identifier associated with file.
pFileSys
IN/OUT (Filled by the method, may be NULL) The file system through which this file was opened.

Returns

true if the file is an open file, false otherwise.

ASFileGetOpenMode

Header: ASProcs.h:1931

Description

Gets the file access mode(s) specified for the file when it was opened.

Syntax

ASFileMode ASFileGetOpenMode(ASFile fN);

Parameters

fN
The file in question.

Returns

A value corresponding to one or more ASFileMode objects used to access or create the file, as shown in the table below. The values that can be returned include combinations of the following, OR'd with each other:

Return value from ASFileGetOpenMode():

Return value

Meaning
0
created
1
readable
2
readable and writable
8
sequential access
16
local

ASFileGetPos

Header: ASProcs.h:932

Description

Gets the current seek position in a file. This is the position at which the next read or write will begin. This call returns an error if the file position is greater than 2 GB.

Syntax

ASTFilePos ASFileGetPos(ASFile aFile);

Parameters

aFile
IN/OUT The file in which to get the seek position.

Returns

The current seek position.

Exceptions

ASFileGetPos64

Header: ASProcs.h:2731

Description

Gets the current seek position in a file. This is the position at which the next read or write will begin. This call will work with files over 2 GB in length.

Syntax

ASFilePos64 ASFileGetPos64(ASFile aFile);

Parameters

aFile
IN/OUT The file in which to get the seek position.

Returns

The current seek position.

Exceptions

ASFileGetURL

Header: ASProcs.h:1878

Description

Returns the URL associated with file. It is the caller's responsibility to release the memory associated with the returned string using ASfree().

Syntax

char *ASFileGetURL(ASFile asf);

Parameters

asf
IN/OUT The file in question.

Returns

A buffer containing the URL, or NULL if it could not be determined. On all file systems, the path will be URL-escaped. On the default file system, encoding will be platform-encoded. On Unicode and browser file systems, encoding will be UTF8.

ASFileHardFlush

Header: ASProcs.h:2059

Description

Causes a hard flush on a file, which means that the file is flushed to the physical destination. For example, if a WebDAV-based file is opened, ASFileFlush() only flushes changes to the local cached version of the file. This method would flush changes all the way to the WebDAV server.

Related Methods

Syntax

ASErrorCode ASFileHardFlush(ASFile aFile);

Parameters

aFile
The file that is flushed.

Returns

0 if the operation succeeded,-1 if there was an error.

ASFileHasOutstandingMReads

Header: ASProcs.h:2470

Description

Determines whether there are any outstanding multi-byte range requests for a file. A document can have outstanding mreads if it was opened in a browser, Acrobat requested some byte ranges, and the byte ranges have not yet arrived.

Syntax

ASBool ASFileHasOutstandingMReads(ASFile fN);

Parameters

fN
The file in question.

Returns

true if the file has outstanding mreads, false otherwise.

ASFileIsSame

Header: ASProcs.h:1746

Description

Performs a comparison between the file and path to determine if they represent the same file. This method will return false if the file was not opened through the fileSys file system.

Note: This method is not guaranteed to work on all file systems.

Syntax

ASBool ASFileIsSame(ASFile fN, ASPathName pathName, ASFileSys fileSys);

Parameters

fN
IN/OUT The file in question.
pathName
IN/OUT The ASPathName in question.
fileSys
IN/OUT The file system from which the path was obtained.

Returns

false if the comparison fails, true otherwise.

ASFileMReadRequest

Header: ASProcs.h:1842

Description

Initiates a byte range request for a given file, if the file is in the browser.

Syntax

void ASFileMReadRequest(ASFile fN, ASInt32 *blockPairs, ASTCount nBlockPairs);

Parameters

fN
The file for which you wish to make read requests.
blockPairs
The array of ASInt32 pairs. The first ASInt32 in the pair is the offset into the file to read, and the second ASInt32 is the length of the range to request.
nBlockPairs
The number of block pairs to request.

ASFileOpenWithVirtualEOF

Header: ASProcs.h:3036

Description

ASFileOpenWithVirtualEOF attempts to create a second ASFile instance to a file that is already open. Both the current instance fN and the new instance must be read only. The new instance shall set a virtual end of file. This virtual EOF and no effect on the first instance or on the physical file. It only effect the ASFile calls where newFile is passed in has the file. Each instance maintains it's own file position marker. The original instance of the file should be close after all other instances have been closed. This routine does not raise, but returns an error code.

Syntax

ASInt32 ASFileOpenWithVirtualEOF(ASFile fN, ASFilePos64 virtualEOF, ASFile *newFile);

Parameters

fN
IN The ASFile to base the new file on
virtualEOF
IN The new EOF.
newFile
OUT the new ASFile.

Returns

Error code if the newFile could not be created.

ASFilePushData

Header: ASProcs.h:1207

Description

Sends data from a file system implementation to an ASFile. The data may be for a multi-read request call, or may be unsolicited.

This method can only be called from within a file system implementation. It must not be called by clients of the ASFile, such as a caller that acquired the file with ASFileSysOpenFile().

Related Methods

ASFileRead ASFileWrite

Syntax

void ASFilePushData(ASFile aFile, const char *p, ASTFilePos offset, ASTArraySize length);

Parameters

aFile
IN/OUT The file to which data is sent.
p
IN/OUT The data being pushed.
offset
IN/OUT A byte offset into the file at which the data should be written.
length
IN/OUT The number of bytes held in the buffer.

Exceptions

ASFileRead

Header: ASProcs.h:985

Description

Reads data from a file, beginning at the current seek position.

Related Methods

ASFileSetPos ASFileWrite

Syntax

ASTArraySize ASFileRead(ASFile aFile, char *p, ASTArraySize count);

Parameters

aFile
IN/OUT The file from which data is read.
p
IN/OUT (Filled by the method) A buffer into which data is written. The buffer must be able to hold at least count bytes.
count
IN/OUT The number of bytes to read.

Returns

The number of bytes actually read from the file.

Exceptions

ASFileRegisterFileSys

Header: ASProcs.h:1226

Description

Allows an implementor to provide a file system for use by external clients. An external client can locate the file system using ASFileGetFileSysByName(). fileSys provides its name via the ASFileSysGetFileSysNameProc() callback. This method returns false if a file system with the same name is already registered.

Syntax

ASBool ASFileRegisterFileSys(ASExtension extension, ASFileSys fileSys);

Parameters

extension
IN/OUT The gExtensionID of the plug-in registering the fileSys.
fileSys
IN/OUT The ASFileSys being registered.

Returns

true if fileSys is successfully registered, false otherwise.

ASFileReopen

Header: ASProcs.h:881

Description

Attempts to reopen a file using the specified read/write mode. On some platforms, this may result in the file being closed and then reopened, and some error conditions may render the file invalid.

Note: The file mode and return types changed in 0x00060000.

Syntax

ASErrorCode ASFileReopen(ASFile aFile, ASFileMode mode);

Parameters

aFile
The file to reopen.
mode
An open-mode value as specified for ASFileMode.

Returns

0 if the operation was successful; some file system or platform-dependent error code is returned otherwise.

ASFileSetEOF

Header: ASProcs.h:951

Description

Changes the size of a file. The new size may by larger or smaller than the original size. Since this method does not return any values, the status can be assessed by examining the error code in the HANDLER clause. This method may raise file system or platform-specific exceptions. This call only works when the desired file size is less than 2 GB.

Syntax

void ASFileSetEOF(ASFile aFile, ASTFilePos newFileSize);

Parameters

aFile
The file whose size is changed.
newFileSize
The new size of file.

Exceptions

asGenErrMethodNotImplemented
asFileErrGeneral

ASFileSetEOF64

Header: ASProcs.h:2746

Description

Changes the size of a file. The new size may by larger or smaller than the original size. This method may raise file system or platform-specific exceptions. This call will work with files over 2 GB in length.

Syntax

void ASFileSetEOF64(ASFile aFile, ASFilePos64 newFileSize);

Parameters

aFile
IN/OUT The file whose size is changed.
newFileSize
IN/OUT The new size of the file.

Exceptions

ASFileSetMode

Header: ASProcs.h:1512

Description

Gets or sets the mode flags for a file. Pass 0 for modeValue and modeMask to simply get the current mode flags.

Note: This operation is primarily intended for slow file systems such as the Internet, where there can potentially be an appreciable wait between requesting and retrieving bytes.

Syntax

ASFlagBits ASFileSetMode(ASFile fN, ASFlagBits modeValue, ASFlagBits modeMask);

Parameters

fN
The file for which to get or set the mode.
modeValue
The mode flag values to get or set, which are described in ASFileMode Flags.
modeMask
The mask for the mode flags to get or set.

Returns

The previous value of the mode, or 0 if the file system does not support this operation.

ASFileSetPos

Header: ASProcs.h:915

Description

Seeks to the specified position in a file. This is the position at which the next read or write will begin. This call only works when the desired file position is less than 2 GB.

Syntax

void ASFileSetPos(ASFile aFile, ASTFilePos pos);

Parameters

aFile
IN/OUT The file in which to seek.
pos
IN/OUT The position to seek.

Exceptions

ASFileSetPos64

Header: ASProcs.h:2715

Description

Seeks to the specified position in a file. This is the position at which the next read or write will begin. This call will work with files over 2 GB in length.

Syntax

void ASFileSetPos64(ASFile aFile, ASFilePos64 pos);

Parameters

aFile
IN/OUT The file in which to seek.
pos
IN/OUT The position to seek.

Exceptions

ASFileStmRdOpen

Header: ASProcs.h:1069

Description

Creates a read-only ASStm from a file. The stream supports seek operations.

Syntax

ASStm ASFileStmRdOpen(ASFile afile, ASSmallBufferSize bufSize);

Parameters

afile
The open file to associate with the stream. The file must have been opened previously using ASFileSysOpenFile(). Each open file has a unique ASFile. The ASFile value has meaning only to the common ASFile implementation and bears no relationship to platform-specific file objects.
bufSize
The length in bytes of the data buffer. If bufSize is 0, the default buffer size (currently 4 K) will be used. The default is generally sufficient. A larger buffer size should be used only when data in the file will be accessed in chunks larger than the default buffer. Although bufSize is passed as an ASUns16, it is treated internally as an ASInt16. As a result, buffer sizes above 32 K are not permitted.

Returns

The newly created ASStm.

ASFileStmWrOpen

Header: ASProcs.h:1568

Description

Creates a writable ASStm from a file. The stream supports seek operations.

Syntax

ASStm ASFileStmWrOpen(ASFile afile, ASSmallBufferSize bufSize);

Parameters

afile
The open file to associate with the stream. The file must have been opened previously using ASFileSysOpenFile(). Each open file has a unique ASFile. The ASFile value has meaning only to the common ASFile implementation and bears no relationship to platform-specific file objects.
bufSize
The length in bytes of a data buffer. If bufSize is 0, the default buffer size (currently 4kB) is used. The default is generally sufficient. A larger buffer size should be used only when data in the file will be accessed in chunks larger than the default buffer. Although bufSize is passed as an ASUns16, it is treated internally as an ASInt16. As a result, buffer sizes above 32 K are not permitted.

Returns

The newly created ASStm.

Exceptions

ASFileUnregisterFileSys

Header: ASProcs.h:1185

Description

Allows a fileSys to be unregistered. In general, a fileSys is only unregistered by the extension that registered it.

Related Methods

Syntax

ASBool ASFileUnregisterFileSys(ASExtension extension, ASFileSys fileSys);

Parameters

extension
IN/OUT The gExtensionID of the plug-in un-registering fileSys.
fileSys
IN/OUT The ASFileSys to un-register.

Returns

true if fileSys successfully unregistered, false if there are any open files that were opened through fileSys.

ASFileWrite

Header: ASProcs.h:1002

Description

Writes data to a file, beginning at the current seek position.

Related Methods

ASFileRead ASFileSetPos

Syntax

ASTArraySize ASFileWrite(ASFile aFile, const char *p, ASTArraySize count);

Parameters

aFile
IN/OUT The file to which data is written.
p
IN/OUT A buffer holding the data that is to be written. The buffer must be able to hold at least count bytes.
count
IN/OUT The number of bytes to write.

Returns

The number of bytes actually written to the file.

Exceptions