Fossil SCM

Simplify a test when looking for the command tail.

danield 2025-01-03 14:21 UTC ssh-signing
Commit b273cc99874ab574983f31716a69f0596daa6095e94528a0bed170f484f9192d
1 file changed +48 -3
+48 -3
--- a/src/file.c
+++ b/src/file.c
@@ -1,3 +1,48 @@
1
-if( chQuote && chQuote==z[0] )
2
- chQuote = 0;
3
- else chQuote = z[0]
1
+ior non-directory object
2
+** with the same name.
3
+**
4
+** Return the number of errors.
5
+*/
6
+int file_mkdir(const char *zName, int eFType, int forceFlag){
7
+ int rc = file_isdir(zName, eFType);
8
+ if( rc==2 ){
9
+ if( !forceFlag ) return 1;
10
+ file_delete(zName);
11
+ }
12
+ if( rc!=1 ){
13
+#if defined(_WIN32)
14
+ wchar_t *zMbcs = fossil_utf8_to_path(zName, 1);
15
+ rc = _wmkdir(zMbcs);
16
+#else
17
+ char *zMbcs = fossil_utf8_to_path(zName, 1);
18
+ rc = mkdir(zMbcs, 0755);
19
+#endif
20
+ fossil_path_free(zMbcs);
21
+ return rc;
22
+ }
23
+ return 0;
24
+}
25
+
26
+/*
27
+** Create the tree of directories in which zFilename belongs, if that sequence
28
+** of directories does not already exist.
29
+**
30
+** On success, return zero. On error, return errorReturn if positive, otherwise
31
+** print an error message and abort.
32
+*/
33
+int file_mkfolder(
34
+ const char *zFilename, /* Pathname showing directories to be created */
35
+ int eFType, /* Follow symlinks if ExtFILE */
36
+ int forceFlag, /* Delete non-directory objects in the way */
37
+ int errorReturn /* What to do when an error is seen */
38
+){
39
+ int nName, rc = 0;
40
+ char *zName;
41
+
42
+ nName = strlen(zFilename);
43
+ zName = fossil_strdup(zFilename);
44
+ nName = file_simplify_name(zName, nName, 0);
45
+ while( nName>0 && zName[nName-1]!='/' ){ nName--; }
46
+ if( nName>1 ){
47
+ zName[nName-1] = 0;
48
+ if( file_isdir(zName, eFType)
--- a/src/file.c
+++ b/src/file.c
@@ -1,3 +1,48 @@
1 if( chQuote && chQuote==z[0] )
2 chQuote = 0;
3 else chQuote = z[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/file.c
+++ b/src/file.c
@@ -1,3 +1,48 @@
1 ior non-directory object
2 ** with the same name.
3 **
4 ** Return the number of errors.
5 */
6 int file_mkdir(const char *zName, int eFType, int forceFlag){
7 int rc = file_isdir(zName, eFType);
8 if( rc==2 ){
9 if( !forceFlag ) return 1;
10 file_delete(zName);
11 }
12 if( rc!=1 ){
13 #if defined(_WIN32)
14 wchar_t *zMbcs = fossil_utf8_to_path(zName, 1);
15 rc = _wmkdir(zMbcs);
16 #else
17 char *zMbcs = fossil_utf8_to_path(zName, 1);
18 rc = mkdir(zMbcs, 0755);
19 #endif
20 fossil_path_free(zMbcs);
21 return rc;
22 }
23 return 0;
24 }
25
26 /*
27 ** Create the tree of directories in which zFilename belongs, if that sequence
28 ** of directories does not already exist.
29 **
30 ** On success, return zero. On error, return errorReturn if positive, otherwise
31 ** print an error message and abort.
32 */
33 int file_mkfolder(
34 const char *zFilename, /* Pathname showing directories to be created */
35 int eFType, /* Follow symlinks if ExtFILE */
36 int forceFlag, /* Delete non-directory objects in the way */
37 int errorReturn /* What to do when an error is seen */
38 ){
39 int nName, rc = 0;
40 char *zName;
41
42 nName = strlen(zFilename);
43 zName = fossil_strdup(zFilename);
44 nName = file_simplify_name(zName, nName, 0);
45 while( nName>0 && zName[nName-1]!='/' ){ nName--; }
46 if( nName>1 ){
47 zName[nName-1] = 0;
48 if( file_isdir(zName, eFType)

Keyboard Shortcuts

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