From da020b37254317d6960a563be12c45f5885ffdf2 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sat, 17 Feb 2024 21:13:06 +0100 Subject: [PATCH] Turn `CameraFile` into a struct --- src/gphoto2/camera/capture.cr | 2 +- src/gphoto2/camera_file_path.cr | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/gphoto2/camera/capture.cr b/src/gphoto2/camera/capture.cr index 1323690..cc94dba 100644 --- a/src/gphoto2/camera/capture.cr +++ b/src/gphoto2/camera/capture.cr @@ -60,7 +60,7 @@ module GPhoto2 private def _capture(type) context.check! \ LibGPhoto2.gp_camera_capture(self, type, out path, context) - CameraFilePath.new pointerof(path) + CameraFilePath.new path end private def capture_preview diff --git a/src/gphoto2/camera_file_path.cr b/src/gphoto2/camera_file_path.cr index 6c8e221..e162e8e 100644 --- a/src/gphoto2/camera_file_path.cr +++ b/src/gphoto2/camera_file_path.cr @@ -1,16 +1,15 @@ module GPhoto2 # Represents a path representing a file or folder. - class CameraFilePath - include GPhoto2::Struct(LibGPhoto2::CameraFilePath) - + struct CameraFilePath # Returns the name part of the path. - def name : String - String.new wrapped.name.to_unsafe - end + getter name : String # Returns the folder part of the path. - def folder : String - String.new wrapped.folder.to_unsafe + getter folder : String + + def initialize(path : LibGPhoto2::CameraFilePath) + @name = String.new(path.name.to_unsafe) + @folder = String.new(path.folder.to_unsafe) end def_equals name, folder