<commit_before>(in-package #:glaw)

#+clisp ;; why ansi isn"t default behavior?
(setf custom:*merge-pathnames-ansi* t)

;; Game asset are loaded from files
(defvar *content-manager* nil)
(defvar *content-directory* nil)

(defun init-content-manager (&optional (content-dir ""))
  (format t "Initializing content manager with ~S~%" content-dir)
  (setf *content-manager* (create-resource-manager))
  (setf *content-directory* content-dir))

(defun shutdown-content-manager ()
  (destroy-resource-manager *content-manager*)
  (setf *content-directory* nil))

(defvar *asset-loaders* (make-hash-table))

(defun load-asset (filename type &optional (identifier filename))
  (format t "Loading asset of type ~S from ~S~%" type filename)
  (with-resource-manager *content-manager*
    (let ((loader (gethash type *asset-loaders* nil))
          (pathname (merge-pathnames filename *content-directory*)))
      (if loader
          (use-resource identifier (funcall (first loader) pathname) (second loader))
          (error "No asset loader defined for ~S~%" type)))))

(defun dispose-asset (identifier)
  "Dispose designated asset regardless of its current users."
  (format t "Disposing of asset: ~S~%" identifier)
  (remove-resource *content-manager* identifier))
<commit_msg>Added helper func to dispose of multiple assets at a time.<commit_after>(in-package #:glaw)

#+clisp ;; why ansi isn"t default behavior?
(setf custom:*merge-pathnames-ansi* t)

;; Game asset are loaded from files
(defvar *content-manager* nil)
(defvar *content-directory* nil)

(defun init-content-manager (&optional (content-dir ""))
  (format t "Initializing content manager with ~S~%" content-dir)
  (setf *content-manager* (create-resource-manager))
  (setf *content-directory* content-dir))

(defun shutdown-content-manager ()
  (destroy-resource-manager *content-manager*)
  (setf *content-directory* nil))

(defvar *asset-loaders* (make-hash-table))

(defun load-asset (filename type &optional (identifier filename))
  (format t "Loading asset of type ~S from ~S~%" type filename)
  (with-resource-manager *content-manager*
    (let ((loader (gethash type *asset-loaders* nil))
          (pathname (merge-pathnames filename *content-directory*)))
      (if loader
          (use-resource identifier (funcall (first loader) pathname) (second loader))
          (error "No asset loader defined for ~S~%" type)))))

(defun dispose-asset (identifier)
  "Dispose designated asset regardless of its current users."
  (format t "Disposing of asset: ~S~%" identifier)
  (remove-resource *content-manager* identifier))

(defun dispose-assets (&rest ids)
  (dolist (it ids)
    (dispose-asset it)))
{'fraction_non_alphanumeric': 0.1379827521559805, 'fraction_numerical': 0.0, 'mean_word_length': 4.546777546777546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3659142', 'n_tokens_mistral': 825, 'n_tokens_neox': 810, 'n_words': 259}