Skip to content


Subversion checkout URL

You can clone with
Download ZIP


A small patch to use the boost regex library to filter filenames #108

wants to merge 1 commit into from

4 participants


I did this as I need to synchronise a filesystem with dotted files in it.
Files to ignore are specified using a perl regular expression in
The regex is compiled a static initialisation time.
My first use of github and a pull request so apologies in advance is this is messed up.
Feel free to suggest a better place to put the expression.


Thanks for the patch!

I am not sure the advantage of using regex to filter out the dot file.

Some users has suggested to add user-defined regex filters (something like .gitignore) to tell Grive to ignore certain files. Are you interested to work on that?


i agree that one file in the root would be simpler. but having the possibilty to define rules per path at some point would make it more flexible and larger rulesets easier to maintain.
though i have to admit it's certainly no top priority issue as it propably would affect only few users.


Regex is overkill; the below patch works just as well (and filters out the exact same set of files). But really, the ignore function should also require the absolute path so that only the exact grive files are filtered out. On the other hand, I'm taking advantage of the .grive* filtering to stick extra non-syncing things (like sync logs) in the same folder...

 libgrive/src/drive/ |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libgrive/src/drive/ b/libgrive/src/drive/
index 43e6367..1dbb822 100644
--- a/libgrive/src/drive/
+++ b/libgrive/src/drive/
@@ -59,7 +59,11 @@ void State::FromLocal( const fs::path& p )

 bool State::IsIgnore( const std::string& filename )
-   return filename[0] == '.' ;
+   if ( filename.length() < 6 )
+       return false ;
+   return filename[0] == '.' && filename[1] == 'g' && filename[2] == 'r' &&
+          filename[3] == 'i' && filename[4] == 'v' && filename[5] == 'e' ;

 void State::FromLocal( const fs::path& p, gr::Resource* folder )
@mianos mianos closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 28, 2012
  1. @mianos
This page is out of date. Refresh to see the latest.
2  libgrive/CMakeLists.txt
@@ -6,7 +6,7 @@ find_package(LibGcrypt REQUIRED)
find_package(JSONC REQUIRED)
find_package(CURL REQUIRED)
find_package(EXPAT REQUIRED)
-find_package(Boost 1.40.0 COMPONENTS filesystem system REQUIRED)
+find_package(Boost 1.40.0 COMPONENTS filesystem system regex REQUIRED)
6 libgrive/src/drive/
@@ -29,9 +29,12 @@
#include "protocol/Json.hh"
#include <fstream>
+#include <boost/regex.hpp>
namespace gr {
+boost::regex State::m_rexp = boost::regex("(\\.|\\.\\.|\\.grive.*)");
State::State( const fs::path& filename, const Json& options ) :
m_cstamp( -1 )
@@ -56,9 +59,10 @@ void State::FromLocal( const fs::path& p )
FromLocal( p, m_res.Root() ) ;
+// changed to only ignore
bool State::IsIgnore( const std::string& filename )
- return filename[0] == '.' ;
+ return boost::regex_match(filename, m_rexp);
void State::FromLocal( const fs::path& p, gr::Resource* folder )
3  libgrive/src/drive/State.hh
@@ -25,6 +25,7 @@
#include "util/FileSystem.hh"
#include <memory>
+#include <boost/regex.hpp>
namespace gr {
@@ -79,6 +80,8 @@ private :
long m_cstamp ;
std::vector<Entry> m_unresolved ;
+ static boost::regex m_rexp ;
} ;
} // end of namespace
Something went wrong with that request. Please try again.