937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
|
zOut[0] = fossil_toupper(zOut[0]);
}
}
#endif
blob_resize(pOut, file_simplify_name(blob_buffer(pOut),
blob_size(pOut), slash));
}
/*
** COMMAND: test-file-environment
**
** Usage: %fossil test-file-environment FILENAME...
**
** Display the effective file handling subsystem "settings" and then
** display file system information about the files specified, if any.
**
** Options:
**
** --open-config Open the configuration database first.
** --slash Trailing slashes, if any, are retained.
*/
void cmd_test_file_environment(void){
int i;
Blob x;
int slashFlag = find_option("slash",0,0)!=0;
if( find_option("open-config", 0, 0)!=0 ){
Th_OpenConfig(1);
}
blob_zero(&x);
fossil_print("Th_IsRepositoryOpen() = %d\n", Th_IsRepositoryOpen());
fossil_print("Th_IsConfigOpen() = %d\n", Th_IsConfigOpen());
fossil_print("filenames_are_case_sensitive() = %d\n",
filenames_are_case_sensitive());
fossil_print("db_allow_symlinks_by_default() = %d\n",
db_allow_symlinks_by_default());
fossil_print("db_allow_symlinks(0) = %d\n", db_allow_symlinks(0));
fossil_print("db_allow_symlinks(1) = %d\n", db_allow_symlinks(1));
for(i=2; i<g.argc; i++){
int rc;
char zBuf[100];
const char *zName = g.argv[i];
struct fossilStat testFileStat;
file_canonical_name(zName, &x, slashFlag);
fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
blob_reset(&x);
memset(&testFileStat, 0, sizeof(struct fossilStat));
rc = fossil_stat(zName, &testFileStat, 0, 0);
fossil_print(" stat_rc = %d\n", rc);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_size);
fossil_print(" file_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
fossil_print(" file_mtime = %s\n", zBuf);
fossil_print(" file_mode = %d\n", testFileStat.st_mode);
memset(&testFileStat, 0, sizeof(struct fossilStat));
rc = fossil_stat(zName, &testFileStat, 1, 1);
fossil_print(" l_stat_rc = %d\n", rc);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_size);
fossil_print(" l_file_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
fossil_print(" l_file_mtime = %s\n", zBuf);
fossil_print(" l_file_mode = %d\n", testFileStat.st_mode);
}
}
/*
** COMMAND: test-canonical-name
**
** Usage: %fossil test-canonical-name FILENAME...
**
** Test the operation of the canonical name generator.
** Also test Fossil's ability to measure attributes of a file.
**
** Options:
**
** --slash Trailing slashes, if any, are retained.
*/
void cmd_test_canonical_name(void){
int i;
Blob x;
int slashFlag = find_option("slash",0,0)!=0;
blob_zero(&x);
for(i=2; i<g.argc; i++){
char zBuf[100];
const char *zName = g.argv[i];
file_canonical_name(zName, &x, slashFlag);
fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
blob_reset(&x);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zName));
fossil_print(" file_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zName));
fossil_print(" file_mtime = %s\n", zBuf);
fossil_print(" file_isfile = %d\n", file_wd_isfile(zName));
fossil_print(" file_isfile_or_link = %d\n",file_wd_isfile_or_link(zName));
fossil_print(" file_islink = %d\n", file_wd_islink(zName));
fossil_print(" file_isexe = %d\n", file_wd_isexe(zName));
fossil_print(" file_isdir = %d\n", file_wd_isdir(zName));
}
}
/*
** Return TRUE if the given filename is canonical.
**
** Canonical names are full pathnames using "/" not "\" and which
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
<
<
<
<
|
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
<
>
|
>
<
<
|
<
<
<
<
<
<
<
<
<
<
<
|
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
|
zOut[0] = fossil_toupper(zOut[0]);
}
}
#endif
blob_resize(pOut, file_simplify_name(blob_buffer(pOut),
blob_size(pOut), slash));
}
/*
** Emits the effective or raw stat() information for the specified
** file or directory.
*/
static void emitFileStat(const char *zPath, int raw, int slash){
char zBuf[100];
Blob x;
memset(zBuf, 0, sizeof(zBuf));
blob_zero(&x);
file_canonical_name(zPath, &x, slash);
fossil_print("%s[%s] -> [%s]\n", raw ? "RAW " : "", zPath, blob_buffer(&x));
blob_reset(&x);
if( raw ){
int rc;
struct fossilStat testFileStat;
memset(&testFileStat, 0, sizeof(struct fossilStat));
rc = fossil_stat(zPath, &testFileStat, 0, 0);
fossil_print(" stat_rc = %d\n", rc);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_size);
fossil_print(" stat_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
fossil_print(" stat_mtime = %s\n", zBuf);
fossil_print(" stat_mode = %d\n", testFileStat.st_mode);
memset(&testFileStat, 0, sizeof(struct fossilStat));
rc = fossil_stat(zPath, &testFileStat, 1, 1);
fossil_print(" l_stat_rc = %d\n", rc);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_size);
fossil_print(" l_stat_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
fossil_print(" l_stat_mtime = %s\n", zBuf);
fossil_print(" l_stat_mode = %d\n", testFileStat.st_mode);
}else{
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_size(zPath));
fossil_print(" file_size = %s\n", zBuf);
sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", file_wd_mtime(zPath));
fossil_print(" file_mtime = %s\n", zBuf);
fossil_print(" file_isfile = %d\n", file_wd_isfile(zPath));
fossil_print(" file_isfile_or_link = %d\n",file_wd_isfile_or_link(zPath));
fossil_print(" file_islink = %d\n", file_wd_islink(zPath));
fossil_print(" file_isexe = %d\n", file_wd_isexe(zPath));
fossil_print(" file_isdir = %d\n", file_wd_isdir(zPath));
}
}
/*
** COMMAND: test-file-environment
**
** Usage: %fossil test-file-environment FILENAME...
**
** Display the effective file handling subsystem "settings" and then
** display file system information about the files specified, if any.
**
** Options:
**
** --open-config Open the configuration database first.
** --slash Trailing slashes, if any, are retained.
*/
void cmd_test_file_environment(void){
int i;
int slashFlag = find_option("slash",0,0)!=0;
if( find_option("open-config", 0, 0)!=0 ){
Th_OpenConfig(1);
}
fossil_print("Th_IsRepositoryOpen() = %d\n", Th_IsRepositoryOpen());
fossil_print("Th_IsConfigOpen() = %d\n", Th_IsConfigOpen());
fossil_print("filenames_are_case_sensitive() = %d\n",
filenames_are_case_sensitive());
fossil_print("db_allow_symlinks_by_default() = %d\n",
db_allow_symlinks_by_default());
fossil_print("db_allow_symlinks(0) = %d\n", db_allow_symlinks(0));
fossil_print("db_allow_symlinks(1) = %d\n", db_allow_symlinks(1));
for(i=2; i<g.argc; i++){
emitFileStat(g.argv[i], 1, slashFlag);
emitFileStat(g.argv[i], 0, slashFlag);
}
}
/*
** COMMAND: test-canonical-name
**
** Usage: %fossil test-canonical-name FILENAME...
**
** Test the operation of the canonical name generator.
** Also test Fossil's ability to measure attributes of a file.
**
** Options:
**
** --open-config Open the configuration database first.
** --slash Trailing slashes, if any, are retained.
*/
void cmd_test_canonical_name(void){
int i;
int slashFlag = find_option("slash",0,0)!=0;
if( find_option("open-config", 0, 0)!=0 ){
Th_OpenConfig(1);
}
for(i=2; i<g.argc; i++){
emitFileStat(g.argv[i], 0, slashFlag);
}
}
/*
** Return TRUE if the given filename is canonical.
**
** Canonical names are full pathnames using "/" not "\" and which
|