1 /*
2 ################################################################################
3 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
4 # Read the zproject/README.md for information about making permanent changes. #
5 ################################################################################
6 */
7
8 #include "QmlZfile.h"
9
10
11 ///
12 // Duplicate a file item, returns a newly constructed item. If the file
13 // is null, or memory was exhausted, returns null.
dup()14 QmlZfile *QmlZfile::dup () {
15 QmlZfile *retQ_ = new QmlZfile ();
16 retQ_->self = zfile_dup (self);
17 return retQ_;
18 };
19
20 ///
21 // Return file name, remove path if provided
filename(const QString & path)22 const QString QmlZfile::filename (const QString &path) {
23 return QString (zfile_filename (self, path.toUtf8().data()));
24 };
25
26 ///
27 // Refresh file properties from disk; this is not done automatically
28 // on access methods, otherwise it is not possible to compare directory
29 // snapshots.
restat()30 void QmlZfile::restat () {
31 zfile_restat (self);
32 };
33
34 ///
35 // Return when the file was last modified. If you want this to reflect the
36 // current situation, call zfile_restat before checking this property.
modified()37 time_t QmlZfile::modified () {
38 return zfile_modified (self);
39 };
40
41 ///
42 // Return the last-known size of the file. If you want this to reflect the
43 // current situation, call zfile_restat before checking this property.
cursize()44 off_t QmlZfile::cursize () {
45 return zfile_cursize (self);
46 };
47
48 ///
49 // Return true if the file is a directory. If you want this to reflect
50 // any external changes, call zfile_restat before checking this property.
isDirectory()51 bool QmlZfile::isDirectory () {
52 return zfile_is_directory (self);
53 };
54
55 ///
56 // Return true if the file is a regular file. If you want this to reflect
57 // any external changes, call zfile_restat before checking this property.
isRegular()58 bool QmlZfile::isRegular () {
59 return zfile_is_regular (self);
60 };
61
62 ///
63 // Return true if the file is readable by this process. If you want this to
64 // reflect any external changes, call zfile_restat before checking this
65 // property.
isReadable()66 bool QmlZfile::isReadable () {
67 return zfile_is_readable (self);
68 };
69
70 ///
71 // Return true if the file is writeable by this process. If you want this
72 // to reflect any external changes, call zfile_restat before checking this
73 // property.
isWriteable()74 bool QmlZfile::isWriteable () {
75 return zfile_is_writeable (self);
76 };
77
78 ///
79 // Check if file has stopped changing and can be safely processed.
80 // Updates the file statistics from disk at every call.
isStable()81 bool QmlZfile::isStable () {
82 return zfile_is_stable (self);
83 };
84
85 ///
86 // Return true if the file was changed on disk since the zfile_t object
87 // was created, or the last zfile_restat() call made on it.
hasChanged()88 bool QmlZfile::hasChanged () {
89 return zfile_has_changed (self);
90 };
91
92 ///
93 // Remove the file from disk
remove()94 void QmlZfile::remove () {
95 zfile_remove (self);
96 };
97
98 ///
99 // Open file for reading
100 // Returns 0 if OK, -1 if not found or not accessible
input()101 int QmlZfile::input () {
102 return zfile_input (self);
103 };
104
105 ///
106 // Open file for writing, creating directory if needed
107 // File is created if necessary; chunks can be written to file at any
108 // location. Returns 0 if OK, -1 if error.
output()109 int QmlZfile::output () {
110 return zfile_output (self);
111 };
112
113 ///
114 // Read chunk from file at specified position. If this was the last chunk,
115 // sets the eof property. Returns a null chunk in case of error.
read(size_t bytes,off_t offset)116 QmlZchunk *QmlZfile::read (size_t bytes, off_t offset) {
117 QmlZchunk *retQ_ = new QmlZchunk ();
118 retQ_->self = zfile_read (self, bytes, offset);
119 return retQ_;
120 };
121
122 ///
123 // Returns true if zfile_read() just read the last chunk in the file.
eof()124 bool QmlZfile::eof () {
125 return zfile_eof (self);
126 };
127
128 ///
129 // Write chunk to file at specified position
130 // Return 0 if OK, else -1
write(QmlZchunk * chunk,off_t offset)131 int QmlZfile::write (QmlZchunk *chunk, off_t offset) {
132 return zfile_write (self, chunk->self, offset);
133 };
134
135 ///
136 // Read next line of text from file. Returns a pointer to the text line,
137 // or NULL if there was nothing more to read from the file.
readln()138 const QString QmlZfile::readln () {
139 return QString (zfile_readln (self));
140 };
141
142 ///
143 // Close file, if open
close()144 void QmlZfile::close () {
145 zfile_close (self);
146 };
147
148 ///
149 // Return file handle, if opened
handle()150 FILE *QmlZfile::handle () {
151 return zfile_handle (self);
152 };
153
154 ///
155 // Calculate SHA1 digest for file, using zdigest class.
digest()156 const QString QmlZfile::digest () {
157 return QString (zfile_digest (self));
158 };
159
160
qmlAttachedProperties(QObject * object)161 QObject* QmlZfile::qmlAttachedProperties(QObject* object) {
162 return new QmlZfileAttached(object);
163 }
164
165
166 ///
167 // Self test of this class.
test(bool verbose)168 void QmlZfileAttached::test (bool verbose) {
169 zfile_test (verbose);
170 };
171
172 ///
173 // If file exists, populates properties. CZMQ supports portable symbolic
174 // links, which are files with the extension ".ln". A symbolic link is a
175 // text file containing one line, the filename of a target file. Reading
176 // data from the symbolic link actually reads from the target file. Path
177 // may be NULL, in which case it is not used.
construct(const QString & path,const QString & name)178 QmlZfile *QmlZfileAttached::construct (const QString &path, const QString &name) {
179 QmlZfile *qmlSelf = new QmlZfile ();
180 qmlSelf->self = zfile_new (path.toUtf8().data(), name.toUtf8().data());
181 return qmlSelf;
182 };
183
184 ///
185 // Create new temporary file for writing via tmpfile. File is automatically
186 // deleted on destroy
tmp()187 QmlZfile *QmlZfileAttached::tmp () {
188 QmlZfile *qmlSelf = new QmlZfile ();
189 qmlSelf->self = zfile_tmp ();
190 return qmlSelf;
191 };
192
193 ///
194 // Destroy a file item
destruct(QmlZfile * qmlSelf)195 void QmlZfileAttached::destruct (QmlZfile *qmlSelf) {
196 zfile_destroy (&qmlSelf->self);
197 };
198
199 /*
200 ################################################################################
201 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
202 # Read the zproject/README.md for information about making permanent changes. #
203 ################################################################################
204 */
205