Skip to content

Commit

Permalink
Turn CameraFile into a struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Feb 17, 2024
1 parent d09f763 commit da020b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/gphoto2/camera/capture.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions src/gphoto2/camera_file_path.cr
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit da020b3

Please sign in to comment.