- Timestamp:
- Sep 16, 2020 9:12:58 PM (4 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/redir.c
r3463 r3473 67 67 68 68 #define EMPTY -2 /* marks an unused slot in redirtab */ 69 #ifndef PIPE_BUF 70 # define PIPESIZE 4096 /* amount of buffering in a pipe */ 71 #else 72 # define PIPESIZE PIPE_BUF 73 #endif 69 #define PIPESIZE SHFILE_PIPE_SIZE 74 70 75 71 -
trunk/src/kash/shfile.c
r3471 r3473 36 36 37 37 #if K_OS == K_OS_WINDOWS 38 # include <limits.h>39 # ifndef PIPE_BUF40 # define PIPE_BUF 51241 # endif42 38 # include <ntstatus.h> 43 39 # define WIN32_NO_STATUS … … 1711 1707 1712 1708 fds[1] = fds[0] = -1; 1713 if (CreatePipe(&hRead, &hWrite, &SecurityAttributes, 4096))1709 if (CreatePipe(&hRead, &hWrite, &SecurityAttributes, SHFILE_PIPE_SIZE)) 1714 1710 { 1715 1711 fds[0] = shfile_insert(pfdtab, (intptr_t)hRead, O_RDONLY, SHFILE_FLAGS_PIPE, -1, "shfile_pipe", "pipe-rd"); … … 2193 2189 #else 2194 2190 return stat(path, pst); 2191 #endif 2192 } 2193 2194 /** 2195 * @retval 1 if regular file. 2196 * @retval 0 if found but not a regular file. 2197 * @retval -1 and errno on failure 2198 */ 2199 int shfile_stat_isreg(shfdtab *pfdtab, const char *path) 2200 { 2201 #if defined(SHFILE_IN_USE) && K_OS == K_OS_WINDOWS 2202 char abspath[SHFILE_MAX_PATH]; 2203 KU16 mode = 0; 2204 int rc = shfile_make_path(pfdtab, path, &abspath[0]); 2205 if (!rc) 2206 { 2207 rc = birdStatModeOnly(abspath, &mode, 0 /*fFollowLink*/); 2208 if (rc >= 0) 2209 rc = S_ISREG(mode) ? 1 : 0; 2210 } 2211 TRACE2((NULL, "shfile_stat_isreg(,%s,) -> %d [%d] st_mode=%o\n", path, rc, errno, mode)); 2212 return rc; 2213 #else 2214 struct stat st; 2215 int rc = shfile_stat(pfdtab, path, &st); 2216 if (rc >= 0) 2217 rc = S_ISREG(st.st_mode) ? 1 : 0; 2218 return rc; 2219 #endif 2220 } 2221 2222 /** 2223 * Same as shfile_stat, but without the data structure. 2224 */ 2225 int shfile_stat_exists(shfdtab *pfdtab, const char *path) 2226 { 2227 #if defined(SHFILE_IN_USE) && K_OS == K_OS_WINDOWS 2228 char abspath[SHFILE_MAX_PATH]; 2229 KU16 mode = 0; 2230 int rc = shfile_make_path(pfdtab, path, &abspath[0]); 2231 if (!rc) 2232 rc = birdStatModeOnly(abspath, &mode, 0 /*fFollowLink*/); 2233 TRACE2((NULL, "shfile_stat_exists(,%s,) -> %d [%d] st_mode=%o\n", path, rc, errno, mode)); 2234 return rc; 2235 #else 2236 struct stat ignored; 2237 return shfile_stat(pfdtab, path, &ignored); 2195 2238 #endif 2196 2239 } -
trunk/src/kash/shfile.h
r3469 r3473 47 47 # endif 48 48 #endif 49 #include <limits.h> /* for PIPE_BUF */ 49 50 #ifndef _MSC_VER 50 51 # include <fcntl.h> … … 160 161 161 162 int shfile_open(shfdtab *, const char *, unsigned, mode_t); 163 #if K_OS == K_OS_WINDOWS 164 # define SHFILE_PIPE_SIZE 65536 165 #elif defined(PIPE_BUF) 166 # define SHFILE_PIPE_SIZE PIPE_BUF 167 #else 168 # define SHFILE_PIPE_SIZE 4096 169 #endif 162 170 int shfile_pipe(shfdtab *, int [2]); 163 171 int shfile_close(shfdtab *, unsigned); … … 171 179 172 180 int shfile_stat(shfdtab *, const char *, struct stat *); 181 int shfile_stat_isreg(shfdtab *, const char *); /**< returns -1, 0 or 1. */ 182 int shfile_stat_exists(shfdtab *, const char *); /**< same as shfile_stat, but discards the stat data. */ 173 183 int shfile_lstat(shfdtab *, const char *, struct stat *); 174 184 int shfile_chdir(shfdtab *, const char *);
Note:
See TracChangeset
for help on using the changeset viewer.