Skip to content

Commit

Permalink
feat: add comments to get_image_thumb_path() and make_directories()
Browse files Browse the repository at this point in the history
Signed-off-by: Rentib <[email protected]>
  • Loading branch information
Rentib committed Oct 19, 2024
1 parent 86ea61f commit 8f74942
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ void image_rotate(struct image* ctx, size_t angle)
}
}

/* TODO: probably should be moved to config, to make use of expand_path() */
bool image_thumb_path(struct image* image, char* path)
// TODO: probably should be moved to config, to make use of expand_path()
/**
* Get path to cached image thumbnail.
* @param image image
* @param path array in which the path should be stored
* @return true if successful
*/
static bool get_image_thumb_path(struct image* image, char* path)
{
static char* cache_dir = NULL;
int r;
Expand All @@ -76,7 +82,13 @@ bool image_thumb_path(struct image* image, char* path)
return r >= 0 && r < PATH_MAX;
}

bool make_directories(char* path)
// TODO: where should this function be?
/**
* Makes directories like `mkdir -p`.
* @param path absolute path to the directory to be created
* @return true if successful
*/
static bool make_directories(char* path)
{
char* slash;

Expand Down Expand Up @@ -133,7 +145,7 @@ void image_thumbnail(struct image* image, size_t size, bool fill,
}

// get thumbnail from cache
if (image_thumb_path(image, thumb_path) &&
if (get_image_thumb_path(image, thumb_path) &&
pixmap_load(&thumb, thumb_path) &&
(thumb.width == thumb_width && thumb.height == thumb_height)) {
goto thumb_done;
Expand Down

0 comments on commit 8f74942

Please sign in to comment.