-
首页
-
C4D R23.110 C++ SDK
#include <c4d_file.h>
详细描述
Represents a file for reading and writing.
-
注意
-
Has to be created with
Alloc()
and destroyed with
Free()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
构造函数 & 析构函数文档编制
◆
BaseFile()
◆
~BaseFile()
成员函数文档编制
◆
Alloc()
Allocates a file. Destroy the allocated file with
Free()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
返回
-
The allocated file, or
nullptr
if the allocation failed.
◆
Free()
Destructs files allocated with
Alloc()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
参数
-
[in,out]
|
fl
|
The file to destruct. If the pointer is
nullptr
nothing happens. The pointer is assigned
nullptr
afterwards.
|
◆
Open()
Opens a file.
-
注意
-
If a plugin has to be cross platform from a PC to a Mac (generally advised) then it must correctly fill in the
type
and
creator
parameters which are needed on a Mac.
-
参数
-
[in]
|
name
|
The name of the file to open.
|
[in]
|
mode
|
The file access mode:
FILEOPEN
|
[in]
|
error_dialog
|
Set the type of error reporting that should happen while opening the file:
FILEDIALOG
|
[in]
|
order
|
The type of byte order in the file:
BYTEORDER
|
[in]
|
type
|
The type of file, only applies to Mac:
MACTYPE_CINEMA
.
|
[in]
|
creator
|
The application that wrote the file, for example 'ttxt' (SimpleText) or 'C4D1' for
Cinema 4D
, Only relevant to Mac:
MACCREATOR_CINEMA
.
|
-
返回
-
true
if the file was opened without any problem, otherwise
false
.
◆
Close()
Closes the file.
Automatically called when a
BaseFile
object is destroyed.
-
返回
-
true
if the file was successfully closed, otherwise
false
.
◆
ReadBytes()
Int
ReadBytes
|
(
|
void *
|
data
,
|
|
|
Int
|
len
,
|
|
|
Bool
|
just_try_it
=
false
|
|
)
|
|
|
Reads a block of bytes from the file.
-
警告
-
Only use this when really needed. Be aware that the byte sequences will not be platform independent.
-
参数
-
[in]
|
data
|
The memory buffer to fill with the bytes from the file. The caller owns the pointed buffer.
|
[in]
|
len
|
The number of bytes to read from the file.
|
[in]
|
just_try_it
|
若
true
and the data retrieved from the file is less than requested, no error will be generated.
|
-
返回
-
The number of bytes read.
◆
TryReadBytes()
Int
TryReadBytes
|
(
|
void *
|
data
,
|
|
|
Int
|
len
|
|
)
|
|
|
Reads a block of bytes from the file.
If the end of the file is reached then only the remaining bytes will be read.
-
注意
-
Same as calling ReadBytes(data, len, true)
-
参数
-
[out]
|
data
|
The memory buffer to fill with the bytes from the file. The caller owns the pointed buffer.
|
[in]
|
len
|
The number of bytes to try and read from the file.
|
-
返回
-
The number of bytes read.
◆
WriteBytes()
Bool
WriteBytes
|
(
|
const void *
|
data
,
|
|
|
Int
|
len
|
|
)
|
|
|
Writes a block of bytes to the file.
-
警告
-
Only use this when really needed. Be aware that the byte sequences will not be platform independent.
-
参数
-
[in]
|
data
|
The memory buffer with the data to write to the file. The caller owns the pointed buffer.
|
[in]
|
len
|
The number of bytes to write to the file.
|
-
返回
-
true
if the bytes were successfully written to the file, otherwise
false
.
◆
Seek()
Sets the file pointer within the file.
-
参数
-
[in]
|
pos
|
The position within the file to place the file pointer.
|
[in]
|
mode
|
Sets how the position relates to the file.
|
-
返回
-
true
if the file pointer position was successfully changed, otherwise
false
.
◆
GetPosition()
Gets the file pointer.
-
返回
-
The position of the file pointer.
◆
GetLength()
Gets the length of the file in bytes.
-
返回
-
The byte length of the file.
◆
GetLocation()
Gets the file location.
-
返回
-
The file location:
LOCATION
◆
GetError()
Gets the last error during read or write.
-
返回
-
The last error:
FILEERROR
◆
SetError()
Sets the error manually.
-
参数
-
◆
SetOrder()
Sets the byte order of the data in the file.
-
参数
-
◆
ReadChar()
Reads a
Char
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
Char
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadUChar()
Reads a
UChar
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
UChar
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadInt16()
Reads a
Int16
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
Int16
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadUInt16()
Reads a
UInt16
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
UInt16
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadInt32()
Reads a
Int32
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
Int32
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadUInt32()
Reads a
UInt32
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
UInt32
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadFloat32()
Reads a
Float32
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
Float32
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadFloat64()
Reads a
Float64
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
Float64
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadInt64()
Reads a
Int64
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
Int64
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadUInt64()
Reads a
UInt64
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
UInt64
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadFilename()
Reads a
Filename
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
Filename
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadBool()
Reads a
Bool
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
Bool
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadString()
Reads a
String
from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed
String
.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadVector32()
Reads a Vector32 from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed Vector32.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadVector64()
Reads a Vector64 from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed Vector64.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadMatrix32()
Reads a Matrix32 from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed Matrix32.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
ReadMatrix64()
Reads a Matrix64 from the file.
-
参数
-
[out]
|
v
|
Assigned the read value. The caller owns the pointed Matrix64.
|
-
返回
-
true
if the value was read successfully, otherwise
false
.
◆
WriteChar()
Writes a
Char
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteUChar()
Writes a
UChar
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteInt16()
Writes a
Int16
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteUInt16()
Writes a
UInt16
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteInt32()
Writes a
Int32
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteUInt32()
Writes a
UInt32
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteFloat32()
Writes a
Float32
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteFloat64()
Writes a
Float64
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteInt64()
Writes a
Int64
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteUInt64()
Writes a
UInt64
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteFilename()
Writes a
Filename
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteBool()
Writes a
Bool
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteString()
Writes a
String
to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteVector32()
Writes a Vector32 to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteVector64()
Writes a Vector64 to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteMatrix32()
Writes a Matrix32 to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.
◆
WriteMatrix64()
Writes a Matrix64 to the file.
-
参数
-
[in]
|
v
|
The value to write to the file.
|
-
返回
-
true
if the value was written successfully, otherwise
false
.