23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
Tcl_Obj *mountpoint;
};
/*
* Internal Core Utilities
*/
static const char *xvfs_relativePath(Tcl_Obj *path, struct xvfs_tclfs_instance_info *info) {
const char *pathStr, *rootStr;
const char *pathFinal;
int pathLen, rootLen;
rootStr = Tcl_GetStringFromObj(info->mountpoint, &rootLen);
pathStr = Tcl_GetStringFromObj(path, &pathLen);
if (pathStr[0] != '/') {
path = Tcl_ObjPrintf("%s/%s", Tcl_GetString(Tcl_FSGetCwd(NULL)), pathStr);
pathStr = Tcl_GetStringFromObj(path, &pathLen);
}
if (pathLen < rootLen) {
return(NULL);
}
|
>
>
>
>
>
|
>
>
>
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
Tcl_Obj *mountpoint;
};
/*
* Internal Core Utilities
*/
static const char *xvfs_relativePath(Tcl_Obj *path, struct xvfs_tclfs_instance_info *info) {
Tcl_Obj *currentDirectory;
const char *pathStr, *rootStr;
const char *pathFinal;
int pathLen, rootLen;
rootStr = Tcl_GetStringFromObj(info->mountpoint, &rootLen);
pathStr = Tcl_GetStringFromObj(path, &pathLen);
if (pathStr[0] != '/') {
currentDirectory = Tcl_FSGetCwd(NULL);
Tcl_IncrRefCount(currentDirectory);
/* XXX:TODO: Free this */
path = Tcl_ObjPrintf("%s/%s", Tcl_GetString(currentDirectory), pathStr);
Tcl_IncrRefCount(path);
Tcl_DecrRefCount(currentDirectory);
pathStr = Tcl_GetStringFromObj(path, &pathLen);
}
if (pathLen < rootLen) {
return(NULL);
}
|
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
child = children[idx];
if (!Tcl_StringMatch(child, pattern)) {
continue;
}
childObj = Tcl_DuplicateObj(path);
Tcl_AppendStringsToObj(childObj, "/", child, NULL);
Tcl_IncrRefCount(childObj);
if (!xvfs_tclfs_verifyType(childObj, types, instanceInfo)) {
Tcl_DecrRefCount(childObj);
continue;
}
|
<
>
|
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
|
child = children[idx];
if (!Tcl_StringMatch(child, pattern)) {
continue;
}
childObj = Tcl_DuplicateObj(path);
Tcl_IncrRefCount(childObj);
Tcl_AppendStringsToObj(childObj, "/", child, NULL);
if (!xvfs_tclfs_verifyType(childObj, types, instanceInfo)) {
Tcl_DecrRefCount(childObj);
continue;
}
|
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
|
xvfs_tclfs_standalone_fs.lstatProc = NULL;
xvfs_tclfs_standalone_fs.loadFileProc = NULL;
xvfs_tclfs_standalone_fs.getCwdProc = NULL;
xvfs_tclfs_standalone_fs.chdirProc = NULL;
xvfs_tclfs_standalone_info.fsInfo = fsInfo;
xvfs_tclfs_standalone_info.mountpoint = Tcl_NewObj();
Tcl_AppendStringsToObj(xvfs_tclfs_standalone_info.mountpoint, XVFS_ROOT_MOUNTPOINT, fsInfo->name, NULL);
tcl_ret = Tcl_FSRegister(NULL, &xvfs_tclfs_standalone_fs);
if (tcl_ret != TCL_OK) {
if (interp) {
Tcl_SetResult(interp, "Tcl_FSRegister() failed", NULL);
}
return(tcl_ret);
}
|
>
>
|
>
>
|
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
|
xvfs_tclfs_standalone_fs.lstatProc = NULL;
xvfs_tclfs_standalone_fs.loadFileProc = NULL;
xvfs_tclfs_standalone_fs.getCwdProc = NULL;
xvfs_tclfs_standalone_fs.chdirProc = NULL;
xvfs_tclfs_standalone_info.fsInfo = fsInfo;
xvfs_tclfs_standalone_info.mountpoint = Tcl_NewObj();
Tcl_IncrRefCount(xvfs_tclfs_standalone_info.mountpoint);
Tcl_AppendStringsToObj(xvfs_tclfs_standalone_info.mountpoint, XVFS_ROOT_MOUNTPOINT, fsInfo->name, NULL);
tcl_ret = Tcl_FSRegister(NULL, &xvfs_tclfs_standalone_fs);
if (tcl_ret != TCL_OK) {
Tcl_DecrRefCount(xvfs_tclfs_standalone_info.mountpoint);
if (interp) {
Tcl_SetResult(interp, "Tcl_FSRegister() failed", NULL);
}
return(tcl_ret);
}
|