Name
hw_FOpen -- open a file (V5.0)
Synopsis
APTR handle = hw_FOpen(STRPTR name, int mode);
Function
This function opens the specified file for reading and/or writing. The second parameter specifies the IO mode to be used on this file. It can be a combination of the following flags:

HWFOPENMODE_READ_LEGACY:
File should be opened for reading. This is mutually exclusive with HWFOPENMODE_WRITE and HWFOPENMODE_READWRITE. Please note that this flag is actually set to 0 for compatibility reasons. This means that hw_FOpen() cannot use the bitwise AND-operator to check if it is set. Instead, it will check if either HWFOPENMODE_WRITE or HWFOPENMODE_READWRITE is set. If both aren't set, then it will assume that HWFOPENMODE_READ_LEGACY is set and will open the file for reading. You should only use this flag if you also need to target Hollywood 5. For Hollywood 6.0 and higher, use HWFOPENMODE_READ_NEW instead (see below).

HWFOPENMODE_WRITE:
File should be opened for writing. If it doesn't exist, hw_FOpen() will create it first. This is mutually exclusive with HWFOPENMODE_READ_NEW and HWFOPENMODE_READWRITE.

HWFOPENMODE_READWRITE:
File should be opened for reading and writing. This is mutually exclusive with HWFOPENMODE_WRITE and HWFOPENMODE_READ_NEW.

HWFOPENMODE_READ_NEW:
File should be opened for reading. This is mutually exclusive with HWFOPENMODE_WRITE and HWFOPENMODE_READWRITE. Please note that this flag requires Hollywood 6.0. If you want to open files for reading with earlier Hollywood versions, use HWFOPENMODE_READ_LEGACY. See above for details. (V6.0)

HWFOPENMODE_NOFILEADAPTER:
If this flag is set, Hollywood will skip all file adapters that are currently active and use its inbuilt file handler to open the file. Use this only if you have a good reason to bypass the file adapters. (V6.0)

HWFOPENMODE_EMULATESEEK:
If this flag is set, Hollywood will emulate seeking for files that have the HWFOPENFLAGS_NOSEEK flag set. Emulation of the seek functionality is done by simply reading bytes from the file until the desired seek position has been reached. This is of course highly inefficient for large seek distances so it should only be used on small files or to bridge small seek distances. (V6.0)

HWFOPENMODE_FORCEUTF8:
If this flag is set, Hollywood will expect the string passed in name to always be in UTF-8 encoding. By default, Hollywood expects the string to be in the encoding of the current script. You can override this behaviour by setting HWFOPENMODE_FORCEUTF8. (V7.0)

HWFOPENMODE_WONTSEEK:
Set this flag to tell Hollywood that you don't need seeking for this file. Hollywood or plugins may then use some optimizations on the file I/O. Note that even if you set HWFOPENMODE_WONTSEEK, it's still allowed to call FSeek() to query the current cursor position, to query the file size by seeking to position 0 with mode set to HWFSEEKMODE_END or to rewind the file back to 0. (V10.0)

This function is thread-safe.

Designer compatibility
Supported since Designer 4.0

Inputs
name
file to open
mode
desired access mode (see above)
Results
handle
handle to refer to this file later or NULL on error

Show TOC