- Timestamp:
- Nov 5, 2016, 8:37:35 PM (9 years ago)
- Location:
- trunk/src/lib/nt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/nt/fts-nt.c
r2992 r2998 86 86 #include "ntdir.h" 87 87 88 static FTSENT *fts_alloc(FTS *, char *, size_t); 88 static FTSENT *fts_alloc(FTS *sp, char const *name, size_t namelen, wchar_t const *wcsname, size_t cwcname); 89 static FTSENT *fts_alloc_ansi(FTS *sp, char const *name, size_t namelen); 90 static FTSENT *fts_alloc_utf16(FTS *sp, wchar_t const *wcsname, size_t cwcname); 89 91 static FTSENT *fts_build(FTS *, int); 90 92 static void fts_lfree(FTSENT *); 91 93 static void fts_load(FTS *, FTSENT *); 92 94 static size_t fts_maxarglen(char * const *); 95 static size_t fts_maxarglenw(wchar_t * const *); 93 96 static void fts_padjust(FTS *, FTSENT *); 94 static int fts_palloc(FTS *, size_t); 97 static void fts_padjustw(FTS *, FTSENT *); 98 static int fts_palloc(FTS *, size_t, size_t); 95 99 static FTSENT *fts_sort(FTS *, FTSENT *, size_t); 96 100 static int fts_stat(FTS *, FTSENT *, int, HANDLE); … … 126 130 127 131 128 FTS * FTSCALL129 nt_fts_open (char * const *argv, int options,132 static FTS * FTSCALL 133 nt_fts_open_common(char * const *argv, wchar_t * const *wcsargv, int options, 130 134 int (*compar)(const FTSENT * const *, const FTSENT * const *)) 131 135 { … … 135 139 FTSENT *parent, *tmp; 136 140 size_t len, nitems; 141 142 birdResolveImports(); 137 143 138 144 /* Options check. */ … … 163 169 * to hold the user's paths. 164 170 */ 165 if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN))) 171 if (fts_palloc(sp, MAX(argv ? fts_maxarglen(argv) : 1, MAXPATHLEN), 172 MAX(wcsargv ? fts_maxarglenw(wcsargv) : 1, MAXPATHLEN)) ) 166 173 goto mem1; 167 174 168 175 /* Allocate/initialize root's parent. */ 169 if ((parent = fts_alloc(sp, "", 0)) == NULL)176 if ((parent = fts_alloc(sp, NULL, 0, NULL, 0)) == NULL) 170 177 goto mem2; 171 178 parent->fts_level = FTS_ROOTPARENTLEVEL; … … 177 184 appended so it won't matter if a slash is appended afterwards. 178 185 2. DOS slashes are converted to UNIX ones. */ 179 char *slash; 180 len = strlen(*argv); 181 if (len == 2 && argv[0][1] == ':') { 182 char tmp[4]; 183 tmp[0] = argv[0][0]; 184 tmp[1] = ':'; 185 tmp[2] = '.'; 186 tmp[3] = '\0'; 187 p = fts_alloc(sp, tmp, 3); 186 wchar_t *wcslash; 187 188 if (wcsargv) { 189 len = wcslen(*wcsargv); 190 if (len == 2 && wcsargv[0][1] == ':') { 191 wchar_t wcsdrive[4]; 192 wcsdrive[0] = wcsargv[0][0]; 193 wcsdrive[1] = ':'; 194 wcsdrive[2] = '.'; 195 wcsdrive[3] = '\0'; 196 p = fts_alloc_utf16(sp, wcsdrive, 3); 197 } else { 198 p = fts_alloc_utf16(sp, *wcsargv, len); 199 } 188 200 } else { 189 p = fts_alloc(sp, *argv, len); 190 } 191 #if 1 /* bird */ 201 len = strlen(*argv); 202 if (len == 2 && argv[0][1] == ':') { 203 char szdrive[4]; 204 szdrive[0] = argv[0][0]; 205 szdrive[1] = ':'; 206 szdrive[2] = '.'; 207 szdrive[3] = '\0'; 208 p = fts_alloc_ansi(sp, szdrive, 3); 209 } else { 210 p = fts_alloc_ansi(sp, *argv, len); 211 } 212 } 192 213 if (p != NULL) { /* likely */ } else { goto mem3; } 193 #endif 194 slash = strchr(p->fts_name, '\\'); 195 while (slash != NULL) { 196 *slash++ = '/'; 197 slash = strchr(p->fts_name, '\\'); 198 } 214 215 wcslash = wcschr(p->fts_wcsname, '\\'); 216 while (wcslash != NULL) { 217 *wcslash++ = '/'; 218 wcslash = wcschr(p->fts_wcsname, '\\'); 219 } 220 221 if (p->fts_name) { 222 char *slash = strchr(p->fts_name, '\\'); 223 while (slash != NULL) { 224 *slash++ = '/'; 225 slash = strchr(p->fts_name, '\\'); 226 } 227 } 228 199 229 p->fts_level = FTS_ROOTLEVEL; 200 230 p->fts_parent = parent; 201 231 p->fts_accpath = p->fts_name; 232 p->fts_wcsaccpath = p->fts_wcsname; 202 233 p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW), INVALID_HANDLE_VALUE); 203 234 … … 231 262 * so that everything about the "current" node is ignored. 232 263 */ 233 if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL)264 if ((sp->fts_cur = fts_alloc(sp, NULL, 0, NULL, 0)) == NULL) 234 265 goto mem3; 235 266 sp->fts_cur->fts_link = root; … … 238 269 return (sp); 239 270 240 mem3: fts_lfree(root); 271 mem3: 272 fts_lfree(root); 241 273 free(parent); 242 mem2: free(sp->fts_path); 243 mem1: free(sp); 274 mem2: 275 free(sp->fts_path); 276 free(sp->fts_wcspath); 277 mem1: 278 free(sp); 244 279 return (NULL); 245 280 } 246 281 247 282 283 FTS * FTSCALL 284 nt_fts_open(char * const *argv, int options, 285 int (*compar)(const FTSENT * const *, const FTSENT * const *)) 286 { 287 return nt_fts_open_common(argv, NULL, options, compar); 288 } 289 290 291 FTS * FTSCALL 292 nt_fts_openw(wchar_t * const *argv, int options, 293 int (*compar)(const FTSENT * const *, const FTSENT * const *)) 294 { 295 return nt_fts_open_common(NULL, argv, options, compar); 296 } 297 298 299 /** 300 * Called by fts_read for FTS_ROOTLEVEL entries only. 301 */ 248 302 static void 249 303 fts_load(FTS *sp, FTSENT *p) 250 304 { 251 305 size_t len; 252 char *cp;306 wchar_t *pwc; 253 307 254 308 /* … … 259 313 * known that the path will fit. 260 314 */ 261 len = p->fts_pathlen = p->fts_namelen; 262 memmove(sp->fts_path, p->fts_name, len + 1); 263 if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { 264 len = strlen(++cp); 265 memmove(p->fts_name, cp, len + 1); 266 p->fts_namelen = len; 267 } 268 p->fts_accpath = p->fts_path = sp->fts_path; 315 if (!(sp->fts_options & FTS_NO_ANSI)) { 316 char *cp; 317 len = p->fts_pathlen = p->fts_namelen; 318 memmove(sp->fts_path, p->fts_name, len + 1); 319 cp = strrchr(p->fts_name, '/'); 320 if (cp != NULL && (cp != p->fts_name || cp[1])) { 321 len = strlen(++cp); 322 memmove(p->fts_name, cp, len + 1); 323 p->fts_namelen = len; 324 } 325 p->fts_accpath = p->fts_path = sp->fts_path; 326 } 327 328 len = p->fts_cwcpath = p->fts_cwcname; 329 memmove(sp->fts_wcspath, p->fts_wcsname, (len + 1) * sizeof(wchar_t)); 330 pwc = wcsrchr(p->fts_wcsname, '/'); 331 if (pwc != NULL && (pwc != p->fts_wcsname || pwc[1])) { 332 len = wcslen(++pwc); 333 memmove(p->fts_wcsname, pwc, (len + 1) * sizeof(wchar_t)); 334 p->fts_cwcname = len; 335 } 336 p->fts_wcsaccpath = p->fts_wcspath = sp->fts_wcspath; 337 269 338 sp->fts_dev = p->fts_dev; 270 339 } … … 296 365 free(sp->fts_array); 297 366 free(sp->fts_path); 367 free(sp->fts_wcspath); 298 368 299 369 /* Free up the stream pointer. */ … … 306 376 * appended which would cause paths to be written as "....//foo". 307 377 */ 308 #define NAPPEND(p) \ 309 (p->fts_path[p->fts_pathlen - 1] == '/' \ 310 ? p->fts_pathlen - 1 : p->fts_pathlen) 378 #define NAPPEND(p) ( p->fts_pathlen - (p->fts_path[p->fts_pathlen - 1] == '/') ) 379 #define NAPPENDW(p) ( p->fts_cwcpath - (p->fts_wcspath[p->fts_cwcpath - 1] == L'/') ) 311 380 312 381 static void … … 327 396 FTSENT *p, *tmp; 328 397 int instr; 329 char *t;398 wchar_t *pwc; 330 399 331 400 /* If finished or unrecoverable error, return NULL. */ … … 447 516 fts_free_entry(tmp); 448 517 449 name: t = sp->fts_path + NAPPEND(p->fts_parent); 450 *t++ = '/'; 451 memmove(t, p->fts_name, p->fts_namelen + 1); 518 name: 519 if (!(sp->fts_options & FTS_NO_ANSI)) { 520 char *t = sp->fts_path + NAPPEND(p->fts_parent); 521 *t++ = '/'; 522 memmove(t, p->fts_name, p->fts_namelen + 1); 523 } 524 pwc = sp->fts_wcspath + NAPPENDW(p->fts_parent); 525 *pwc++ = '/'; 526 memmove(pwc, p->fts_wcsname, (p->fts_cwcname + 1) * sizeof(wchar_t)); 452 527 return (sp->fts_cur = p); 453 528 } … … 468 543 469 544 /* NUL terminate the pathname. */ 470 sp->fts_path[p->fts_pathlen] = '\0'; 545 if (!(sp->fts_options & FTS_NO_ANSI)) 546 sp->fts_path[p->fts_pathlen] = '\0'; 547 sp->fts_wcspath[ p->fts_cwcpath] = '\0'; 471 548 472 549 /* … … 478 555 * and clear fts_symfd now. 479 556 */ 480 if (p->fts_flags & FTS_SYMFOLLOW) {557 if (p->fts_flags & FTS_SYMFOLLOW) 481 558 p->fts_symfd = INVALID_HANDLE_VALUE; 482 }483 559 if (p->fts_dirfd != INVALID_HANDLE_VALUE) { 484 560 birdCloseFile(p->fts_dirfd); … … 614 690 FTSENT *cur, *tail; 615 691 DIR *dirp; 616 void *oldaddr; 617 char *cp; 618 int saved_errno, doadjust; 692 int saved_errno, doadjust, doadjust_utf16; 619 693 long level; 620 size_t dnamlen, len, maxlen, nitems;694 size_t len, cwcdir, maxlen, cwcmax, nitems; 621 695 unsigned fDirOpenFlags; 622 696 … … 676 750 * each new name into the path. 677 751 */ 678 len = NAPPEND(cur); 679 cp = sp->fts_path + len; 680 *cp++ = '/'; 681 len++; 682 maxlen = sp->fts_pathlen - len; 752 if (sp->fts_options & FTS_NO_ANSI) { 753 len = maxlen = 0; 754 } else { 755 len = NAPPEND(cur); 756 sp->fts_path[len] = '/'; /// @todo unnecessary? 757 len++; 758 maxlen = sp->fts_pathlen - len; 759 } 760 761 cwcdir = NAPPENDW(cur); 762 sp->fts_wcspath[cwcdir] = '/'; /// @todo unnecessary? 763 cwcdir++; 764 cwcmax = sp->fts_cwcpath - len; 683 765 684 766 level = cur->fts_level + 1; 685 767 686 768 /* Read the directory, attaching each entry to the `link' pointer. */ 687 doadjust = 0;769 doadjust = doadjust_utf16 = 0; 688 770 for (head = tail = NULL, nitems = 0; dirp && (dp = birdDirRead(dirp));) { 689 dnamlen = dp->d_namlen;690 771 if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) 691 772 continue; 692 773 693 if ((p = fts_alloc (sp, dp->d_name, dnamlen)) == NULL)774 if ((p = fts_alloc_ansi(sp, dp->d_name, dp->d_namlen)) == NULL) 694 775 goto mem1; 695 if (dnamlen >= maxlen) { /* include space for NUL */ 696 oldaddr = sp->fts_path; 697 if (fts_palloc(sp, dnamlen + len + 1)) { 776 777 if (p->fts_namelen >= maxlen 778 || p->fts_cwcname >= cwcmax) { /* include space for NUL */ 779 void *oldaddr = sp->fts_path; 780 wchar_t *oldwcspath = sp->fts_wcspath; 781 if (fts_palloc(sp, 782 p->fts_namelen >= maxlen ? len + p->fts_namelen + 1 : 0, 783 p->fts_cwcname >= cwcmax ? cwcdir + p->fts_cwcname + 1 : 0)) { 698 784 /* 699 785 * No more memory for path or structures. Save … … 714 800 } 715 801 /* Did realloc() change the pointer? */ 716 if (oldaddr != sp->fts_path) { 717 doadjust = 1; 718 if (1 /*ISSET(FTS_NOCHDIR)*/) 719 cp = sp->fts_path + len; 720 } 802 doadjust |= oldaddr != sp->fts_path; 803 doadjust_utf16 |= oldwcspath != sp->fts_wcspath; 721 804 maxlen = sp->fts_pathlen - len; 805 cwcmax = sp->fts_cwcpath - cwcdir; 722 806 } 723 807 724 808 p->fts_level = level; 725 809 p->fts_parent = sp->fts_cur; 726 p->fts_pathlen = len + dnamlen; 810 p->fts_pathlen = len + p->fts_namelen; 811 p->fts_cwcpath = cwcdir + p->fts_cwcname; 727 812 p->fts_accpath = p->fts_path; 813 p->fts_wcsaccpath = p->fts_wcspath; 728 814 p->fts_stat = dp->d_stat; 729 815 p->fts_info = fts_process_stats(p, &dp->d_stat); … … 748 834 if (doadjust) 749 835 fts_padjust(sp, head); 836 if (doadjust_utf16) 837 fts_padjustw(sp, head); 750 838 751 839 /* 752 840 * Reset the path back to original state. 753 841 */ 754 sp->fts_path[cur->fts_pathlen] = '\0'; 842 sp->fts_path[cur->fts_pathlen] = '\0'; // @todo necessary? 843 sp->fts_wcspath[cur->fts_cwcpath] = '\0'; // @todo necessary? 755 844 756 845 /* If didn't find anything, return NULL. */ … … 903 992 904 993 static FTSENT * 905 fts_alloc(FTS *sp, char *name, size_t namelen)994 fts_alloc(FTS *sp, char const *name, size_t namelen, wchar_t const *wcsname, size_t cwcname) 906 995 { 907 996 FTSENT *p; 908 997 size_t len; 909 998 910 struct ftsent_withstat {911 FTSENT ent;912 struct stat statbuf;913 };914 915 999 /* 916 1000 * The file name is a variable length array. Allocate the FTSENT 917 1001 * structure and the file name. 918 1002 */ 919 len = sizeof(FTSENT) + namelen + 1; 920 if ((p = malloc(len)) == NULL) 921 return (NULL); 922 923 p->fts_name = (char *)(p + 1); 924 p->fts_statp = &p->fts_stat; 925 926 /* Copy the name and guarantee NUL termination. */ 927 memcpy(p->fts_name, name, namelen); 928 p->fts_name[namelen] = '\0'; 929 p->fts_namelen = namelen; 930 p->fts_path = sp->fts_path; 931 p->fts_errno = 0; 932 p->fts_flags = 0; 933 p->fts_instr = FTS_NOINSTR; 934 p->fts_number = 0; 935 p->fts_pointer = NULL; 936 p->fts_fts = sp; 937 p->fts_symfd = INVALID_HANDLE_VALUE; 938 p->fts_dirfd = INVALID_HANDLE_VALUE; 1003 len = sizeof(FTSENT) + (cwcname + 1) * sizeof(wchar_t); 1004 if (!(sp->fts_options & FTS_NO_ANSI)) 1005 len += namelen + 1; 1006 p = malloc(len); 1007 if (p) { 1008 /* Copy the names and guarantee NUL termination. */ 1009 p->fts_wcsname = (wchar_t *)(p + 1); 1010 memcpy(p->fts_wcsname, wcsname, cwcname * sizeof(wchar_t)); 1011 p->fts_wcsname[cwcname]; 1012 p->fts_cwcname = cwcname; 1013 if (!(sp->fts_options & FTS_NO_ANSI)) { 1014 p->fts_name = (char *)(p->fts_wcsname + cwcname + 1); 1015 memcpy(p->fts_name, name, namelen); 1016 p->fts_name[namelen] = '\0'; 1017 p->fts_namelen = namelen; 1018 } else { 1019 p->fts_name = NULL; 1020 p->fts_namelen = 0; 1021 } 1022 1023 p->fts_path = sp->fts_path; 1024 p->fts_wcspath = sp->fts_wcspath; 1025 p->fts_statp = &p->fts_stat; 1026 p->fts_errno = 0; 1027 p->fts_flags = 0; 1028 p->fts_instr = FTS_NOINSTR; 1029 p->fts_number = 0; 1030 p->fts_pointer = NULL; 1031 p->fts_fts = sp; 1032 p->fts_symfd = INVALID_HANDLE_VALUE; 1033 p->fts_dirfd = INVALID_HANDLE_VALUE; 1034 } 939 1035 return (p); 940 1036 } 1037 1038 1039 /** 1040 * Converts the ANSI name to UTF-16 and calls fts_alloc. 1041 * 1042 * @returns Pointer to allocated and mostly initialized FTSENT structure on 1043 * success. NULL on failure, caller needs to record it. 1044 * @param sp Pointer to FTS instance. 1045 * @param name The ANSI name. 1046 * @param namelen The ANSI name length. 1047 */ 1048 static FTSENT * 1049 fts_alloc_ansi(FTS *sp, char const *name, size_t namelen) 1050 { 1051 MY_UNICODE_STRING UniStr; 1052 MY_ANSI_STRING AnsiStr; 1053 MY_NTSTATUS rcNt; 1054 FTSENT *pRet; 1055 1056 UniStr.Buffer = NULL; 1057 UniStr.MaximumLength = UniStr.Length = 0; 1058 1059 AnsiStr.Buffer = (char *)name; 1060 AnsiStr.Length = AnsiStr.MaximumLength = (USHORT)namelen; 1061 1062 rcNt = g_pfnRtlAnsiStringToUnicodeString(&UniStr, &AnsiStr, TRUE /*fAllocate*/); 1063 if (NT_SUCCESS(rcNt)) { 1064 pRet = fts_alloc(sp, name, namelen, UniStr.Buffer, UniStr.Length / sizeof(wchar_t)); 1065 HeapFree(GetProcessHeap(), 0, UniStr.Buffer); 1066 } else { 1067 pRet = NULL; 1068 } 1069 return pRet; 1070 } 1071 1072 1073 /** 1074 * Converts the UTF-16 name to ANSI (if necessary) and calls fts_alloc. 1075 * 1076 * @returns Pointer to allocated and mostly initialized FTSENT structure on 1077 * success. NULL on failure, caller needs to record it. 1078 * @param sp Pointer to FTS instance. 1079 * @param wcsname The UTF-16 name. 1080 * @param cwcname The UTF-16 name length. 1081 */ 1082 static FTSENT * 1083 fts_alloc_utf16(FTS *sp, wchar_t const *wcsname, size_t cwcname) 1084 { 1085 FTSENT *pRet; 1086 1087 if (sp->fts_options & FTS_NO_ANSI) { 1088 pRet = fts_alloc(sp, NULL, 0, wcsname, cwcname); 1089 } else { 1090 MY_UNICODE_STRING UniStr; 1091 MY_ANSI_STRING AnsiStr; 1092 MY_NTSTATUS rcNt; 1093 1094 UniStr.Buffer = (wchar_t *)wcsname; 1095 UniStr.MaximumLength = UniStr.Length = (USHORT)(cwcname * sizeof(wchar_t)); 1096 1097 AnsiStr.Buffer = NULL; 1098 AnsiStr.Length = AnsiStr.MaximumLength = 0; 1099 1100 rcNt = g_pfnRtlUnicodeStringToAnsiString(&AnsiStr, &UniStr, TRUE /*fAllocate*/); 1101 if (NT_SUCCESS(rcNt)) { 1102 pRet = fts_alloc(sp, AnsiStr.Buffer, AnsiStr.Length, wcsname, cwcname); 1103 HeapFree(GetProcessHeap(), 0, AnsiStr.Buffer); 1104 } else { 1105 pRet = NULL; 1106 } 1107 } 1108 return pRet; 1109 } 1110 941 1111 942 1112 static void … … 960 1130 */ 961 1131 static int 962 fts_palloc(FTS *sp, size_t more )1132 fts_palloc(FTS *sp, size_t more, size_t cwcmore) 963 1133 { 964 1134 void *ptr; 965 1135 966 sp->fts_pathlen += more + 256; 967 ptr = realloc(sp->fts_path, sp->fts_pathlen); 968 if (ptr) { 969 /*likely */ 970 } else { 971 free(sp->fts_path); 972 } 973 sp->fts_path = ptr; 974 return (ptr == NULL); 1136 /** @todo Isn't more and cwcmore minimum buffer sizes rather than what needs 1137 * to be added to the buffer?? This code makes no sense when looking at 1138 * the way the caller checks things out! */ 1139 1140 if (more) { 1141 sp->fts_pathlen += more + 256; 1142 ptr = realloc(sp->fts_path, sp->fts_pathlen); 1143 if (ptr) { 1144 sp->fts_path = ptr; 1145 } else { 1146 free(sp->fts_path); 1147 sp->fts_path = NULL; 1148 free(sp->fts_wcspath); 1149 sp->fts_wcspath = NULL; 1150 return 1; 1151 } 1152 } 1153 1154 if (cwcmore) { 1155 sp->fts_cwcpath += cwcmore + 256; 1156 ptr = realloc(sp->fts_wcspath, sp->fts_cwcpath); 1157 if (ptr) { 1158 sp->fts_wcspath = ptr; 1159 } else { 1160 free(sp->fts_path); 1161 sp->fts_path = NULL; 1162 free(sp->fts_wcspath); 1163 sp->fts_wcspath = NULL; 1164 return 1; 1165 } 1166 } 1167 return 0; 975 1168 } 976 1169 … … 1003 1196 } 1004 1197 1198 /* 1199 * When the UTF-16 path is realloc'd, have to fix all of the pointers in 1200 * structures already returned. 1201 */ 1202 static void 1203 fts_padjustw(FTS *sp, FTSENT *head) 1204 { 1205 FTSENT *p; 1206 wchar_t *addr = sp->fts_wcspath; 1207 1208 #define ADJUSTW(p) \ 1209 do { \ 1210 if ((p)->fts_wcsaccpath != (p)->fts_wcsname) \ 1211 (p)->fts_wcsaccpath = addr + ((p)->fts_wcsaccpath - (p)->fts_wcspath); \ 1212 (p)->fts_wcspath = addr; \ 1213 } while (0) 1214 1215 /* Adjust the current set of children. */ 1216 for (p = sp->fts_child; p; p = p->fts_link) 1217 ADJUSTW(p); 1218 1219 /* Adjust the rest of the tree, including the current level. */ 1220 for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { 1221 ADJUSTW(p); 1222 p = p->fts_link ? p->fts_link : p->fts_parent; 1223 } 1224 } 1225 1005 1226 static size_t 1006 1227 fts_maxarglen(char * const *argv) … … 1014 1235 } 1015 1236 1237 /** Returns the max string size (including term). */ 1238 static size_t 1239 fts_maxarglenw(wchar_t * const *argv) 1240 { 1241 size_t max = 0; 1242 for (; *argv; ++argv) { 1243 size_t len = wcslen(*argv); 1244 if (len > max) 1245 max = len; 1246 } 1247 return max + 1; 1248 } 1249 -
trunk/src/lib/nt/fts-nt.h
r2997 r2998 67 67 char *fts_path; /* path for this descent */ 68 68 size_t fts_pathlen; /* sizeof(path) */ 69 wchar_t *fts_wcspath; /* NT: UTF-16 path for this descent. */ 70 size_t fts_cwcpath; /* NT: size of fts_wcspath buffer */ 69 71 size_t fts_nitems; /* elements in the sort array */ 70 72 int (FTSCALL *fts_compar) /* compare function */ … … 85 87 #define FTS_NAMEONLY 0x100 /* (private) child names only */ 86 88 #define FTS_STOP 0x200 /* (private) unrecoverable error */ 89 #define FTS_NO_ANSI 0x40000000 /* NT: No ansi name or access path. */ 87 90 int fts_options; /* fts_open options, global flags */ 88 91 void *fts_clientptr; /* thunk for sort function */ … … 97 100 void *fts_pointer; /* local address value */ 98 101 char *fts_accpath; /* access path */ 102 wchar_t *fts_wcsaccpath; /* NT: UTF-16 access path */ 99 103 char *fts_path; /* root path */ 104 wchar_t *fts_wcspath; /* NT: UTF-16 root path */ 100 105 int fts_errno; /* errno for this node */ 101 106 fts_fd_t fts_symfd; /* NT: Normally -1; -2 we followed this symlinked dir */ 102 107 fts_fd_t fts_dirfd; /* NT: Handle to the directory (NT_FTS_)INVALID_HANDLE_VALUE if not valid */ 103 108 size_t fts_pathlen; /* strlen(fts_path) */ 109 size_t fts_cwcpath; /* NT: length of fts_wcspath. */ 104 110 size_t fts_namelen; /* strlen(fts_name) */ 111 size_t fts_cwcname; /* NT: length of fts_wcsname. */ 105 112 113 fts_nlink_t fts_nlink; /* link count */ 106 114 fts_ino_t fts_ino; /* inode */ 107 115 fts_dev_t fts_dev; /* device */ 108 fts_nlink_t fts_nlink; /* link count */109 116 110 117 #define FTS_ROOTPARENTLEVEL -1 … … 141 148 struct stat *fts_statp; /* stat(2) information */ 142 149 char *fts_name; /* file name */ 150 wchar_t *fts_wcsname; /* NT: UTF-16 file name. */ 143 151 FTS *fts_fts; /* back pointer to main FTS */ 144 152 BirdStat_T fts_stat; /* NT: We always got stat info. */ … … 156 164 FTS *FTSCALL nt_fts_get_stream(FTSENT *); 157 165 #define fts_get_stream(ftsent) ((ftsent)->fts_fts) 158 FTS *FTSCALL nt_fts_open(char * const *, int, 159 166 FTS *FTSCALL nt_fts_open(char * const *, int, int (FTSCALL*)(const FTSENT * const *, const FTSENT * const *)); 167 FTS *FTSCALL nt_fts_openw(wchar_t * const *, int, int (FTSCALL*)(const FTSENT * const *, const FTSENT * const *)); 160 168 FTSENT *FTSCALL nt_fts_read(FTS *); 161 169 int FTSCALL nt_fts_set(FTS *, FTSENT *, int); -
trunk/src/lib/nt/nthlpcore.c
r2985 r2998 61 61 BOOLEAN (WINAPI *g_pfnRtlDosPathNameToNtPathName_U)(PCWSTR, MY_UNICODE_STRING *, PCWSTR *, MY_RTL_RELATIVE_NAME_U *); 62 62 MY_NTSTATUS (WINAPI *g_pfnRtlAnsiStringToUnicodeString)(MY_UNICODE_STRING *, MY_ANSI_STRING const *, BOOLEAN); 63 MY_NTSTATUS (WINAPI *g_pfnRtlUnicodeStringToAnsiString)(MY_ANSI_STRING *, MY_UNICODE_STRING *, BOOLEAN); 63 64 BOOLEAN (WINAPI *g_pfnRtlEqualUnicodeString)(MY_UNICODE_STRING const *, MY_UNICODE_STRING const *, BOOLEAN); 64 65 BOOLEAN (WINAPI *g_pfnRtlEqualString)(MY_ANSI_STRING const *, MY_ANSI_STRING const *, BOOLEAN); … … 67 68 VOID (WINAPI *g_pfnRtlAcquirePebLock)(VOID); 68 69 VOID (WINAPI *g_pfnRtlReleasePebLock)(VOID); 69 70 70 71 71 static struct … … 88 88 { (FARPROC *)&g_pfnRtlDosPathNameToNtPathName_U, "RtlDosPathNameToNtPathName_U" }, 89 89 { (FARPROC *)&g_pfnRtlAnsiStringToUnicodeString, "RtlAnsiStringToUnicodeString" }, 90 { (FARPROC *)&g_pfnRtlUnicodeStringToAnsiString, "RtlUnicodeStringToAnsiString" }, 90 91 { (FARPROC *)&g_pfnRtlEqualUnicodeString, "RtlEqualUnicodeString" }, 91 92 { (FARPROC *)&g_pfnRtlEqualString, "RtlEqualString" }, -
trunk/src/lib/nt/ntstuff.h
r2985 r2998 556 556 extern BOOLEAN (WINAPI * g_pfnRtlDosPathNameToNtPathName_U)(PCWSTR, MY_UNICODE_STRING *, PCWSTR *, MY_RTL_RELATIVE_NAME_U *); 557 557 extern MY_NTSTATUS (WINAPI * g_pfnRtlAnsiStringToUnicodeString)(MY_UNICODE_STRING *, MY_ANSI_STRING const *, BOOLEAN); 558 extern MY_NTSTATUS (WINAPI * g_pfnRtlUnicodeStringToAnsiString)(MY_ANSI_STRING *, MY_UNICODE_STRING *, BOOLEAN); 558 559 extern BOOLEAN (WINAPI * g_pfnRtlEqualUnicodeString)(MY_UNICODE_STRING const *pUniStr1, MY_UNICODE_STRING const *pUniStr2, 559 560 BOOLEAN fCaseInsensitive);
Note:
See TracChangeset
for help on using the changeset viewer.