In Windows convert backslash to forward slash.

This commit is contained in:
Andrea Mazzoleni 2011-05-03 23:28:03 +02:00
parent 61eb8e802f
commit 5a2e118c38
9 changed files with 25 additions and 21 deletions

View file

@ -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
==========

2
elem.c
View file

@ -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 */

View file

@ -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));
}

2
scan.c
View file

@ -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);
}

View file

@ -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

View file

@ -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

View file

@ -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.

13
util.c
View file

@ -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
}

2
util.h
View file

@ -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);