| ︙ | | |
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
-
+
-
+
-
+
-
+
-
+
|
#ifdef DJGPP
if (name[1] == ':')
#else
if (name[0] == '/')
#endif
{
encoding = Tcl_GetEncoding(NULL, NULL);
Tcl_ExternalToUtfDString(encoding, name, -1, &utfName);
Tcl_ExternalToUtfDString(encoding, name, TCL_NOSIZE, &utfName);
TclSetObjNameOfExecutable(
Tcl_NewStringObj(Tcl_DStringValue(&utfName), -1), encoding);
Tcl_NewStringObj(Tcl_DStringValue(&utfName), TCL_NOSIZE), encoding);
Tcl_DStringFree(&utfName);
goto done;
}
/*
* The name is relative to the current working directory. First strip off
* a leading "./", if any, then add the full path name of the current
* working directory.
*/
if ((name[0] == '.') && (name[1] == '/')) {
name += 2;
}
Tcl_DStringInit(&nameString);
Tcl_DStringAppend(&nameString, name, -1);
Tcl_DStringAppend(&nameString, name, TCL_NOSIZE);
TclpGetCwd(NULL, &cwd);
Tcl_DStringFree(&buffer);
Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&cwd),
Tcl_DStringLength(&cwd), &buffer);
if (Tcl_DStringValue(&cwd)[Tcl_DStringLength(&cwd) -1] != '/') {
TclDStringAppendLiteral(&buffer, "/");
}
Tcl_DStringFree(&cwd);
TclDStringAppendDString(&buffer, &nameString);
Tcl_DStringFree(&nameString);
encoding = Tcl_GetEncoding(NULL, NULL);
Tcl_ExternalToUtfDString(encoding, Tcl_DStringValue(&buffer), -1,
Tcl_ExternalToUtfDString(encoding, Tcl_DStringValue(&buffer), TCL_NOSIZE,
&utfName);
TclSetObjNameOfExecutable(
Tcl_NewStringObj(Tcl_DStringValue(&utfName), -1), encoding);
Tcl_NewStringObj(Tcl_DStringValue(&utfName), TCL_NOSIZE), encoding);
Tcl_DStringFree(&utfName);
done:
Tcl_DStringFree(&buffer);
#endif
}
|
| ︙ | | |
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
-
+
|
}
}
/*
* Now open the directory for reading and iterate over the contents.
*/
native = Tcl_UtfToExternalDString(NULL, dirName, -1, &ds);
native = Tcl_UtfToExternalDString(NULL, dirName, TCL_NOSIZE, &ds);
if ((TclOSstat(native, &statBuf) != 0) /* INTL: Native. */
|| !S_ISDIR(statBuf.st_mode)) {
Tcl_DStringFree(&dsOrig);
Tcl_DStringFree(&ds);
Tcl_DecrRefCount(fileNamePtr);
return TCL_OK;
|
| ︙ | | |
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
-
+
-
+
|
}
/*
* Now check to see if the file matches, according to both type
* and pattern. If so, add the file to the result.
*/
utfname = Tcl_ExternalToUtfDString(NULL, entryPtr->d_name, -1,
utfname = Tcl_ExternalToUtfDString(NULL, entryPtr->d_name, TCL_NOSIZE,
&utfDs);
if (Tcl_StringCaseMatch(utfname, pattern, 0)) {
int typeOk = 1;
if (types != NULL) {
Tcl_DStringSetLength(&ds, nativeDirLen);
native = Tcl_DStringAppend(&ds, entryPtr->d_name, -1);
native = Tcl_DStringAppend(&ds, entryPtr->d_name, TCL_NOSIZE);
matchResult = NativeMatchType(interp, native,
entryPtr->d_name, types);
typeOk = (matchResult == 1);
}
if (typeOk) {
Tcl_ListObjAppendElement(interp, resultPtr,
TclNewFSPathObj(pathPtr, utfname,
|
| ︙ | | |
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
|
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
|
-
+
-
+
|
TclpGetUserHome(
const char *name, /* User name for desired home directory. */
Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with
* name of user's home directory. */
{
struct passwd *pwPtr;
Tcl_DString ds;
const char *native = Tcl_UtfToExternalDString(NULL, name, -1, &ds);
const char *native = Tcl_UtfToExternalDString(NULL, name, TCL_NOSIZE, &ds);
pwPtr = TclpGetPwNam(native); /* INTL: Native. */
Tcl_DStringFree(&ds);
if (pwPtr == NULL) {
return NULL;
}
Tcl_ExternalToUtfDString(NULL, pwPtr->pw_dir, -1, bufferPtr);
Tcl_ExternalToUtfDString(NULL, pwPtr->pw_dir, TCL_NOSIZE, bufferPtr);
return Tcl_DStringValue(bufferPtr);
}
/*
*---------------------------------------------------------------------------
*
* TclpObjAccess --
|
| ︙ | | |
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
|
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
|
-
+
|
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error getting working directory name: %s",
Tcl_PosixError(interp)));
}
return NULL;
}
return Tcl_ExternalToUtfDString(NULL, buffer, -1, bufferPtr);
return Tcl_ExternalToUtfDString(NULL, buffer, TCL_NOSIZE, bufferPtr);
}
/*
*---------------------------------------------------------------------------
*
* TclpReadlink --
*
|
| ︙ | | |
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
|
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
|
-
+
|
{
#ifndef DJGPP
char link[MAXPATHLEN];
int length;
const char *native;
Tcl_DString ds;
native = Tcl_UtfToExternalDString(NULL, path, -1, &ds);
native = Tcl_UtfToExternalDString(NULL, path, TCL_NOSIZE, &ds);
length = readlink(native, link, sizeof(link)); /* INTL: Native. */
Tcl_DStringFree(&ds);
if (length < 0) {
return NULL;
}
|
| ︙ | | |
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
|
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
|
-
+
|
Tcl_Obj *
TclpNativeToNormalized(
ClientData clientData)
{
Tcl_DString ds;
Tcl_ExternalToUtfDString(NULL, (const char *) clientData, -1, &ds);
Tcl_ExternalToUtfDString(NULL, (const char *) clientData, TCL_NOSIZE, &ds);
return TclDStringToObj(&ds);
}
/*
*---------------------------------------------------------------------------
*
* TclNativeCreateNativeRep --
|
| ︙ | | |