aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/glob.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-03-10 01:46:19 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-03-10 01:46:19 +0100
commit5837cc436b4cee01e5cc48d32e75835a14121013 (patch)
tree287e5c74acbafbe5146bb499ea113d4f6ba73038 /src/glob.cpp
parent3db42f84371cf7ae9c1ec6cbf3668424645c7479 (diff)
downloadsciteco-5837cc436b4cee01e5cc48d32e75835a14121013.tar.gz
dirname length calculation moved from glob.cpp to file_get_dirname_len() in ioview.h
this function is very useful in other places as well (e.g. command line tab completion)
Diffstat (limited to 'src/glob.cpp')
-rw-r--r--src/glob.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/glob.cpp b/src/glob.cpp
index af8fbe9..9ef3f89 100644
--- a/src/glob.cpp
+++ b/src/glob.cpp
@@ -28,6 +28,7 @@
#include "interface.h"
#include "parser.h"
#include "ring.h"
+#include "ioview.h"
#include "glob.h"
namespace SciTECO {
@@ -38,7 +39,7 @@ namespace States {
Globber::Globber(const gchar *pattern)
{
- gsize dirname_len = 0;
+ gsize dirname_len;
/*
* This finds the directory component including
@@ -49,11 +50,9 @@ Globber::Globber(const gchar *pattern)
* file names with the exact same directory
* prefix as the input pattern.
*/
- for (const gchar *p = pattern; *p; p++)
- if (G_IS_DIR_SEPARATOR(*p))
- dirname_len = p - pattern + 1;
-
+ dirname_len = file_get_dirname_len(pattern);
dirname = g_strndup(pattern, dirname_len);
+
dir = g_dir_open(*dirname ? dirname : ".", 0, NULL);
/* if dirname does not exist, dir may be NULL */