From 5a2e118c38fad41a2b23a33e9a64e543ccc61e72 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 3 May 2011 23:28:03 +0200 Subject: [PATCH] In Windows convert backslash to forward slash. --- HISTORY | 2 ++ elem.c | 2 +- murmurhash3.c | 2 +- scan.c | 2 +- snapraid.1 | 6 ++++-- snapraid.conf.example.windows | 11 ++++++----- snapraid.d | 6 ++++-- util.c | 13 +++++-------- util.h | 2 +- 9 files changed, 25 insertions(+), 21 deletions(-) diff --git a/HISTORY b/HISTORY index ae093447..b15ef041 100644 --- a/HISTORY +++ b/HISTORY @@ -26,6 +26,8 @@ SnapRAID HISTORY present. * Opening the files in sequential mode in Windows. This should give a speedup in Windows. +* In Windows you can use the backslash \ in the filter definitions instead + of the forward slash /. 1.0 2011/4 ========== diff --git a/elem.c b/elem.c index 30f90538..acaba55c 100644 --- a/elem.c +++ b/elem.c @@ -46,7 +46,7 @@ struct snapraid_filter* filter_alloc(int direction, const char* pattern) char* last; filter = malloc_nofail(sizeof(struct snapraid_filter)); - pathcpy(filter->pattern, sizeof(filter->pattern), pattern); + pathimport(filter->pattern, sizeof(filter->pattern), pattern); filter->direction = direction; /* find first and last slash */ diff --git a/murmurhash3.c b/murmurhash3.c index 52302d7f..105f661d 100644 --- a/murmurhash3.c +++ b/murmurhash3.c @@ -26,7 +26,7 @@ // non-native version will be less than optimal. /* Rotate left */ -inline uint32_t rotl32 ( uint32_t x, int8_t r ) +inline uint32_t rotl32(uint32_t x, int8_t r) { return (x << r) | (x >> (32 - r)); } diff --git a/scan.c b/scan.c index 047fcfa5..620a8b14 100644 --- a/scan.c +++ b/scan.c @@ -214,7 +214,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, s pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name); if (stat(path_next, &st) != 0) { - fprintf(stderr, "Error in stat file '%s'\n", path_next); + fprintf(stderr, "Error in stat file/directory '%s'\n", path_next); exit(EXIT_FAILURE); } diff --git a/snapraid.1 b/snapraid.1 index 23431af1..87f0cf30 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -506,8 +506,7 @@ globbing character like * and ? but they never matches a directory slash. This pattern is applied only to directories and not to files. .PP -Note that when globbing chars are used in the command line, you have to -quote them in Unix. Otherwise the shell will try to expand them. +In Windows you can freely use the backslash \(rs instead of the forward slash /. .PP In the configuration file, you can use different strategies to filter the files to process. @@ -621,6 +620,9 @@ snapraid \(hyf \(a"*.mp3\(a" check .PP .PD .RE +.PP +In Unix, when using globbing chars in the command line, you have to quote them. +Otherwise the shell will try to expand them. .SH CONTENT SnapRAID stores the list and checksums of your files in the content file. .PP diff --git a/snapraid.conf.example.windows b/snapraid.conf.example.windows index 3f85b878..90a5c696 100644 --- a/snapraid.conf.example.windows +++ b/snapraid.conf.example.windows @@ -29,13 +29,14 @@ disk d2 H:\array\ disk d3 I:\array\ # Defines files and directories to exclude -# Remember to use the forward slash -> / +# Remember that all the paths are relative at the mount points # Format: "exclude FILE" -# Format: "exclude DIR/" -# Format: "exclude /PATH/FILE" -# Format: "exclude /PATH/DIR/" +# Format: "exclude DIR\" +# Format: "exclude \PATH\FILE" +# Format: "exclude \PATH\DIR\" exclude *.bak -exclude tmp/ +exclude AppData\ +exclude \System Volume Information\ # Defines the block size in kibi bytes (1024 bytes). # Default value is 256 -> 256 kibi bytes -> 262144 bytes diff --git a/snapraid.d b/snapraid.d index 58d75406..f02c620a 100644 --- a/snapraid.d +++ b/snapraid.d @@ -362,8 +362,7 @@ Pattern directory slash. This pattern is applied only to directories and not to files. - Note that when globbing chars are used in the command line, you have to - quote them in Unix. Otherwise the shell will try to expand them. + In Windows you can freely use the backslash \ instead of the forward slash /. In the configuration file, you can use different strategies to filter the files to process. @@ -407,6 +406,9 @@ Pattern :# Note the "" use to avoid globbing expansion by the shell in Unix. :snapraid -f "*.mp3" check + In Unix, when using globbing chars in the command line, you have to quote them. + Otherwise the shell will try to expand them. + Content SnapRAID stores the list and checksums of your files in the content file. diff --git a/util.c b/util.c index 83bbf427..ea5b99aa 100644 --- a/util.c +++ b/util.c @@ -180,17 +180,14 @@ void pathcpy(char* str, size_t size, const char* src) void pathimport(char* str, size_t size, const char* src) { -#ifdef _WIN32 - size_t len; -#endif - pathcpy(str, size, src); #ifdef _WIN32 - /* convert last \ to / */ - len = strlen(str); - if (len && str[len-1] == '\\') { - str[len-1] = '/'; + /* convert all Windows '\' to '/' */ + while (*str) { + if (*str == '\\') + *str = '/'; + ++str; } #endif } diff --git a/util.h b/util.h index 0b74af28..8b37d694 100644 --- a/util.h +++ b/util.h @@ -84,7 +84,7 @@ void pathcpy(char* str, size_t size, const char* src); /** * Imports a path limiting the size. - * In Windows, the last slash, if present, is converted to the C standard. + * In Windows all the backslash are converted to the C standard of forward slash. * Aborts if too long. */ void pathimport(char* str, size_t size, const char* src);