static int is_replay(struct dir_item *item)
{
- return strcmp(item->path + strlen(item->path) - 4, ".nbr") == 0;
+ return str_ends_with(item->path, ".nbr");
}
static int is_score(struct dir_item *item)
{
- return strncmp(item->path, "neverballhs-", sizeof ("neverballhs-") - 1) == 0;
+ return str_starts_with(item->path, "neverballhs-");
}
static void make_dirs_and_migrate(void)
fs_mkdir("Screenshots");
}
+/*---------------------------------------------------------------------------*/
+
int main(int argc, char *argv[])
{
SDL_Joystick *joy = NULL;
static int is_unseen_set(struct dir_item *item)
{
- return (strncmp(base_name(item->path, NULL), "set-", 4) == 0 &&
- strcmp(item->path + strlen(item->path) - 4, ".txt") == 0 &&
+ return (str_starts_with(base_name(item->path, NULL), "set-") &&
+ str_ends_with(item->path, ".txt") &&
!set_is_loaded(item->path));
}
static int is_unseen_course(struct dir_item *item)
{
- return (strncmp(base_name(item->path, NULL), "holes-", 6) == 0 &&
- strcmp(item->path + strlen(item->path) - 4, ".txt") == 0 &&
+ return (str_starts_with(base_name(item->path, NULL), "holes-") &&
+ str_ends_with(item->path, ".txt") &&
!course_is_loaded(item->path));
}
#endif
#define strdup dupe_string
+#define str_starts_with(s, h) (strncmp((s), (h), strlen(h)) == 0)
+#define str_ends_with(s, t) (strcmp((s) + strlen(s) - strlen(t), (t)) == 0)
+
time_t make_time_from_utc(struct tm *);
const char *date_to_str(time_t);