int ok = hw_TranslateFileNameExt(STRPTR name, struct hwTranslateFileInfo *tf, struct hwTagList *tags);
fopen()
instead, it will fail to open the file. That's why you should always use
the functions from DOSBase
when dealing with files. See File IO information for details.
If you cannot use the functions from DOSBase
to do your file IO for some particular
reason, you can use hw_TranslateFileNameExt()
to break down a virtual file specification
into a physical one. You'll have to pass a pointer to a struct hwTranslateFileInfo
structure to this function. struct hwTranslateFileInfo
looks like this:
struct hwTranslateFileInfo { STRPTR File; // [in/out] int FileLen; // [in] STRPTR FileExt; // [in/out] int FileExtLen; // [in] STRPTR RealFile; // [in/out] int RealFileLen; // [in] APTR MemoryBlock; // [out] DOSINT64 Offset; // [out] DOSINT64 Length; // [out] }; |
Here's a description of the individual structure members:
File:
NULL
, Hollywood will copy the name of the virtual file to this string
buffer. You will also have to provide the size of this buffer in the FileLen
argument.
FileLen:
File
is non-NULL
, you'll have to set this member to the size of the buffer passed
in File
.
FileExt:
NULL
, Hollywood will copy the extension of the virtual file to this string
buffer. You will also have to provide the size of this buffer in the FileExtLen
argument.
FileExtLen:
FileExt
is non-NULL
, you'll have to set this member to the size of the buffer passed
in FileExt
.
RealFile:
NULL
, Hollywood will copy the name of the file that contains the virtual
file to this string buffer. For example, there might be a virtual file named intro.png
inside the physical file gamedata.bin
at offset 1048576 from the start of the file
taking up 65536 bytes inside gamedata.bin
. In case the virtual file doesn't have a
container file but is stored within a memory block, Hollywood will set this member to an
empty string and will store a pointer to the memory block that contains the virtual file in
MemoryBlock
. Note that if you set RealFile
, you will also have to provide the size of the
buffer in the RealFileLen
argument.
RealFileLen:
RealFile
is non-NULL
, you'll have to set this member to the size of the buffer passed
in RealFile
.
MemoryBlock:
Offset:
Length:
You can use hw_ChunkToFile() to easily save a virtual file to a physical file. See hw_ChunkToFile for details.
This function is thread-safe.
struct hwTranslateFileInfo
initialized as described aboveNULL
for nowTrue
on success, False
otherwise