aboutsummaryrefslogtreecommitdiff
path: root/fiv-io-model.h
diff options
context:
space:
mode:
Diffstat (limited to 'fiv-io-model.h')
-rw-r--r--fiv-io-model.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/fiv-io-model.h b/fiv-io-model.h
new file mode 100644
index 0000000..2fb9ad7
--- /dev/null
+++ b/fiv-io-model.h
@@ -0,0 +1,61 @@
+//
+// fiv-io-model.h: filesystem
+//
+// Copyright (c) 2021 - 2023, Přemysl Eric Janouch <p@janouch.name>
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+//
+
+#pragma once
+
+#include <gio/gio.h>
+#include <glib.h>
+
+typedef enum _FivIoModelSort {
+ FIV_IO_MODEL_SORT_NAME,
+ FIV_IO_MODEL_SORT_MTIME,
+ FIV_IO_MODEL_SORT_COUNT,
+
+ FIV_IO_MODEL_SORT_MIN = 0,
+ FIV_IO_MODEL_SORT_MAX = FIV_IO_MODEL_SORT_COUNT - 1
+} FivIoModelSort;
+
+#define FIV_TYPE_IO_MODEL (fiv_io_model_get_type())
+G_DECLARE_FINAL_TYPE(FivIoModel, fiv_io_model, FIV, IO_MODEL, GObject)
+
+/// Loads a directory. Clears itself even on failure.
+gboolean fiv_io_model_open(FivIoModel *self, GFile *directory, GError **error);
+
+/// Returns the current location as a GFile.
+/// There is no ownership transfer, and the object may be NULL.
+GFile *fiv_io_model_get_location(FivIoModel *self);
+
+/// Returns the previous VFS directory in order, or NULL.
+GFile *fiv_io_model_get_previous_directory(FivIoModel *self);
+/// Returns the next VFS directory in order, or NULL.
+GFile *fiv_io_model_get_next_directory(FivIoModel *self);
+
+// These objects are reference-counted using GRcBox.
+typedef struct {
+ const char *uri; ///< GIO URI
+ const char *target_uri; ///< GIO URI for any target
+ const char *display_name; ///< Label for the file
+ const char *collate_key; ///< Collate key for the filename
+ guint64 filesize; ///< Filesize in bytes
+ gint64 mtime_msec; ///< Modification time in milliseconds
+} FivIoModelEntry;
+
+#define fiv_io_model_entry_ref(e) g_rc_box_acquire(e)
+#define fiv_io_model_entry_unref(e) g_rc_box_release(e)
+
+FivIoModelEntry *const *fiv_io_model_get_files(FivIoModel *self, gsize *len);
+FivIoModelEntry *const *fiv_io_model_get_subdirs(FivIoModel *self, gsize *len);