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 #ifndef QML_ZDIR_H 9 #define QML_ZDIR_H 10 11 #include <QtQml> 12 13 #include <czmq.h> 14 #include "qml_czmq_plugin.h" 15 16 17 class QmlZdir : public QObject 18 { 19 Q_OBJECT 20 Q_PROPERTY(bool isNULL READ isNULL) 21 22 public: 23 zdir_t *self; 24 QmlZdir()25 QmlZdir() { self = NULL; } isNULL()26 bool isNULL() { return self == NULL; } 27 28 static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZdir.cpp 29 30 public slots: 31 // Return directory path 32 const QString path (); 33 34 // Return last modification time for directory. 35 time_t modified (); 36 37 // Return total hierarchy size, in bytes of data contained in all files 38 // in the directory tree. 39 off_t cursize (); 40 41 // Return directory count 42 size_t count (); 43 44 // Returns a sorted list of zfile objects; Each entry in the list is a pointer 45 // to a zfile_t item already allocated in the zdir tree. Do not destroy the 46 // original zdir tree until you are done with this list. 47 QmlZlist *list (); 48 49 // Remove directory, optionally including all files that it contains, at 50 // all levels. If force is false, will only remove the directory if empty. 51 // If force is true, will remove all files and all subdirectories. 52 void remove (bool force); 53 54 // Return full contents of directory as a zdir_patch list. 55 QmlZlist *resync (const QString &alias); 56 57 // Load directory cache; returns a hash table containing the SHA-1 digests 58 // of every file in the tree. The cache is saved between runs in .cache. 59 QmlZhash *cache (); 60 61 // Print contents of directory to open stream 62 void fprint (FILE *file, int indent); 63 64 // Print contents of directory to stdout 65 void print (int indent); 66 }; 67 68 class QmlZdirAttached : public QObject 69 { 70 Q_OBJECT 71 QObject* m_attached; 72 73 public: QmlZdirAttached(QObject * attached)74 QmlZdirAttached (QObject* attached) { 75 Q_UNUSED (attached); 76 }; 77 78 public slots: 79 // Calculate differences between two versions of a directory tree. 80 // Returns a list of zdir_patch_t patches. Either older or newer may 81 // be null, indicating the directory is empty/absent. If alias is set, 82 // generates virtual filename (minus path, plus alias). 83 QmlZlist *diff (QmlZdir *older, QmlZdir *newer, const QString &alias); 84 85 // Create a new zdir_watch actor instance: 86 // 87 // zactor_t *watch = zactor_new (zdir_watch, NULL); 88 // 89 // Destroy zdir_watch instance: 90 // 91 // zactor_destroy (&watch); 92 // 93 // Enable verbose logging of commands and activity: 94 // 95 // zstr_send (watch, "VERBOSE"); 96 // 97 // Subscribe to changes to a directory path: 98 // 99 // zsock_send (watch, "ss", "SUBSCRIBE", "directory_path"); 100 // 101 // Unsubscribe from changes to a directory path: 102 // 103 // zsock_send (watch, "ss", "UNSUBSCRIBE", "directory_path"); 104 // 105 // Receive directory changes: 106 // zsock_recv (watch, "sp", &path, &patches); 107 // 108 // // Delete the received data. 109 // free (path); 110 // zlist_destroy (&patches); 111 void watch (QmlZsock *pipe, void *unused); 112 113 // Self test of this class. 114 void test (bool verbose); 115 116 // Create a new directory item that loads in the full tree of the specified 117 // path, optionally located under some parent path. If parent is "-", then 118 // loads only the top-level directory, and does not use parent as a path. 119 QmlZdir *construct (const QString &path, const QString &parent); 120 121 // Destroy a directory tree and all children it contains. 122 void destruct (QmlZdir *qmlSelf); 123 }; 124 125 126 QML_DECLARE_TYPEINFO(QmlZdir, QML_HAS_ATTACHED_PROPERTIES) 127 128 #endif 129 /* 130 ################################################################################ 131 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # 132 # Read the zproject/README.md for information about making permanent changes. # 133 ################################################################################ 134 */ 135