* one interpreter will be used to add/remove mounts and volumes,
* it does cope with multiple interpreters in multiple threads.
*
- * Copyright (c) 2001 Vince Darley.
+ * Copyright (c) 2001-2003 Vince Darley.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#ifdef BUILD_vfs
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
-#endif /* BUILD_Vfs */
+#endif /* BUILD_vfs */
/*
* Only the _Init function is exported.
return TCL_ERROR;
}
Tcl_SetErrno(posixError);
- return TCL_OK;
+ return -1;
}
case VFS_NORMALIZE: {
Tcl_Obj *path;
} else {
/* Leave an error message if the cmdInterp is non NULL */
if (cmdInterp != NULL) {
- int posixError = -1;
- Tcl_Obj* error = Tcl_GetObjResult(interp);
- if (Tcl_GetIntFromObj(NULL, error, &posixError) == TCL_OK) {
- Tcl_SetErrno(posixError);
+ if (returnVal == -1) {
Tcl_ResetResult(cmdInterp);
Tcl_AppendResult(cmdInterp, "couldn't open \"",
Tcl_GetString(pathPtr), "\": ",
Tcl_PosixError(interp), (char *) NULL);
-
} else {
+ Tcl_Obj* error = Tcl_GetObjResult(interp);
/*
* Copy over the error message to cmdInterp,
* duplicating it in case of threading issues.
channelRet->interp = interp;
channelRet->closeCallback = closeCallback;
/* The channelRet structure will be freed in the callback */
- Tcl_CreateCloseHandler(chan, &VfsCloseProc, (ClientData)channelRet);
+ Tcl_CreateCloseHandler(chan, &VfsCloseProc,
+ (ClientData)channelRet);
}
}
return chan;
if (pattern == NULL) {
Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewObj());
} else {
- Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewStringObj(pattern,-1));
+ Tcl_ListObjAppendElement(interp, mountCmd,
+ Tcl_NewStringObj(pattern,-1));
}
Tcl_ListObjAppendElement(interp, mountCmd, Tcl_NewIntObj(type));
Tcl_SaveResult(interp, &savedResult);
static int
VfsDeleteFile(
- Tcl_Obj *pathPtr) /* Pathname of file to be removed (UTF-8). */
+ Tcl_Obj *pathPtr) /* Pathname of file to be removed */
{
Tcl_Obj *mountCmd = NULL;
Tcl_SavedResult savedResult;
static int
VfsCreateDirectory(
- Tcl_Obj *pathPtr) /* Pathname of directory to create (UTF-8). */
+ Tcl_Obj *pathPtr) /* Pathname of directory to create */
{
Tcl_Obj *mountCmd = NULL;
Tcl_SavedResult savedResult;
} else {
Tcl_ListObjAppendElement(NULL, mountCmd,
Tcl_NewStringObj(normedString,splitPosition));
- if ((normedString[splitPosition] != VFS_SEPARATOR) || (VFS_SEPARATOR ==':')) {
+ if ((normedString[splitPosition] != VFS_SEPARATOR)
+ || (VFS_SEPARATOR ==':')) {
/* This will occur if we mount 'ftp://' */
splitPosition--;
}
proc vfs::http::access {dirurl name mode} {
::vfs::log "access $name $mode"
if {$mode & 2} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
if {$name == ""} { return 1 }
set state [::http::geturl "$dirurl$name"]
}
"a" -
"w*" {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
default {
return -code error "illegal access mode \"$mode\""
proc vfs::http::createdirectory {dirurl name} {
::vfs::log "createdirectory $name"
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc vfs::http::removedirectory {dirurl name} {
::vfs::log "removedirectory $name"
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc vfs::http::deletefile {dirurl name} {
::vfs::log "deletefile $name"
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc vfs::http::fileattributes {dirurl path args} {
# set value
set index [lindex $args 0]
set val [lindex $args 1]
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
}
}
proc vfs::http::utime {dirurl path actime mtime} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc access {db name mode} {
if {$mode & 2} {
if {$::mk4vfs::v::mode($db) == "readonly"} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
}
# We can probably do this more efficiently, can't we?
}
a {
if {$::mk4vfs::v::mode($db) == "readonly"} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
if { [catch {::mk4vfs::stat $db $file sb }] } {
# Create file
}
w* {
if {$::mk4vfs::v::mode($db) == "readonly"} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
if { [catch {::mk4vfs::stat $db $file sb }] } {
# Create file
2 {
# set value
if {$::mk4vfs::mode($db) == "readonly"} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
set index [lindex $args 0]
set val [lindex $args 1]
proc mkdir {db path} {
if {$v::mode($db) == "readonly"} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
set sp [::file split $path]
set parent 0
proc mtime {db path time} {
if {$v::mode($db) == "readonly"} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
stat $db $path sb
if { $sb(type) == "file" } {
proc delete {db path {recursive 0}} {
#puts stderr "mk4delete db $db path $path recursive $recursive"
if {$v::mode($db) == "readonly"} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
stat $db $path sb
if {$sb(type) == "file" } {
proc vfs::tar::access {tarfd name mode} {
if {$mode & 2} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
# Readable, Exists and Executable are treated as 'exists'
# Could we get more information from the archive?
"" -
"r" {
if {![::tar::exists $tarfd $name]} {
- return -code error $::vfs::posix(ENOENT)
+ vfs::filesystem posixerror $::vfs::posix(ENOENT)
}
::tar::stat $tarfd $name sb
return [list $nfd]
}
default {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
}
}
proc vfs::tar::createdirectory {tarfd name} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
#error "tar-archives are read-only (not implemented)"
}
proc vfs::tar::removedirectory {tarfd name} {
#::vfs::log "removedirectory $name"
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
#error "tar-archives are read-only (not implemented)"
}
proc vfs::tar::deletefile {tarfd name} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
#error "tar-archives are read-only (not implemented)"
}
# set value
set index [lindex $args 0]
set val [lindex $args 1]
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
}
}
# set the 'mtime' of a file.
proc vfs::tar::utime {fd path actime mtime} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
#
proc vfs::zip::access {zipfd name mode} {
#::vfs::log "zip-access $name $mode"
if {$mode & 2} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
# Readable, Exists and Executable are treated as 'exists'
# Could we get more information from the archive?
"" -
"r" {
if {![::zip::exists $zipfd $name]} {
- return -code error $::vfs::posix(ENOENT)
+ vfs::filesystem posixerror $::vfs::posix(ENOENT)
}
::zip::stat $zipfd $name sb
return [list $nfd]
}
default {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
}
}
proc vfs::zip::createdirectory {zipfd name} {
#::vfs::log "createdirectory $name"
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc vfs::zip::removedirectory {zipfd name} {
#::vfs::log "removedirectory $name"
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc vfs::zip::deletefile {zipfd name} {
#::vfs::log "deletefile $name"
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
proc vfs::zip::fileattributes {zipfd name args} {
# set value
set index [lindex $args 0]
set val [lindex $args 1]
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
}
}
proc vfs::zip::utime {fd path actime mtime} {
- return -code error [vfs::filesystem posixerror $::vfs::posix(EROFS)]
+ vfs::filesystem posixerror $::vfs::posix(EROFS)
}
# Below copied from TclKit distribution