diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-05-06 16:39:57 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2024-05-06 17:27:25 -0400 |
commit | ee840709d3d93376f9b5da6c34572424079304b8 (patch) | |
tree | 2357bb53651524d1cc5dd386fb32ddba15e7be0d /apps/plugins/open_plugins.c | |
parent | 30482bd9087444c434ee4c4cc1756ca9a402f5ad (diff) | |
download | rockbox-ee840709d3d93376f9b5da6c34572424079304b8.tar.gz rockbox-ee840709d3d93376f9b5da6c34572424079304b8.zip |
[Feature] Open plugins now recognizes known filetypes and can run them
now you can run your lua files without having to add the viewer to
the shortcut or if you want a bmp file to be displayed when you start
the device that can be done as well
Change-Id: Ia56b566789623a2ca78d9e4583086db6e2cd689b
Diffstat (limited to 'apps/plugins/open_plugins.c')
-rw-r--r-- | apps/plugins/open_plugins.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/apps/plugins/open_plugins.c b/apps/plugins/open_plugins.c index b608aff789..9d58433fdf 100644 --- a/apps/plugins/open_plugins.c +++ b/apps/plugins/open_plugins.c | |||
@@ -118,8 +118,7 @@ static int op_entry_read_opx(const char *path) | |||
118 | int fd_opx; | 118 | int fd_opx; |
119 | int len; | 119 | int len; |
120 | 120 | ||
121 | len = rb->strlen(path); | 121 | if(rb->filetype_get_attr(path) == FILE_ATTR_OPX) |
122 | if(len > OP_LEN && rb->strcasecmp(&((path)[len-OP_LEN]), "." OP_EXT) == 0) | ||
123 | { | 122 | { |
124 | fd_opx = rb->open(path, O_RDONLY); | 123 | fd_opx = rb->open(path, O_RDONLY); |
125 | if (fd_opx >= 0) | 124 | if (fd_opx >= 0) |
@@ -317,6 +316,7 @@ static int op_entry_transfer(int fd, int fd_tmp, | |||
317 | 316 | ||
318 | static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key) | 317 | static uint32_t op_entry_add_path(const char *key, const char *plugin, const char *parameter, bool use_key) |
319 | { | 318 | { |
319 | char buf[MAX_PATH]; | ||
320 | int len; | 320 | int len; |
321 | uint32_t hash; | 321 | uint32_t hash; |
322 | uint32_t newhash; | 322 | uint32_t newhash; |
@@ -339,8 +339,11 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha | |||
339 | else | 339 | else |
340 | hash = op_entry.hash; | 340 | hash = op_entry.hash; |
341 | 341 | ||
342 | |||
343 | |||
342 | if (plugin) | 344 | if (plugin) |
343 | { | 345 | { |
346 | int fattr = rb->filetype_get_attr(plugin); | ||
344 | /* name */ | 347 | /* name */ |
345 | if (use_key) | 348 | if (use_key) |
346 | { | 349 | { |
@@ -353,8 +356,21 @@ static uint32_t op_entry_add_path(const char *key, const char *plugin, const cha | |||
353 | if (op_entry.name[0] == '\0' || op_entry.lang_id >= 0) | 356 | if (op_entry.name[0] == '\0' || op_entry.lang_id >= 0) |
354 | rb->strlcpy(op_entry.name, pos, OPEN_PLUGIN_NAMESZ); | 357 | rb->strlcpy(op_entry.name, pos, OPEN_PLUGIN_NAMESZ); |
355 | 358 | ||
356 | len = rb->strlen(pos); | 359 | |
357 | if(len > ROCK_LEN && rb->strcasecmp(&(pos[len-ROCK_LEN]), "." ROCK_EXT) == 0) | 360 | |
361 | if ((!parameter || parameter[0] == '\0') && fattr != FILE_ATTR_ROCK && fattr != FILE_ATTR_OPX) | ||
362 | { | ||
363 | rb->strlcpy(op_entry.param, plugin, OPEN_PLUGIN_BUFSZ); | ||
364 | parameter = op_entry.param; | ||
365 | plugin = rb->filetype_get_plugin(fattr, buf, sizeof(buf)); | ||
366 | if (!plugin) | ||
367 | { | ||
368 | rb->splashf(HZ * 2, rb->str(LANG_OPEN_PLUGIN_NOT_A_PLUGIN), pos); | ||
369 | return 0; | ||
370 | } | ||
371 | } | ||
372 | |||
373 | if(fattr == FILE_ATTR_ROCK) | ||
358 | { | 374 | { |
359 | fd_tmp = rb->open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); | 375 | fd_tmp = rb->open(OPEN_PLUGIN_DAT ".tmp", O_WRONLY | O_CREAT | O_TRUNC, 0666); |
360 | if (fd_tmp < 0) | 376 | if (fd_tmp < 0) |