From 578881317d11e97b4a79bc55ba19c5a1b8c33be5 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Wed, 23 Dec 2009 00:58:38 +0200 Subject: [PATCH] XDG functions are added --- glib/cl-gtk2-glib.asd | 3 ++- glib/glib.utils.lisp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 glib/glib.utils.lisp diff --git a/glib/cl-gtk2-glib.asd b/glib/cl-gtk2-glib.asd index cc11c70..908923f 100644 --- a/glib/cl-gtk2-glib.asd +++ b/glib/cl-gtk2-glib.asd @@ -10,6 +10,7 @@ (:file "glib.string") (:file "glib.quark") (:file "glib.gerror") + (:file "glib.utils") (:file "gobject.init") (:file "gobject.ffi.package") @@ -38,4 +39,4 @@ (:file "gobject.boxed") (:file "gobject.object-function")) - :depends-on (:cffi :trivial-garbage :iterate :bordeaux-threads :iterate :closer-mop)) \ No newline at end of file + :depends-on (:cffi :trivial-garbage :iterate :bordeaux-threads :iterate :closer-mop)) diff --git a/glib/glib.utils.lisp b/glib/glib.utils.lisp new file mode 100644 index 0000000..77cf03f --- /dev/null +++ b/glib/glib.utils.lisp @@ -0,0 +1,46 @@ +(in-package :glib) + +(defcfun g-get-user-cache-dir :string) + +(defun get-user-cache-dir () + (g-get-user-cache-dir)) + +(export 'get-user-cache-dir) + +(defcfun g-get-user-data-dir :string) + +(defun get-user-data-dir () + (g-get-user-data-dir)) + +(export 'get-user-data-dir) + +(defcfun g-get-user-config-dir :string) + +(defun get-user-config-dir () + (g-get-user-config-dir)) + +(export 'get-user-config-dir) + +(defcfun g-build-filenamev (:string :free-from-foreign t) + (args :pointer)) + +(defun build-filename (&rest args) + (let* ((n (length args)) + (arr (g-malloc (* (1+ n) (foreign-type-size :pointer))))) + + (iter (for i from 0) + (for arg in args) + (setf (mem-aref arr :pointer i) (g-strdup arg))) + (setf (mem-aref arr :pointer n) (null-pointer)) + + (prog1 + (g-build-filenamev arr) + + (iter (for i from 0) + (for str-ptr = (mem-aref arr :pointer i)) + (until (null-pointer-p str-ptr)) + (g-free str-ptr)) + (g-free arr)))) + +(export 'build-filename) + -- 1.7.10.4