Forum OpenACS Development: Re: NaviServer on Windows: [ns_logroll] returns "Permission denied"

Dear Enrique,
I have implemented the following changes into my Windows-OpenACS distribution:

static int
Rename(const char *from, const char *to)
{
int err;
Tcl_Obj *fromObj, *toObj;

NS_NONNULL_ASSERT(from != NULL);
NS_NONNULL_ASSERT(to != NULL);

fromObj = Tcl_NewStringObj(from, -1);
Tcl_IncrRefCount(fromObj);

toObj = Tcl_NewStringObj(to, -1);
Tcl_IncrRefCount(toObj);

#ifdef WIN32
err != CopyFile(from, to, FALSE);
if (err == 0) {
DeleteFile(from);
}
#else
err = Tcl_FSRenameFile(fromObj, toObj);
#endif
Tcl_DecrRefCount(fromObj);
Tcl_DecrRefCount(toObj);
if (err != 0) {
Ns_Log(Error, "rollfile: failed to rename file '%s' to '%s': '%s'",
from, to, strerror(Tcl_GetErrno()));
}

return err;
}

with this change the rolling of the log files works also on Windows.

Once again thank you,
Maurizio

I did find the following piece of text inside TCL's code:

"The many functions in this structure are broken down into three
categories: infrastructure functions (almost all of which must be
implemented), operational functions (which must be implemented if a
complete filesystem is provided), and efficiency functions (which need
only be implemented if they can be done so efficiently, or if they have
side-effects which are required by the filesystem; Tcl has less
efficient emulations it can fall back on). It is important to note
that, in the current version of Tcl, most of these fallbacks are only
used to handle commands initiated in Tcl, not in C. What this means is,
that if a "file rename" command is issued in Tcl, and the relevant
filesystem(s) do not implement their "Tcl_FSRenameFileProc", Tcl's
core will instead fallback on a combination of other filesystem
functions (it will use "Tcl_FSCopyFileProc" followed by
"Tcl_FSDeleteFileProc", and if "Tcl_FSCopyFileProc\"is not
implemented there is a further fallback). However, if a
"Tcl_FSRenameFileProc" command is issued at the C level, no such
fallbacks occur
.
[...]
"