Differences From:
File
src/file.c
part of check-in
[becc24e4e9]
- On windows builds, understand both "C:/" and "C:\" as the beginning of
an absolute pathname.
by
drh on
2008-05-01 18:42:26.
[view]
To:
File
src/file.c
part of check-in
[525cc35bf3]
- Allow the check-in of files show names begin with ".". Add the "private"
table to repository schema but do not yet do anything with it.
by
drh on
2008-05-17 08:53:34.
[view]
@@ -74,8 +74,9 @@
struct stat buf;
if( stat(zFilename, &buf)!=0 ){
return 0;
}
+ if( !S_ISREG(buf.st_mode) ) return 0;
#ifdef __MINGW32__
return ((S_IXUSR)&buf.st_mode)!=0;
#else
return ((S_IXUSR|S_IXGRP|S_IXOTH)&buf.st_mode)!=0;
@@ -89,9 +90,9 @@
#ifndef __MINGW32__
struct stat buf;
if( stat(zFilename, &buf)!=0 ) return;
if( onoff ){
- if( (buf.st_mode & 0111)==0 ){
+ if( (buf.st_mode & 0111)!=0111 ){
chmod(zFilename, buf.st_mode | 0111);
}
}else{
if( (buf.st_mode & 0111)!=0 ){
@@ -142,24 +143,30 @@
** a file in a repository. Valid filenames follow all of the
** following rules:
**
** * Does not begin with "/"
-** * Does not contain any path element that begins with "."
+** * Does not contain any path element named "." or ".."
** * Does not contain any of these characters in the path: "\*[]?"
** * Does not end with "/".
** * Does not contain two or more "/" characters in a row.
** * Contains at least one character
*/
int file_is_simple_pathname(const char *z){
int i;
- if( *z=='.' || *z=='/' || *z==0 ) return 0;
+ if( *z=='/' || *z==0 ) return 0;
+ if( *z=='.' ){
+ if( z[1]=='/' || z[1]==0 ) return 0;
+ if( z[1]=='.' && (z[2]=='/' || z[2]==0) ) return 0;
+ }
for(i=0; z[i]; i++){
if( z[i]=='\\' || z[i]=='*' || z[i]=='[' || z[i]==']' || z[i]=='?' ){
return 0;
}
if( z[i]=='/' ){
- if( z[i+1]=='/' || z[i+1]=='.' ){
- return 0;
+ if( z[i+1]=='/' ) return 0;
+ if( z[i+1]=='.' ){
+ if( z[i+2]=='/' || z[i+2]==0 ) return 0;
+ if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
}
}
}
if( z[i-1]=='/' ) return 0;