aboutsummaryrefslogtreecommitdiffstats
path: root/doc/reference/jsextensions/jsextension-binaryfile.qdoc
blob: 59def1af4f10a7756be6242e86d46685717f2260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/****************************************************************************
**
** Copyright (C) 2017 Sergey Belyashov <sergey.belyashov@gmail.com>
** Copyright (C) 2017 Denis Shienkov <denis.shienkov@gmail.com>
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \contentspage index.html
    \page jsextension-binaryfile.html
    \ingroup list-of-builtin-services

    \title BinaryFile Service
    \brief Provides read and write operations on binary files.

    The \c BinaryFile service allows you to read from and write into binary files.

    \section1 Related Declarations

    \section2 BinaryFile.OpenMode
    \code
    enum BinaryFile.OpenMode { ReadOnly, WriteOnly, ReadWrite }
    \endcode
    List of modes that a file may be opened in.

    The OpenMode values can be combined with the bitwise or operator.

    \section1 Available operations

    \section2 Constructor
    \code
    BinaryFile(filePath: string, openMode: OpenMode = BinaryFile.ReadOnly)
    \endcode
    Opens the file at \c filePath in the given mode and returns the object representing the file.
    \note The mode influences which of the operations listed below can actually be used on the file.

    \section2 atEof
    \code
    atEof(): boolean
    \endcode
    Returns \c{true} if no more data can be read from the file, \c{false} otherwise.

    \section2 close
    \code
    close(): void
    \endcode
    Closes the file. It is recommended to always call this function as soon as you are finished
    with the file, in order to keep the number of in-flight file descriptors as low as possible.

    \section2 filePath
    \code
    filePath(): string
    \endcode
    The absolute path of the file represented by this object.

    \section2 size
    \code
    size(): number
    \endcode
    Returns the size of the file (in bytes).

    \section2 resize
    \code
    resize(size: number): void
    \endcode
    Sets the file \c size (in bytes). If \c size is larger than the file currently is, the new
    bytes will be set to 0; if \c size is smaller, the file is truncated.

    \section2 pos
    \code
    pos(): number
    \endcode
    Returns the position that data is written to or read from.

    \section2 seek
    \code
    seek(pos: number): void
    \endcode
    Sets the current position to \c pos.

    \section2 read
    \code
    read(size: number): number[]
    \endcode
    Reads at most \c size bytes of data from the file and returns it as an array.

    \section2 write
    \code
    write(data: number[]): void
    \endcode
    Writes \c data into the file at the current position.
*/