OpenWrt packages
Sign in or create your account | Project List | Help
OpenWrt packages Git Source Tree
Root/
| 1 | From 925908b925a9008a3da36d222874d2b66c9fe6f7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Joshua Judson Rosen <rozzin@geekspace.com> |
| 3 | Date: Fri, 13 May 2011 21:32:04 -0400 |
| 4 | Subject: [PATCH 15/17] Move file_depth() to util.c and make it public. |
| 5 | It's useful beyond the scope of ui_explore_view.... |
| 6 | |
| 7 | --- |
| 8 | ui_explore_view.c | 17 ++--------------- |
| 9 | util.c | 13 +++++++++++++ |
| 10 | util.h | 2 ++ |
| 11 | 3 files changed, 17 insertions(+), 15 deletions(-) |
| 12 | |
| 13 | diff --git a/ui_explore_view.c b/ui_explore_view.c |
| 14 | index d99eab2..38f6c62 100644 |
| 15 | --- a/ui_explore_view.c |
| 16 | +++ b/ui_explore_view.c |
| 17 | @@ -29,6 +29,7 @@ |
| 18 | #include "gjay.h" |
| 19 | #include "ui.h" |
| 20 | #include "ipc.h" |
| 21 | +#include "util.h" |
| 22 | |
| 23 | |
| 24 | enum |
| 25 | @@ -80,7 +81,7 @@ static int get_iter_path ( GtkTreeModel *tree_model, |
| 26 | char * buffer, |
| 27 | gboolean is_start ); |
| 28 | static int file_iter_depth ( char * file ); |
| 29 | -static int file_depth ( char * file ); |
| 30 | + |
| 31 | static gint explore_animate ( gpointer data ); |
| 32 | static void explore_mark_new_dirs ( char * dir ); |
| 33 | static gint iter_sort_strcmp ( GtkTreeModel *model, |
| 34 | @@ -628,20 +629,6 @@ static int file_iter_depth ( char * file ) { |
| 35 | return depth; |
| 36 | } |
| 37 | |
| 38 | -/* Get the depth by counting the number of non-terminal '/' in the path */ |
| 39 | -static int file_depth ( char * file ) { |
| 40 | - int len, kk, depth; |
| 41 | - |
| 42 | - len = strlen(file); |
| 43 | - if (len) |
| 44 | - len--; // Avoid ending '/' |
| 45 | - for (kk = 0, depth = 0; kk < len; kk++) { |
| 46 | - if (file[kk] == '/') |
| 47 | - depth++; |
| 48 | - } |
| 49 | - return depth; |
| 50 | -} |
| 51 | - |
| 52 | |
| 53 | |
| 54 | /* How many directory steps separate files 1 and 2? */ |
| 55 | diff --git a/util.c b/util.c |
| 56 | index 6b57e5b..00db2d8 100644 |
| 57 | --- a/util.c |
| 58 | +++ b/util.c |
| 59 | @@ -96,3 +96,16 @@ float strtof_gjay ( const char *nptr, char **endptr) { |
| 60 | return result; |
| 61 | } |
| 62 | |
| 63 | +/* Get the depth by counting the number of non-terminal '/' in the path */ |
| 64 | +int file_depth ( char * file ) { |
| 65 | + int len, kk, depth; |
| 66 | + |
| 67 | + len = strlen(file); |
| 68 | + if (len) |
| 69 | + len--; // Avoid ending '/' |
| 70 | + for (kk = 0, depth = 0; kk < len; kk++) { |
| 71 | + if (file[kk] == '/') |
| 72 | + depth++; |
| 73 | + } |
| 74 | + return depth; |
| 75 | +} |
| 76 | diff --git a/util.h b/util.h |
| 77 | index 24c2170..b9fc7fd 100644 |
| 78 | --- a/util.h |
| 79 | +++ b/util.h |
| 80 | @@ -36,4 +36,6 @@ gchar * strdup_convert ( const gchar * str, |
| 81 | float strtof_gjay ( const char * nptr, |
| 82 | char ** endptr); |
| 83 | |
| 84 | +int file_depth ( char * file ); |
| 85 | + |
| 86 | #endif /* UTIL_H */ |
| 87 | -- |
| 88 | 1.7.2.5 |
| 89 | |
| 90 |
