Fossil SCM

Add the 'test-file-environment' test command.

mistachkin 2017-02-13 23:56 UTC symlinks
Commit c891d86c6c06ba2631d5281465f5d55c2d1309eb
1 file changed +38
+38
--- src/file.c
+++ src/file.c
@@ -939,10 +939,48 @@
939939
}
940940
#endif
941941
blob_resize(pOut, file_simplify_name(blob_buffer(pOut),
942942
blob_size(pOut), slash));
943943
}
944
+
945
+/*
946
+** COMMAND: test-file-environment
947
+**
948
+** Usage: %fossil test-file-environment FILENAME...
949
+**
950
+** Display the effective file handling subsystem "settings" and then
951
+** display file system information about the files specified, if any.
952
+*/
953
+void cmd_test_file_environment(void){
954
+ int i;
955
+ Blob x;
956
+ int slashFlag = find_option("slash",0,0)!=0;
957
+ blob_zero(&x);
958
+ fossil_print("filenames_are_case_sensitive() = %d\n",
959
+ filenames_are_case_sensitive());
960
+ fossil_print("db_allow_symlinks_by_default() = %d\n",
961
+ db_allow_symlinks_by_default());
962
+ fossil_print("db_allow_symlinks(0) = %d\n", db_allow_symlinks(0));
963
+ fossil_print("db_allow_symlinks(1) = %d\n", db_allow_symlinks(1));
964
+ for(i=2; i<g.argc; i++){
965
+ int rc;
966
+ char zBuf[100];
967
+ const char *zName = g.argv[i];
968
+ struct fossilStat testFileStat;
969
+ file_canonical_name(zName, &x, slashFlag);
970
+ fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
971
+ blob_reset(&x);
972
+ memset(&testFileStat, 0, sizeof(struct fossilStat));
973
+ rc = fossil_stat(zName, &testFileStat, 1, 1);
974
+ fossil_print(" stat_rc = %d\n", rc);
975
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_size);
976
+ fossil_print(" file_size = %s\n", zBuf);
977
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
978
+ fossil_print(" file_mtime = %s\n", zBuf);
979
+ fossil_print(" file_mode = %d\n", testFileStat.st_mode);
980
+ }
981
+}
944982
945983
/*
946984
** COMMAND: test-canonical-name
947985
**
948986
** Usage: %fossil test-canonical-name FILENAME...
949987
--- src/file.c
+++ src/file.c
@@ -939,10 +939,48 @@
939 }
940 #endif
941 blob_resize(pOut, file_simplify_name(blob_buffer(pOut),
942 blob_size(pOut), slash));
943 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
944
945 /*
946 ** COMMAND: test-canonical-name
947 **
948 ** Usage: %fossil test-canonical-name FILENAME...
949
--- src/file.c
+++ src/file.c
@@ -939,10 +939,48 @@
939 }
940 #endif
941 blob_resize(pOut, file_simplify_name(blob_buffer(pOut),
942 blob_size(pOut), slash));
943 }
944
945 /*
946 ** COMMAND: test-file-environment
947 **
948 ** Usage: %fossil test-file-environment FILENAME...
949 **
950 ** Display the effective file handling subsystem "settings" and then
951 ** display file system information about the files specified, if any.
952 */
953 void cmd_test_file_environment(void){
954 int i;
955 Blob x;
956 int slashFlag = find_option("slash",0,0)!=0;
957 blob_zero(&x);
958 fossil_print("filenames_are_case_sensitive() = %d\n",
959 filenames_are_case_sensitive());
960 fossil_print("db_allow_symlinks_by_default() = %d\n",
961 db_allow_symlinks_by_default());
962 fossil_print("db_allow_symlinks(0) = %d\n", db_allow_symlinks(0));
963 fossil_print("db_allow_symlinks(1) = %d\n", db_allow_symlinks(1));
964 for(i=2; i<g.argc; i++){
965 int rc;
966 char zBuf[100];
967 const char *zName = g.argv[i];
968 struct fossilStat testFileStat;
969 file_canonical_name(zName, &x, slashFlag);
970 fossil_print("[%s] -> [%s]\n", zName, blob_buffer(&x));
971 blob_reset(&x);
972 memset(&testFileStat, 0, sizeof(struct fossilStat));
973 rc = fossil_stat(zName, &testFileStat, 1, 1);
974 fossil_print(" stat_rc = %d\n", rc);
975 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_size);
976 fossil_print(" file_size = %s\n", zBuf);
977 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", testFileStat.st_mtime);
978 fossil_print(" file_mtime = %s\n", zBuf);
979 fossil_print(" file_mode = %d\n", testFileStat.st_mode);
980 }
981 }
982
983 /*
984 ** COMMAND: test-canonical-name
985 **
986 ** Usage: %fossil test-canonical-name FILENAME...
987

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button