summaryrefslogtreecommitdiff
path: root/src/c_fl_filename.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2024-12-10 20:47:53 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2024-12-10 22:31:22 +1300
commit24781de8bedb3bf4d12d7ec1d0307842e59a3f94 (patch)
tree26e4ab0fad00728adead6cb6626fe40fa7a31704 /src/c_fl_filename.cpp
parent70d75e1f45bcee89b363677a161f022ecbffd1db (diff)
Binding for filename.H added
Diffstat (limited to 'src/c_fl_filename.cpp')
-rw-r--r--src/c_fl_filename.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/src/c_fl_filename.cpp b/src/c_fl_filename.cpp
new file mode 100644
index 0000000..39af3d1
--- /dev/null
+++ b/src/c_fl_filename.cpp
@@ -0,0 +1,127 @@
+
+
+// Programmed by Jedidiah Barber
+// Released into the public domain
+
+
+#include <FL/filename.H>
+#include <string.h>
+#include "c_fl_filename.h"
+
+
+
+
+const int fl_path_max = FL_PATH_MAX;
+
+
+
+
+void free_filename_file_list(void * l, int n) {
+ struct dirent ** p = reinterpret_cast<struct dirent **>(l);
+ fl_filename_free_list(&p, n);
+}
+
+const char * filename_dname(void * l, int n) {
+ return (reinterpret_cast<struct dirent **>(l)[n])->d_name;
+}
+
+
+
+
+void filename_decode_uri(char *uri) {
+ fl_decode_uri(uri);
+}
+
+int filename_absolute(char * to, int tolen, const char * from) {
+ return fl_filename_absolute(to, tolen, from);
+}
+
+int filename_expand(char * to, int tolen, const char * from) {
+ return fl_filename_expand(to, tolen, from);
+}
+
+const char * filename_ext(const char * buf) {
+ return fl_filename_ext(buf);
+}
+
+int filename_isdir(const char * name) {
+ return fl_filename_isdir(name);
+}
+
+int filename_list(const char * d, void * l, void * f) {
+ return fl_filename_list(d, reinterpret_cast<struct dirent ***>(l),
+ reinterpret_cast<Fl_File_Sort_F*>(f));
+}
+
+int filename_match(const char * name, const char * pattern) {
+ return fl_filename_match(name, pattern);
+}
+
+const char * filename_name(const char * name) {
+ return fl_filename_name(name);
+}
+
+int filename_relative(char * to, int tolen, const char * from) {
+ return fl_filename_relative(to, tolen, from);
+}
+
+char * filename_setext(char * to, int tolen, const char * ext) {
+ return fl_filename_setext(to, tolen, ext);
+}
+
+int filename_open_uri(const char * uri, char * msg, int msglen) {
+ return fl_open_uri(uri, msg, msglen);
+}
+
+
+
+
+int filename_alphasort(char * a, char * b) {
+ struct dirent d_aye, d_bee;
+ d_aye.d_name[0] = '\0';
+ strncat (d_aye.d_name, a, 255);
+ d_bee.d_name[0] = '\0';
+ strncat (d_bee.d_name, b, 255);
+ struct dirent * dp_aye = &d_aye;
+ struct dirent * dp_bee = &d_bee;
+ int result = fl_alphasort(&dp_aye, &dp_bee);
+ return result < 0 ? 0 : result == 0 ? 1 : 2;
+}
+
+int filename_casealphasort(char * a, char * b) {
+ struct dirent d_aye, d_bee;
+ d_aye.d_name[0] = '\0';
+ strncat (d_aye.d_name, a, 255);
+ d_bee.d_name[0] = '\0';
+ strncat (d_bee.d_name, b, 255);
+ struct dirent * dp_aye = &d_aye;
+ struct dirent * dp_bee = &d_bee;
+ int result = fl_casealphasort(&dp_aye, &dp_bee);
+ return result < 0 ? 0 : result == 0 ? 1 : 2;
+}
+
+int filename_numericsort(char * a, char * b) {
+ struct dirent d_aye, d_bee;
+ d_aye.d_name[0] = '\0';
+ strncat (d_aye.d_name, a, 255);
+ d_bee.d_name[0] = '\0';
+ strncat (d_bee.d_name, b, 255);
+ struct dirent * dp_aye = &d_aye;
+ struct dirent * dp_bee = &d_bee;
+ int result = fl_numericsort(&dp_aye, &dp_bee);
+ return result < 0 ? 0 : result == 0 ? 1 : 2;
+}
+
+int filename_casenumericsort(char * a, char * b) {
+ struct dirent d_aye, d_bee;
+ d_aye.d_name[0] = '\0';
+ strncat (d_aye.d_name, a, 255);
+ d_bee.d_name[0] = '\0';
+ strncat (d_bee.d_name, b, 255);
+ struct dirent * dp_aye = &d_aye;
+ struct dirent * dp_bee = &d_bee;
+ int result = fl_casenumericsort(&dp_aye, &dp_bee);
+ return result < 0 ? 0 : result == 0 ? 1 : 2;
+}
+
+